2.16 Attribute storage summary

 <  Day Day Up  >  

There are many objects in the portal environment for storing attributes. In order to help you choose the right object for the right situation, refer to the following chart.

Object

Scope

Attribute Type

Programmatic Access

Best Practice

PortletRequest

Limited to request between the portal server and the portlet

object

getAttribute() setAttribute() removeAttribute()

Use a short term bucket for communication between portlet and JSP (ex: Portlet URI)

PortletSession

Limited to subsequent requests by the same user on the same concrete portlet instance

object

getAttribute() setAttribute() removeAttribute()

Use as an open line of communication between requests. (for example Shopping cart)

PortletSettings

Shared by all instances of the concrete portlet. Editable only in configure mode.

String

getAttribute() setAttribute() removeAttribute()

Use only for configuration information that is applicable to all instances (for example user ID)

PortletApplicationSettings

Shared by all concrete portlet instances deployed in the same concrete applicationd.itable only in configure mode.

String

getAttribute() setAttribute() removeAttribute()

Use only for configuration information that is applicable to all concrete portlet instances in the same application (for example server name )

PortletData

Persistently available to a single concrete portlet instance.

object(serializable)

getAttribute() setAttribute() removeAttribute()

Use for information that needs life beyond a session (for example portlet preferences)

PortletURI

One request through to the actionPerformed method

String

addParameter()

Use to provide default parameter values in case the user does not enter a value in a form

PortletMessage

Only available to registered message listeners in the event processing phase

Object

Since each custom portlet message can be implemented uniquely, access is not pre-defined

Use to adequately capture all the information necessary to complete the message. There is no predictably regarding order of execution for listeners so do depend on this.

PortletConfig

Same config object is available to every concrete portlet instance derived from the same abstract portlet.

String

getInitParameter()

This vale can only be set during development or deployment. Since its scope is very broad, use carefully .

DefaultPortlet Action

Available as long as the PortletURI it is attached to is available.

object

setParameter()

getParameters()

It is not recommended to store objects such as PortletResponse etc. Use sparingly.

PortletAdapter

Available to all instances of the concrete portlet. Value is not unique between users.

object

getVariable()

setVariable()

Use this object to store attributes that are not unique to any one user, and can be lost if the server shuts down

 <  Day Day Up  >  


IBM WebSphere Portal V5 A Guide for Portlet Application Development
IBM Websphere Portal V5: A Guide for Portlet Application Development
ISBN: 0738498513
EAN: 2147483647
Year: 2004
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net