Dynamic context provides a content synchronization mechanism based on portlets. Content synchronization is needed when the content rendered in a given portlet is a direct function of the latest content of another portlet in the current active portal page.
The necessity for the dynamic context infrastructure is determined by the requirement to have the portlets on the same portal page display the content that is binded by a common dynamic context.
The following example illustrates dynamic context for the B2B direct portal application:
- Four portlets (Account List, Contract List, Order List, and Invoice List) are in the portal application. When the user selects an account in the Account List portlet, the portlets are updated depending on the selected account. The Contract List portlet displays the list of contracts for that account, while the Order List portlet displays the list of orders, and Invoice List portlet displays the list of invoices.
- The dynamic context that is shared between the portlets is the accountId specified in the Account List portlet. Portlets are typically independent from one another, but the dynamic context sharing feature provides a new mechanism to map the relations of portlets and articulate their dependency on each other at time of portlet application deployment and configuration. The portlet itself does not need to be changed.
The dynamic context is based on the idea of the dynamic context portlet group. Given all portlets within a given portlet application, the dynamic context portlet group defines the subset of portlets within a given portlet application that share the same dynamic context. A given portlet application may have zero or more dynamic context portlet groups.
Each dynamic context group has the following elements:
- Dynamic Context: Dynamic context defines the context that all portlets within the same dynamic context group share. Each dynamic context group should only have one dynamic context. In the event that more than one dynamic context is required, another new dynamic context group can be created.
- Dynamic Context Master Portlet: Each dynamic context group has only one portlet that functions as the dynamic context master portlet. The dynamic context master portlet watches for the change in the defined dynamic context and as a result, drives the defined behavior (action) of each dynamic context slave portlet.
- Dynamic Context Slave Portlets: Each dynamic context portlet group must of at least one dynamic context slave portlet. Each dynamic context slave portlet must define the slave portlet action, which is the pre-defined action of the slave in relation to the dynamic context. The slave portlet action performs the registered action upon notification of the change in dynamic context.
The dynamic context group definition requirement is captured in an XML schema called the Dynamic Context Portlet Group Definition Template, that provides the formal definition of the dynamic context portlet group:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:annotation> <xsd:documentation xml:lang="en"> Schema for Websphere Commerce Enabled Portal Dynamic Context Group Definition Copyright 2002 IBM Corporation </xsd:documentation> </xsd:annotation> <xsd:element name="DynamicContextGroups" type="DynamicContextGroupsType"/> <xsd:complexType name="DynamicContextGroupsType"> <xsd:sequence> <xsd:element name="DynamicContextGroup" type="DynamicContextGroupDefinition Template" minOccurs="1" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="DynamicContextGroupDefinitionTemplate"> <xsd:sequence> <xsd:element name="DynamicContextGroupName" type="xsd:string"/> <xsd:element name="DynamicContextMasterPortlet" type="xsd:string"/> <xsd:element name="DynamicContext" type="xsd:string" maxOccurs="1"/> <xsd:element name="DynamicContextSlavePortlet" type="SlavePortletType" minOccurs="1" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="SlavePortletType"> <xsd:sequence> <xsd:element name="DynamicContextSlavePortletName" type="xsd:string"/> <xsd:element name="SlavePortletAction" type="xsd:string"/> <xsd:element name="SlavePortletRefreshPriority" type="xsd:decimal" minOccurs="0"/> <xsd:element name="SlaveParamMapToContext" type="xsd:string" minOccurs="0"/> </xsd:sequence> </xsd:complexType> </xsd:schema>
The schema file is provided with the Dynamic Context Portlet Group Assembly Tool Plug-in.
To familiarize yourself with creating a dynamic context relationship, complete the following tutorial: