Friday, 16 March 2012

Working with portlet container in websphere application server 7.0-Part5


Portlet aggregation tag library generates a portlet aggregation framework to address one or more portlets on one page If you write JavaServer Pages, you can aggregate multiple portlets on one page using the aggregation tag library. This tag library does not provide full featured portal aggregation implementation, but provides a good migration scenario if you already have aggregating servlets and JavaServer Pages and want to switch to portlets.

To allow the customer to create a simple portal aggregation, the aggregation tag library also provides the following features.
  • Invoke a portlet's action method
  • Render multiple portlets on one page
  • Provide links to change the portlet's mode or window state
  • Display the portlet's title
  • Retain the portlet cookie state
The aggregation tag library and JavaServer Pages that use the aggregation tag library will only work with the WebSphere Application Server portlet container implementation because the protocol between the tags and the container is not standardized.

The following diagram depicts how an HTML page would look like and what tags are used in order to create the page.  

 
When you use the aggregation tag library, you must set the portletUrlPrefix attribute of the init tag to the aggregating application. You need to:
  • Ensure that the portletUrlPrefix attribute is set to the following in the aggregator page.
"http://" + <server_address> + ":" + <server_port> + "/" + <aggregator context> + "/" <aggregator mapping>
  • Reference the aggregation JSP page within the web.xml file through a servlet mapping ending with /*. For example, /aggregation/*
When aggregating multiple portlets on a single page, special care must be used with the naming conventions of form attribute names in your portlets. Because your portlets are all on the same page, they all share the same HttpServletRequest. When one portlet is viewed the entire page is refreshed and form data is re-posted. Therefore, if there are multiple portlets that are aggregated on a single page with the same form attribute names, there could be logic corruption when form data is re-posted.

Aggregation tag library attributes

The aggregation tag library is used to aggregate multiple portlets on one page. This topic describes the attributes within the aggregation tag library.
Supported arguments include:
init
This tag initializes the portlet framework and has to be used in the beginning of the JSP. All other tags described in this section are only valid in the body of this tag, therefore the init tag usually encloses the whole body of a JSP. In case the current URL contains an action flag the action method of the corresponding portlet is called. The state and insert tags are sub-tags of the init tag.
 
The init tag has the following attributes: 
  • portletURLPrefix = ”<any string>”This URL defines the prefix used for PortletURLs. Portlet URLs are created either by the state tag or within a portlet's render method, which is called by using the insert tag. This is a required attribute.
  • portletURLSuffix = ”<any string>” This URL defines the suffix used for PortletURLs. Portlet URLs are created either by the state tag or within a portlet's render method, which is called by using the insert tag. This is attribute optional.
  • portletURLQueryParams = ”<any string>”
    This URL defines the query parameters used for PortletURLs. Portlet URLs are created either by the state tag or within a portlet's render method, which is called by using the insert tag. This is attribute optional.

scope, portlet
 
The scope tag and portlet tag are used to provide information that is necessary when a portlet application is installed under a multiple part context root, for example, /context1/context2. these tags also define which portlet windows should participate in portlet coordination via public render parameters, and add a render parameter to the newly created URL.
 
The urlParam tag has the following attributes:
  • context = "/<context1>/<context2>"Specifies the context root of the portlet application in which the portlet is deployed. This attribute is required.
  • portletname = "<portlet-name>"Specifies the portlet-name. This attribute is required.
  • windowId = ”<any string>” Defines the window ID for the concrete portlet instance. This attribute is required.
state
 
The state tag creates a URL pointing to the given portlet using the given state. You can place this URL either into a variable specified by the var attribute or you can write it directly to the output stream. This tag is useful to create URLs for HTML buttons, images, and other items such that when the URL is invoked, the state changes defined in the URL are applied to the given portlet.
 
The state tag has the following attributes:
  • url = ”<context>/<portlet-name>” Identifies the portlet for this tag by using the context and portlet-name to address the portlet. This attribute is required.
  • windowId = ”<any string>” Defines the window ID for the portlet URL created by this tag. This is attribute optional.
  • var = ”<any string>” If defined the URL is written into a variable with the given scope and name, not to the output stream. This is attribute optional.
  • scope = ”page|request|session|application” This attribute is only valid if the var attribute is specified. If defined, the URL is not written to the output stream but a variable is created in the given scope with the given name. The default is page. This is attribute optional.
  • portletMode = ”view|help|edit|<custom>” This attribute sets the portlet mode.
  • portletWindowState = ”maximized|minimized|normal|<custom>” This attribute sets the window state.
  • action = ”true/false”
    This attribute defines whether this is an action URL. This is attribute optional. The default is false.
 
urlParam
 
Adds a render parameter to the newly created URL.
 
The urlParam tag has the following attributes:
  • name = ”<any string>”Indicates the name of the parameter. This is attribute required.
  • value = ”<any string>” Indicates the value of the parameter. This is attribute required.
insert
 
This tag calls the render method of the portlet and retrieves the content as well as the title. You can optionally place the content and title of the specified portlet into variables using the contentVar and titleVar attributes.
 
The insert tag has the following attributes:
  • url = ”<context>/<portlet-name>” (mandatory) Identifies the portlet for this tag by using the context and portlet-name to address the portletThis is attribute required.
  • windowId = ”<any string>” Defines the window ID of the portlet. This is attribute optional.
  • contentVar = ”<any string>” If defined, the portlet's content is not written to the output stream but written into a variable with the given scope and name. This is attribute optional.
  • contentScope = ”page|request|session|application” This attribute is only valid if the contentVar tag is used. If defined, the portlet's content is written into a variable with the given scope and name, not to the output stream. The default is page. This is attribute optional.
  • titleVar = ”<any string>” If defined the portlet's title is written into a variable with the given scope and name. If it is not defined, the title is ignored and not written to the output stream. This is attribute optional.
  • titleScope = ”page|request|session|application”
    This attribute is only valid if titleVar tag is used. If defined, the portlet's title is written into a variable with the given scope and name, not to the output stream. The default is page. This is attribute optional.


No comments:

Post a Comment