JBoss.orgCommunity Documentation

JBoss Portlet Bridge Reference Guide

1. JBoss Portlet Bridge Overview
2. Getting started with JBoss Portlet Bridge
2.1. What's New in 2.0?
2.1.1. Eventing
2.1.2. Portlet Served Resources
2.1.3. Public Render Parameters
2.2. Bridge Frameworks and Extensions
2.2.1. Seam Bridgelets
2.2.2. RichFaces Bridgelets
2.3. Before you start
2.4. Maven Archetypes
2.5. Video Tutorials
3. Bridge Configuration
3.1. Core Setup and Configuration
3.1.1. portlet.xml
3.1.2. faces-config.xml
3.1.3. Facelets Configuration
3.1.4. JSP Only Configuration
3.1.5. JSR-329
3.2. RichFaces Setup and Configuration Options
3.2.1. web.xml
3.3. Seam Setup and Configuration Options
3.3.1. Configuration
3.4. Portlet 2.0 Coordination
3.4.1. Sending and Receiving Events
3.4.2. Public Render Parameters
3.4.3. Serving Your JSF Resources in a Portlet
3.5. Additional Options
3.5.1. WindowState Saving
3.5.2. Restoring ViewId
4. Developing Portlets with the Bridge
4.1. Excluding Attributes from the Bridge Request Scope
4.2. Supporting PortletMode Changes
4.3. Navigating to a mode's last viewId
4.4. General Error Handling
4.5. Custom Ajax Error Handling
4.6. Communication Between Your Portlets
4.6.1. Storing Components in PortletSession.APPLICATION_SCOPE
4.6.2. Using the PortletSession
4.7. Linking to Portlet/JSF Pages Using h:outputink
4.8. Redirecting to an External Page or Resource
4.9. Using Provided EL Variables
4.10. Remote Portlet Navigation Using Portlet Events

To get an idea of the JBoss Portlet Bridge community, the developers, and for wiki information, checkout the project page.

What is the JBoss Portlet Bridge?

The JBoss Portlet Bridge (or JBPB for short) is a final implementation of the JSR-329 specification which supports the JSF 1.2 runtime within a JSR 286 portlet and with added enhancements to support other web frameworks (such as Seam and RichFaces). It allows any Java developer to get started quickly with their JSF web application running in a portal environment. The developer no longer needs to worry about the underlying portlet development, portlet concepts, or the API.

Understanding how JSF works with Portal

The portlet bridge isn't a portlet. It's the mediator between the two environments and allows JSF and Portal to be completely unaware of each other. The bridge is used to execute Faces requests on behalf of the portlet. During each request, the Faces environment is setup and handled by the bridge. Part of this implementation acts as a Faces controller much as the FacesServlet does in the direct client request world. The other part of this implementation is provided by implementating a variety of (standard) Faces extensions.

JBoss Portlet Bridge not only gives you the ability to run JSF web applications in a portlet, but also gives you the benefit of running supported JBoss frameworks like Seam and RichFaces.

Current version and compatibilty information can be easily located here. Ensure you are using compatible versions of all integrated frameworks before you begin.

GateIn provides it's latest distribution included in JBoss Application Server. All of the guesswork has been eliminated so that you can unzip and run the Portal with a few clicks. Get the latest here (ensure you choose the Portal + JBoss AS link)

Next, all that's left is to download the JBoss Portlet Bridge distribution and cofigure your portlet to use the bridge. Or, you can run a provided archetype Section 2.4, “Maven Archetypes” and deploy the generated war in a few easy steps. This will also give you an empty project to play around with or start from scratch.

The 329 specification is aimed at making the developers life as easy as possible with JSF+Portlet development. You will see below that there are minimal settings to getting any JSF web application up and running in the Portal environment.

If you are starting from scratch, we highly recommend you use the Section 2.4, “Maven Archetypes”.

The following configuration is designated for portlets using the RichFaces library in GateIn. These settings will vary based on your individual needs. See this section of the RichFaces documentation for more details.



If you use the "NONE" strategy, you must include the following scripts in your portlet or portal page header.

The org.ajax4jsf.RESOURCE_URI_PREFIX configuration cross references the path to your scripts below. These settings are required for RichFaces using the "NONE" strategy.

    <script src="/faces/rfRes/org/ajax4jsf/framework.pack.js" type="text/javascript"></script>
    <script src="/faces/rfRes/org/richfaces/ui.pack.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="/faces/rfRes/org/richfaces/skin.xcss"/>

Seam automatically configures your Ajax4JSF Filter, so if you are running a Seam portlet, you do not need the following Filter config. (But you do need the RESOURCE_URI_PREFIX no matter what)


                <display-name>Ajax4jsf Filter</display-name>


One very important thing to note before using either of the following mechanisms, is that you must have the proper 2.0 schema and xsd definition at the top of your portlet.xml.

    <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"

Just like with any portlet 2.0 event consumer and receiver, you must define them in the portlet.xml. To see a working example, checkout the Seam Booking Demo portlet. http://anonsvn.jboss.org/repos/portletbridge/tags/2.3.0.Final/examples/seam/booking/

You must also define the following init params in your portlet.xml.


For now, you must dipatch the event in the JSF or Seam backing bean. Future versions on the 2.0 bridge will automate the dispatching and consuming of events.

   if (response instanceof StateAwareResponse) {
        StateAwareResponse stateResponse = (StateAwareResponse) response;
        stateResponse.setEvent(Foo.QNAME, new Bar());

Then you must also create the event handler class by implementing the BridgeEventHandler interface to process the event payload.

   public class BookingEventHandler implements BridgeEventHandler
       public EventNavigationResult handleEvent(FacesContext context, Event event)
            //process event payload here


Public Render Parameters (or PRPs) are one of the most powerful and simple Portlet 2.0 features. Several portlets (JSF or not) can share the same render parameters. This feature can be use to present a cohesive UI to the user across all portlets on the page (i.e. using an employee ID to display relative data).

The bridge maps a render parameter to a backing bean using settings in your faces-config.xml and portlet.xml. A clear and working example can be found in the Seam Booking Demo portlet. http://anonsvn.jboss.org/repos/portletbridge/tags/2.3.0.Final/examples/seam/booking/

You must define the following init params in your portlet.xml.


Create a managed bean and public-parameter-mappings in your faces-config.xml. This should be a basic bean that you can bind the passed parameter to a string with getter and setter.


                <parameter>"the name of your portlet":hotelName</parameter>

You must set the parameter in the JSF or Seam backing bean, if you are providing one from your portlet.

   if (response instanceof StateAwareResponse) {
        StateAwareResponse stateResponse = (StateAwareResponse) response;

Then you must also implement the BridgePublicRenderParameterHandler interface to process any updates from the received parameter.

   public void processUpdates(FacesContext context)
      ELContext elContext = context.getELContext();
      BookingPRPBean bean = (BookingPRPBean) elContext.getELResolver().getValue(elContext, null, "bookingPRP");

    if(null != bean){
       //Do something with bean.getHotelName());
    } else {


We have setup a few examples to show you how to use EL and a simple bean that will allow you to use the portlet resource serving mechanism within a JSF portlet.

In ResourceBean.java, you can see a very simple implementations of a Map object that uses the bridge to get and encode a resource url served from the portlets web application.

So, when you have the normal "/images", "/styles" and other resource folders in your web app, you can use the following EL expression to serve them in your JSF application.


Just copy the ResourceBean.java code above, and add an entry to you faces-config.xml for the bean:


This chapter demonstrates common development tasks described by the 329 specification.

By default a mode change will start in the mode's default view without any (prior) existing state. One common portlet pattern when returning to the mode one left after entering another mode (e.g.. view -> edit -> view) is to return to the last view (and state) of this origin mode. The bridge will explicitly encode the necessary information so that when returning to a prior mode it can target the appropriate view and restore the appropriate state. The session attributes maintained by the bridge are intended to be used by developers to navigate back from a mode to the last location and state of a prior mode. As such a developer needs to describe a dynamic navigation: "from view X return to the last view of mode y". This is most easily expressed via an EL expression. E.g.


expression returns a viewId of the form


Without wildcarding, when a subsequent navigation occurs from this new view, the navigation rules wouldn't resolve because there wouldn't be an exact match. Likewise, the above edit.jspx


is wildcarded because there are navigation rules that target it that use a query string:

<to-view-id> /edit.jspx?javax.portlet.faces.PortletMode=edit </to-view-id>

Developers are encouraged to use such wildcarding to ensure they execute properly in the broadest set of bridge implementations.

There are roughly 4 different ways to send messages, events, and parameters between portlets which are contained in different ears/wars or contained in the same war. The Portlet Container does not care if you have 2 portlets in the same war or if they are separated, because each portlet has a different HttpSession.

Of course, with the Portlet 2.0 spec, the recommended way to share a parameter or event payload between 2 or more portlets are the Section 3.4.2, “Public Render Parameters” and Section 3.4.1, “Sending and Receiving Events” mechanisms. This allows you to decouple your application from surgically managing objects in the PortletSession.APPLICATION_SCOPE.

But, if these do not meet your usecase or you have a different strategy, you can use one of the following methods.

When you send events using the method described here Section 3.4.1, “Sending and Receiving Events”, you can also leverage the EventNavigationResult and return a JSF navigation rule. For Example, by returning a

new EventNavigationResult("fromAction","Outcome"); 

the fromAction can be a catch all like "/*" or a nav rule defined in your faces-config.xml and outcome can be the from-outcome node defined in the faces-config.xml navigation rule.