The following sample demonstrates the use of Portlet Adapter builder's 'Profile Edit and Configure Options' for customizing the portlet instance based on default profile selected in Edit Shared Settings mode. The scenario is best suited for solutions where a common UI is required to be presented in different pages but with changes to content based on portlet instance, and available to all users.
Basic understanding of the terminology is required,
Edit Defaults (Settings): Changes made here affect a particular occurrence of a portlet on a page and apply to all users who view the portlet on that page. In order for a user to have access to edit shared settings they must be granted at least Editor role on the page and Editor role on the corresponding Portlet definition. A users Edit settings will override the Edit Default settings. This is available for JSR 168 compliant portlets and IBM portlets. This is also known as Edit Shared Settings.
Profile Sets Input in Portlet Adapter definition: Determines how profile sets and profile entries get exposed in the Edit and Configure modes of the portlet. For each profile set associated with the portlet model, the builder call editor for the Portlet Adapter builder displays its name as the prompt for a selectable input with following options:
Do not expose in Portal tools
Show individual profile values in Edit and Edit Defaults
Show Profile names in Edit and Edit Defaults
Show Individual Profile Values in configure
Show profile names in configure.
Show individual profile values in Edit Defaults
Show profile names in Edit Defaults
The following sample demonstrates last option "Show Profile names in Edit Defaults" to set a default color for individual portlet instances. Following are the steps to create this sample portlet.
Step-1: Create a simple model with main Action List and page builder, 'page1'.
Step-2: Edit the page 'page1' to add a table and a named page location "namedTag" to display the value of color selected in text. See Fig.1below, 'portletView_namedTag' is pagelocation for the Table enclosing default portlet view.
Step-3: Add a Variable builder of type String to persist and display the default selected color value. See Fig.2
Step-4: Add profiling to default value for this variable. Following profile entries and values are used.
Step-5: Now to display the selected color as background color, add an Attribute Setter builder to set the background color. Assign the attribute setter to the TABLE pagelocation and with "bgcolor" as attribute name and set the above defined string variable as attribute value.
Step-6: Add a Text builder to print the default color selected on the portlet view.
Step-7: Add a Portlet Adapter builder to support this application as Portlet and provide the builder inputs for Portlet Adapter such as name, title etc,. Notice that the profile set which was used to profile the value of bgcolor string variable now appears under "Profile Sets" section. Select "Show profile names in Edit Defaults" option.
Step-8: Deploy the sample portlet application, and login to portal administration to place this portlet in our 'Color Sample' page. For purpose of demonstration, add 4 instances of same portlet on the same page.
Step-9: Goto "Edit Shared Settings" mode for each portlet instance, notice the profile set which was used to profile 'bgcolor' string variable is provided with profile entry names as options. Select the default profile to be applied for this portlet instance. If default profile selected for a portlet instance is "Green", then 'bgcolor' default value will be the profile for "Green" and its profile value "green".
Step-10: Click OK on Edit Shared Settings page, and similarly save your changes for all the portlet instances on this page. Navigate to the portal page to see the changes applied successfully with different default profiles applied to "bgcolor".
The following are the list of builders used in this sample.
As shown in the above sample, by exposing the profile sets used in your models developers can create multiple portlet instances with different UI features , reusing the same portlet models and underlying code.