Sunday, February 7, 2010

JSR 168 Portlet Guidelines

Use locale specific Resource Bundle files for displaying captions on the JSP page.
To display Error message use their Locale specific methods.
Use PortletPreference object for storing personalization related data.
Use PortletSession with Portlet Scope for managing beans.
JSR-168 supports only expiration based caching , which is by default set to 0 , change it according to your need.
For static contents portlet set it to –1 .
Try to finish all portlet functionality in default modes only [view, Edit, Help] .
Donot use instance variable on Portlet Level, they might posses unpredictable behavior.
Always pass the data using beans.
Always maintain version numbers for your code.
If on certain actions, processing is not required then make those URLs RenderURL not ActionURL.
Do not use any of the following Tag while writing JSPs , because your JSP page is rendered inside a tag only.
i. html /html
ii. head /head
iii. body /body
If using tables in JSPs then donot make them of Fixed width, use width in Percentage [%]
On the JSP page, do not use HTML style of commenting [] , always comment in scriptlets [<% %>] because all HTML comment get transferred directly to the browser.
Do not use inline stylesheet in JSP, because the stylesheet is taken care by portal administrator.
Try to avoid complex javascript on JSP page, if required then they must be prefixed with Tag.
All shared Jar files or Resources must be kept inside the shared directory on server.
Put all the portlet in same web archive, which shares session on application scope.
Update portlet preference data inside processAction method only.
Always keep the portletSession timeout as portal timeout.
Do not use thread inside portlet class.
Try to put all Domain related portlet into single archive.
Use JSP for displaying tabular data instead of XML/XSLT whenever possible, because they need to be parsed on every request, where JSP is compiled into servlet and behave faster.
Use Taglibs wherever it is possible.