JBoss Community Archive (Read Only)

Portlet Bridge 3.0

Configuration

Portlet Configuration

Here is an example portlet.xml to configure a JSF2 portlet:

<portlet-class>
  javax.portlet.faces.GenericFacesPortlet
</portlet-class>

<init-param>
  <name>javax.portlet.faces.defaultViewId.view</name>
  <value>/welcome.xhtml</value>
</init-param>

<init-param>
  <name>javax.portlet.faces.defaultViewId.edit</name>
  <value>/jsf/edit.xhtml</value>
</init-param>

<init-param>
  <name>javax.portlet.faces.defaultViewId.help</name>
  <value>/jsf/help.xhtml</value>
</init-param>

Only the javax.portlet.faces.defaultViewId.view init-param is mandatory. The edit and help init-param's are only required when your portlet requires the Edit and Help portlet modes.

Portlet 2.0 Schema

To have access to the latest Portlet 2.0 spec features, such as Events and Public Render Parameters, it's important to ensure that your portlet.xml contains the following schema definition:

<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
  version="2.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">

Preserving Request Parameters outside ActionRequest

By default the JBoss Portlet Bridge does not retain any Request Parameters that were received as part of an ActionRequest from the Portal. To ensure that Request Parameters from an ActionRequest are retained in the Bridge Request Scope until a RenderRequest, add the following init-param to portlet.xml:

<init-param>
  <name>javax.portlet.faces.preserveActionParams</name>
  <value>true</value>
</init-param>

Render Policy

Different JSF View Declaration Languages require different behavior from the JBoss Portlet Bridge when it comes to rendering views. Instructing the Bridge on which policy to use is done using the javax.portlet.faces.RENDER_POLICY context-param in web.xml.

If you're using Facelets:

Include the following in web.xml:

<context-param>
  <param-name>
    javax.portlet.faces.RENDER_POLICY
  </param-name>
  <param-value>
    ALWAYS_DELEGATE
  </param-value>
</context-param>

If you're using JSP:

Include the following in web.xml:

<context-param>
  <param-name>
    javax.portlet.faces.RENDER_POLICY
  </param-name>
  <param-value>
    NEVER_DELEGATE
  </param-value>
</context-param>

Supported Render Policies in JBoss Portlet Bridge:

  • ALWAYS_DELEGATE: Indicates the Bridge should not render the view itself but rather always delegate the rendering.

  • NEVER_DELEGATE: Indicates the Bridge should always render the view itself and never delegate.

  • DEFAULT: Directs the Bridge to first delegate the render and if and only if an Exception is thrown then render the view based on its own logic. If the configuration parameter is not present or has an invalid value the Bridge renders using default behavior. I.e. as if DEFAULT is set.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-11 12:26:01 UTC, last content change 2012-07-31 15:56:41 UTC.