JBoss Community Archive (Read Only)

Portlet Bridge 3.3

Tips

Excluding Attributes from Bridge Request Scope

When your application uses request attributes on a per request basis and you do not want that particular attribute to be managed in the Bridge Request Scope, you must use the following configuration in your faces-config.xml to have them excluded.

<application>
  <application-extension>
    <bridge:excluded-attributes>
      <bridge:excluded-attribute>foo.bar</bridge:excluded-attribute>
      <bridge:excluded-attribute>foo.baz.*</bridge:excluded-attribute>
    </bridge:excluded-attributes>
  </application-extension>
</application>

Above you will see that any attribute namespaced as foo.bar or any attribute beginning with foo.baz. will be excluded from the Bridge Request Scope and only be used per that application's request.

In the preceding example, the namespace associated with the "bridge" prefix is "http://jboss.org/portletbridge".

JSF Facelet View

When creating a JSF Facelet view document it's common to wrap the content with:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets">
...
</html>

As a single portlet only reflects a potentially small portion of the HTML markup for a page, a JSF portlet returning the above markup for each portlet can be distracting and potentially problematic.

The recommended way to wrap the content of a JSF Facelet view document for a portlet is:

<f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets">
...
</f:view>

This results in only the relevant content of the portlet markup being returned to the page.

Although it is not relevant to a portlet, it's important to include <h:head> and <h:body> elements so that JSF can process the Facelet correctly.

Error Handling

To display error pages for specific exceptions in your JSF portlet, you need web.xml content such as:

<error-page>
  <exception-type>javax.servlet.ServletException</exception-type>
  <location>/faces/error.xhtml</location>
</error-page>
<error-page>
  <exception-type>javax.faces.application.ViewExpiredException</exception-type>
  <location>/faces/error.xhtml</location>
</error-page>

The above error page definitions are appropriate for a JSF portlet that has a FacesServlet mapping such as /faces/. If the FacesServlet mapping was **.jsf then location would be error, error.jsf or error.xhtml.

There is no requirement when using FacesServlet suffix mapping to append an extension, the name of the view is all that is required for the page to be found

Remember to add a link from any error page to the normal flow of your JSF application otherwise the same error page will be constantly displayed.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-11 12:28:53 UTC, last content change 2012-09-11 15:49:54 UTC.