Portal Ajax Integration

From MemberWiki

Jump to: navigation, search

Contents

Upcoming Standardization

JSR-286 and WSRP 2.0

The JCP JSR-286 Expert Group and OASIS WSRP (Web Services for Remote Portlets) Technical Committee are, through shared membership, reaching agreement on a JavaScript API for Portlet requests:

http://www.oasis-open.org/committees/download.php/21243/xpr-wd-07.html

XMLPortletRequest is modeled after XMLHttpRequest and should function as a drop-in replacement once the Portlet-specific URLs are used.

Note that WSRP email archives are available:

http://www.oasis-open.org/committees/wsrp

JSR-301

JSR-301 is actively defining standard and correct behavior for JSF Portlets (including those using Ajax).

Current Practice

getResource

Under WSRP 1.0 and JSR-168, the most common method for using Ajax within Portlets is via getResource. The getResource call is intended for returning images and other static resources associated with a Portlet, but in its re-purposing for Ajax, does not have the stateful qualities expected:

  • Portlet state is not accessible
  • Coordination features are not accessible (Portlet events cannot be sent)

WSRP does not address all of the outstanding issues for Ajax, but a Committee standard extension to WSRP 2.0 is planned.

Portlet/Servlet interaction

Ajax approaches that simultaneously make use of Servlets and Portlets must ensure that the Porlets and Servlets can share state. If the session is used, care must be taken as Portlets introduce an additional scope not present with HttpSession. The PortletSession attributes can be in either APPLICATION_SCOPE (which is directly shared with servlets) and PORTLET_SCOPE (which typically isolates individual portlets from each other with a naming scheme).

Since the JSF API javax.faces.context.ExternalContext.getSessionMap() returns PORTLET_SCOPE attributes in a portlet environment, Portlets are not immediately able to communicate with Servlets through the JSF API alone.