Overview: Developing a dynamic UI configuration | HCL Digital Experience
Get an overview of the main tasks involved in creating a dynamic UI configuration.
About this task
- Planning
- Creating the extension node for containing dynamic pages
- Developing the portlet definition for dynamic portlets
- Developing the page definition for dynamic pages
- Developing the dynamic UI launching portlet
- Providing controls for closing dynamic UIs.
- Testing the configuration
- Deploying the configuration
Procedure
- Planning. Determine the requirements of the
dynamic UI configuration. The following are some of the questions
that can help you in the planning process.
- What is the layout of the page definition?
- Should the page definitions be viewable by users? If not, where in the portal topology should they be placed?
- Where should the extension node be placed in the portal topology?
- What information needs to be passed to each dynamic UI? How will the portlets use that information?
- How will the UI be closed? Should you use tags to allow the user to close dynamic pages and dynamic portlets? If not, is it the responsibility of the calling portlet or a dynamic portlet to close the UI?
- Creating the extension node for dynamic pages.
-
Developing the portlet definition for dynamic portlets. Any existing portlet can be used as the
definition for a dynamic portlet. For standard portlets, be sure to set the ID attribute for the
<portlet-app/>
element in portlet.xml. The launching portlet uses this value, plus the<portlet-name/>
, to obtain the object ID of the portlet definition. For HCL portlets, the uid attribute of the<portlet-app/>
element is used.Determine what properties need to be passed to the portlet.- Portlet deployment descriptor considerations
- To receive portlet properties, the com.ibm.portal.context.enable preference parameter must be set in the
portlet.xml with a value of true. By default, this value
is set to false.
- For standard
portlets:
<portlet-preferences> ... <preference> <name>com.ibm.portal.context.enable</name> <value>true</value> </preference> ... </portlet-preferences>
- For HCL
portlets
... <config-param> <param-name>com.ibm.portal.context.enable</param-name> <param-value>true</param-value> </config-param> ...
Additionally, you must also modify the file web.xml for HCL portlets to receive portlet properties. The servlet class entry should specify the com.ibm.wps.pb.wrapper.PortletWrapper class. SeePackaging, deploying and compiling cooperative portlets for more information and an example.
- For standard
portlets:
- Considerations for retrieving context
- Standard portlets receive page properties on the processAction() method using the
com.ibm.portal.context request attribute. The value of this attribute is a
Map storing the context entries. Each property value is obtained by name. The
name and value of each property value is determined by the requirements of your dynamic UI
configuration. Use the following code sample to get a value for the property with the name propertyName:
public void processAction (ActionRequest request, ActionResponse response) throws PortletException, java.io.IOException { // perform application specific action handling ... // perform page context processing String specialAction = request.getParameter("com.ibm.portal.action"); if (specialAction != null && specialAction.equals("com.ibm.portal.context.receive")) { //this indicates context was passed to the launched page java.util.Map contextMap = (java.util.Map) request.getAttribute("com.ibm.portal.context"); Object propertyValue = (Object) contextMap.get(<propertyName>); portletSession.setAttribute(<propertyName>, propertyValue); } }
HCL portlets must implement the PropertyListener interface that provides the setProperties() method, which provides the page properties as an array of PropertyValue objects.
In this sample, a loop is used to scan the array for the task properties.public void setProperties(PortletRequest request, PropertyValue contextArray[]) { Object propertyValue; for (int i = 0; i < contextArray.length; i++) { String propertyName = contextArray[i].getProperty().getName(); if(propertyName.equals(<propertyName>)) { propertyValue = (Object)contextArray[i].getValue(); } } request.getSession().setAttribute(<propertyName>, propertyValue); }
- IBM portlet considerations
- To receive portlet properties, the com.ibm.portal.context.enable configuration parameter is specified in the portlet.xml. This parameter plays the same functional role as the standard portlet preference. Additionally, you must also modify the web.xml file to receive portlet properties. The servlet class entry should specify the com.ibm.wps.pb.wrapper.PortletWrapper class. See the Packaging, deploying and compiling cooperative portlets section for more information.
- Developing the page definition for dynamic
pages.
- Create the layout and content of the page definition from which dynamic pages are launched. For development purposes, you can use Manage Pages as you work with the visual layout.
- Assign a unique name to the page using the Unique names portlet. The portlet uses this name to lookup the object ID of the page definition.
- Developing the dynamic UI launching portlet
- Providing controls for closing dynamic UIs.
In many cases you can allow the user to explicitly close a dynamic UI from a theme or skin. These icons are enabled by using the
<portal:closePage/>
and<portal:closePortlet/>
tags. See Tags used by the portal JSPs for more information.As an alternative, the launching portlet can close a dynamic UI using the removePage() or removePortlet() methods of the DynamicUICtrl interface, providing the object ID of the dynamic UI as input on the call. If removing a dynamic portlet, the calling portlet must be on the same page.
- Testing the configuration. Each dynamic UI configuration has its own requirements, design, and implementation, and therefore, a different set of test cases. However, you should always verify the following general behaviors.
- Pages and portlets are created and removed successfully.
- Each time a dynamic UI is launched, a new instance of the page or portlet is created or, in the case of shared dynamic UIs, the user is returned to an existing instance.
- Properties are passed and processed by the dynamic portlets as expected.
- As portlets are added and removed from a dynamic page, the page maintains a balanced layout.
- Deploying the configurationWhen the dynamic UI configuration is ready to be promoted to a production level server, create the XMLAccess scripts that contain the necessary page and portlet definitions. You can use the Manage Pages portlet to export the page configuration to XMLAccess, including any wires or unique names used by the configuration.