Portlet Modes

A portlet mode indicates the function a portlet is performing in the render method. The Portlet Specification defines three portlet modes, VIEW, EDIT, and HELP.

VIEW Mode – The expected functionality for a portlet in VIEW portlet mode is to generate markup reflecting the current state of the portlet. Portlet developers should implement the VIEW portlet mode functionality by overriding 20 the doView method of the GenericPortlet class. It is mandatory for a portlet to support this mode.

EDIT Mode – Within the EDIT portlet mode, a portlet should provide content and logic that lets a user customize the behavior of the portlet. Typically, portlets in EDIT portlet mode will set or update portlet preferences. Portlet developers should implement the EDIT portlet mode functionality by overriding the doEdit method of the GenericPortlet class.

HELP Mode – When in HELP portlet mode, a portlet should provide help information about the portlet. Portlet developers should implement the HELP portlet mode functionality by overriding the doHelp method of the GenericPortlet class.

Some vendors have added there own modes. WebSphere Portal uses two special custom modes from the set of predefined custom modes in the Java Portlet Specification to allow setting up the more general preference levels:

  • The EDIT_DEFAULTS custom portlet mode is used to work directly on the shared preferences. In this case the personalized preferences level is not available.
  • Similarly, the CONFIG mode is used to read and modify the administrator level of preferences.

Sample Application with all three modes:

Create Portlet Project > In the wizard select help/edit modes (you can add them later also. RAD automatically adds xhtml respective for each mode. Following is the Portlet.xml

PortletModeXML

Note that the page for a particular mode can also be decided from the modes respective reder methods aFor testing purpose I am not writing anything in the respective doView,doEdit, doHelp mode.

Deploy on server.

Important – The default skin applied is usually hidden, because of which only the view mode would be visible. Change the skin of the portlet to standard for full view.

PortletModeStandardSkin

PortletModeDisplay

 

Clicking on Personalize will open portlet in edit mode.

Clicking help will pop up a window with help page.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: