Chapter 28. Portlet Bridge
- 28.1. JBoss Portlet Bridge
- 28.2. Portlet application
- 28.3. Extensions
- 28.4. Examples
- 28.5. Render Policy Parameters
- 28.6. Facelets Configuration
- 28.7. JSP-only Configuration
- 28.8. RichFaces Local and Remote Portlet Support
- 28.9. Sending and Receiving Events
- 28.10. Sending Events
- 28.11. Receiving Events
- 28.12. Public Render Parameters
- 28.13. Saving Bridge Request Scope after Render complete
- 28.14. PRP portlet configuration
- 28.15. Application configuration
- 28.16. Portlet Session
- 28.17. Resource serving
- 28.18. Serving JSF Resources in a Portlet
- 28.19. Expression Language Reference
- 28.20. Expression Language Configuration
- 28.21. Developing Portlets with the Bridge
- 28.21.1. Implementing Portlet Bridge
- 28.21.2. Declaring Artifact Dependencies
- 28.21.3. Declaring Depchain Dependencies
- 28.21.4. Deploying Portlet Bridge Portlets
- 28.21.5. Disable Automatic Portlet Bridge Injection
- 28.21.6. Supported Portlet Tags
- 28.21.7. Excluding Attributes from the Bridge Request Scope
- 28.21.8. Prevent Resources Being Added to Portal Page Head
- 28.21.9. JSF Facelet View
- 28.21.10. Error Handling
- 28.21.11. Switching Portlet Modes
- 28.21.12. Navigating to a mode's last viewId
- 28.21.13. Using Wildcards to Identify the Rule Target
- 28.21.14. Clearing the View History when Changing Portlet Modes
- 28.21.15. Communication Between Portlets
- 28.21.16. Storing Components in PortletSession.APPLICATION_SCOPE
- 28.21.17. Using the PortletSession
- 28.21.18. Linking to a Facelets page within the Same Portlet
- 28.21.19. Redirecting to an External Page or Resource
- 28.21.20. Using Provided EL Variables
28.1. JBoss Portlet Bridge
Faces requests on behalf of the portlet. During each request, the Faces environment is setup and handled by the bridge.
Faces controller, much like the FacesServlet does in the direct client request environment.
Faces extensions.
28.2. Portlet application
28.3. Extensions
28.4. Examples
Important
- JSF2 Portlet
- This example provides a basic JSF2 portlet demonstrating Ajax functionality. This example provides a solid foundation for basic JSF2 functionality.
- RichFaces 4 Simple
- This example demonstrates a simple RichFaces 4 form with ajax submission and an extended data table showing the submitted data. This example provides a solid foundation for basic RichFaces 4 functionality.
- RichFaces 4 Showcase
- This example demonstrates a RichFaces 4 application, with portlet-specific changes. This example is worth deploying for advanced RichFaces 4 functionality, and shows the full spectrum of what can be achieved with RichFaces 4 and Portlet Bridge
28.5. Render Policy Parameters
web.xml.
RenderPolicy Options
- 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. If an exception is thrown, the bridge renders 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 as it would if DEFAULT was set.
28.6. Facelets Configuration
web.xml setting is only for Facelets based applications.
Example 28.1. Facelets web.xml Configuration
<context-param> <param-name>javax.portlet.faces.RENDER_POLICY</param-name> <param-value>ALWAYS_DELEGATE</param-value> </context-param>
28.7. JSP-only Configuration
web.xml setting is only for JSP based applications. Download the demonstration application here.
Example 28.2. web.xml
<context-param> <param-name>javax.portlet.faces.RENDER_POLICY</param-name> <param-value>NEVER_DELEGATE</param-value> </context-param>
28.8. RichFaces Local and Remote Portlet Support
Table 28.1. RichFaces Feature Support Exceptions
| RichFaces Component | Local Portlet | Remote Portlet using WSRP | Additional Comments |
|---|---|---|---|
rich:editor | Yes | Yes | Some issues with editor icons over WSRP may be encountered when the Consumer and Producer are on different servers because the URLs are relative and are generated through JavaScript |
rich:focus | Yes | Untested | Available since RichFaces 4.3.0.M3 |
rich:placeholder | Yes | Untested | Available since RichFaces 4.3.0.M3 |
a4j:push | Yes | No | Not supported for WSRP in Red Hat JBoss Portal Platform 6.2 |
Table 28.2. RichFaces Feature Status
| RichFaces Component | Supported as Local Portlet | Supported as Remote Portlet using WSRP |
|---|---|---|
a4j:actionListener | Yes | Yes |
a4j:ajax | Yes | Yes |
a4j:attachQueue | Yes | Yes |
a4j:commandButton | Yes | Yes |
a4j:commandLink | Yes | Yes |
a4j:jsFunction | Yes | Yes |
a4j:log | Yes | Yes |
a4j:mediaOutput | Yes | Yes |
a4j:outputPanel | Yes | Yes |
a4j:param | Yes | Yes |
a4j:poll | Yes | Yes |
a4j:queue | Yes | Yes |
a4j:region | Yes | Yes |
a4j:repeat | Yes | Yes |
a4j:status | Yes | Yes |
rich:accordion | Yes | Yes |
rich:accordionItem | Yes | Yes |
rich:autocomplete | Yes | Yes |
rich:calendar | Yes | Yes |
rich:collapsiblePanel | Yes | Yes |
rich:collapsibleSubTable | Yes | Yes |
rich:collapsibleSubTableToggler | Yes | Yes |
rich:column | Yes | Yes |
rich:columnGroup | Yes | Yes |
rich:componentControl | Yes | Yes |
rich:contextMenu | Yes | Yes |
rich:dataGrid | Yes | Yes |
rich:dataTable | Yes | Yes |
rich:dragIndicator | Yes | Yes |
rich:dragSource | Yes | Yes |
rich:dropDownMenu | Yes | Yes |
rich:dataScroller | Yes | Yes |
rich:dropTarget | Yes | Yes |
rich:editor | Yes | Yes |
rich:extendedDataTable | Yes | Yes |
rich:fileUpload | Yes | Yes |
rich:focus | Yes | Untested |
rich:graphValidator | Yes | Yes |
rich:hashParam | Yes | Yes |
rich:hotKey | Yes | Yes |
rich:inplaceInput | Yes | Yes |
rich:inplaceSelect | Yes | Yes |
rich:inputNumberSlider | Yes | Yes |
rich:inputNumberSpinner | Yes | Yes |
rich:jQuery | Yes | Yes |
rich:list | Yes | Yes |
rich:menuGroup | Yes | Yes |
rich:menuItem | Yes | Yes |
rich:menuSeparator | Yes | Yes |
rich:message | Yes | Yes |
rich:messages | Yes | Yes |
rich:notify | Yes | Yes |
rich:notifyMessage | Yes | No |
rich:notifyMessages | Yes | Yes |
rich:notifyStack | Yes | Yes |
rich:orderingList | Yes | Yes |
rich:panel | Yes | Yes |
rich:panelMenu | Yes | Yes |
rich:panelMenuGroup | Yes | Yes |
rich:panelMenuItem | Yes | Yes |
rich:inputNumberSlider | Yes | Yes |
rich:pickList | Yes | Yes |
rich:placeholder | Yes | Untested |
rich:popupPanel | Yes | Yes |
rich:progressBar | Yes | Yes |
rich:select | Yes | Yes |
rich:tab | Yes | Yes |
rich:tabPanel | Yes | Yes |
rich:toggleControl | Yes | Yes |
rich:togglePanel | Yes | Yes |
rich:togglePanelItem | Yes | Yes |
rich:toolbar | Yes | Yes |
rich:toolbarGroup | Yes | Yes |
rich:tooltip | Yes | Yes |
rich:tree | Yes | Yes |
rich:treeModelAdaptor | Yes | Yes |
rich:treeModelRecursiveAdaptor | Yes | Yes |
rich:treeNode | Yes | Yes |
rich:validator | Yes | Yes |
28.9. Sending and Receiving Events
28.10. Sending Events
Procedure 28.1. Sending Events
- Define the autoDispatchEvents <init-param> in
portlet.xmlto specify the GenericFacesPortlet should override event handling and dispatch all events to the bridge.Important
If the application is written entirely in JSF (as opposed to a mix of view technologies), this <init-param> must be set totrue.<init-param> <name>javax.portlet.faces.autoDispatchEvents</name> <value>true</value> </init-param>
- Define the <supported-publishing-event> in
portlet.xmlto enable the portlet to publish an event to the portal.<supported-publishing-event> <qname xmlns:jbp="urn:jboss:portal:samples:event">jbp:BookingEvent</qname> </supported-publishing-event>
- Define the <event-definition> directive in
portlet.xmlto specify how the event namespace (<qname>) is linked to an actual type within the application.<event-definition> <qname xmlns:jbp="urn:jboss:portal:samples:event">jbp:BookingEvent</qname> <value-type>org.jboss.example.booking.BookingEvent</value-type> </event-definition>
Example 28.3. Event type example
@XmlRootElement public class BookingEvent implements Serializable { private String id; public static final QName QNAME = new QName("urn:jboss:portal:samples:event", "BookingEvent"); public BookingEvent(String id) { this.id = id; } public String getId() { return id; } }
Example 28.4. Dispatch event example
Object response = FacesContext.getCurrentInstance().getExternalContext().getResponse(); if (response instanceof StateAwareResponse) { String id = "an id"; StateAwareResponse stateResponse = (StateAwareResponse) response; stateResponse.setEvent(BookingEvent.QNAME, new BookingEvent(id)); }
28.11. Receiving Events
Procedure 28.2.
- Define the bridgeEventHandler <init-param> directive in
portlet.xmlto specify the portlet can receive an event from Portlet Bridge.<init-param> <name>javax.portlet.faces.bridgeEventHandler</name> <value>org.jboss.example.booking.BookingEventHandler</value> </init-param>
- Define the <supported-processing-event> directive in
portal.xmlto specify the portlet can also receive an event from the portal.<supported-processing-event> <qname xmlns:jbp="urn:jboss:portal:samples:event">jbp:BookingEvent</qname> </supported-processing-event>
- Define the <event-definition> directive in the portlet that will be receiving the event.
<event-definition> <qname xmlns:jbp="urn:jboss:portal:samples:event">jbp:BookingEvent</qname> <value-type>org.jboss.example.booking.BookingEvent</value-type> </event-definition>
public class BookingEventHandler implements BridgeEventHandler {
public EventNavigationResult handleEvent(FacesContext context, Event event) {
// Process event payload as appropriate
}
}28.12. Public Render Parameters
get/set method) designed to handle a String representation of the value through a Faces ValueExpression.
ValueExpression's setValue().
faces-config.xml and portlet.xml files.
28.13. Saving Bridge Request Scope after Render complete
<init-param> <name>org.jboss.portletbridge.BRIDGE_SCOPE_PRESERVED_POST_RENDER</name> <value>true</value> </init-param>
<context-param> <param-name>org.jboss.portletbridge.BRIDGE_SCOPE_PRESERVED_POST_RENDER</param-name> <param-value>true</param-value> </context-param>
28.14. PRP portlet configuration
<portlet> <!-- Unnecessary configuration information removed for clarity --> <supported-public-render-parameter>hotelName</supported-public-render-parameter> </portlet> <public-render-parameter> <identifier>hotelName</identifier> <qname xmlns:j="http://jboss.org/params">j:hotelName</qname> </public-render-parameter>
<init-param> <name>javax.portlet.faces.bridgePublicRenderParameterHandler</name> <value>org.jboss.example.booking.BookingPRPHandler</value> </init-param>
28.15. Application configuration
Example 28.5. Set Parameter
Object response = FacesContext.getCurrentInstance().getExternalContext().getResponse(); if (response instanceof StateAwareResponse) { StateAwareResponse stateResponse = (StateAwareResponse) response; stateResponse.setRenderParameter("hotelName", "Name of Hotel"); }
Example 28.6. Retrieve parameter
public class BookingPRP { private String hotelName; public String getHotelName() { return hotelName; } public void setHotelName(String hotelName) { this.hotelName = hotelName; } }
faces-config.xml.
<application>
<application-extension>
<bridge:public-parameter-mappings>
<bridge:public-parameter-mapping>
<parameter>[bookingMapPortlet]:[hotelName]</parameter>
<model-el>#{bookingPRP.hotelName}</model-el>
</bridge:public-parameter-mapping>
</bridge:public-parameter-mappings>
</application-extension>
</application>Important
- [bookingMapPortlet]
- The arbitrary name of the portlet, as set in
portlet.xml - [hotelName]
- The arbitrary name of the render parameter.
portlet.xml requires a bean to process the updates to the model, as a result of the Public Render Parameter.
public class BookingPRPHandler implements BridgePublicRenderParameterHandler { public void processUpdates(FacesContext context) { ELContext elContext = context.getELContext(); BookingPRPBean bean = (BookingPRPBean) elContext.getELResolver().getValue(elContext, null, "bookingPRP"); if(null != bean) { System.out.println("******processUpdates from BookingPRPHandler: " + bean.getHotelName()); } } }
28.16. Portlet Session
Object objSession = FacesContext.getCurrentInstance().getExternalContext().getSession(false); try { if (objSession instanceof PortletSession) { PortletSession portalSession = (PortletSession)objSession; portalSession.setAttribute("your parameter name", "parameter value", PortletSession.APPLICATION_SCOPE); } }
#{httpSessionScope['your parameter name']}28.17. Resource serving
/ resources directory. This placement allows the resource to be retrieved using JSF2 resource handling.
#{resource['/stylesheet.css']}Important
@import to retrieve content within CSS files.
/resources directory, because it does not specify a resource library. For resources that do specify a library, these must be placed in the library sub-directory.
28.18. Serving JSF Resources in a Portlet
- If the request is for a non-JSF resource, the bridge handles the request by acquiring a request dispatcher and forwarding the request to the named resource.
- If the request is for a JSF resource, the bridge runs the full JSF life cycle ensuring that data is processed and the resource (markup) is rendered.
28.19. Expression Language Reference
EL and a simple bean are provided in the ResourceBean.java file of the Richfaces Portlet example.
package org.richfaces.demo.common; import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.Set; import javax.faces.bean.ManagedBean; import javax.faces.context.ExternalContext; import javax.faces.context.FacesContext; import javax.portlet.MimeResponse; import javax.portlet.ResourceURL; /** * @author <a href="http://community.jboss.org/people/kenfinni">Ken Finnigan</a> */ @ManagedBean(name = "portletRes") public class PortletResource implements Map<String, String> { @Override public void clear() { } @Override public boolean containsKey(Object arg0) { return true; } @Override public boolean containsValue(Object arg0) { return true; } @Override public Set<java.util.Map.Entry<String, String>> entrySet() { return Collections.emptySet(); } @Override public String get(Object resourceKey) { FacesContext context = FacesContext.getCurrentInstance(); String resourceUrl = null; if (null != resourceKey) { ExternalContext extCon = context.getExternalContext(); MimeResponse response = (MimeResponse) extCon.getResponse(); ResourceURL resUrl = response.createResourceURL(); resUrl.setResourceID(resourceKey.toString()); resourceUrl = resUrl.toString(); } return resourceUrl; } @Override public boolean isEmpty() { return false; } @Override public Set<String> keySet() { return Collections.emptySet(); } @Override public String put(String arg0, String arg1) { return null; } @Override public void putAll(Map<? extends String, ? extends String> arg0) { } @Override public String remove(Object arg0) { return null; } @Override public int size() { return 0; } @Override public Collection<String> values() { return Collections.emptySet(); } }
28.20. Expression Language Configuration
/images", "/styles" and other resource folders in your web application, you can use the following EL expression to serve them in your JSF application.
#{resource['/img/the-path-to-my-image.png']}
ResourceBean.java code described in Section 28.19, “Expression Language Reference”, and add an entry to the faces-config.xml for the bean.
<managed-bean> <managed-bean-name>resource</managed-bean-name> <managed-bean-class>org.richfaces.demo.common.ResourceBean</managed-bean-class> <managed-bean-scope>application</managed-bean-scope> </managed-bean>
28.21. Developing Portlets with the Bridge
28.21.1. Implementing Portlet Bridge
28.21.2. Declaring Artifact Dependencies
Procedure 28.3. Artifact Dependencies
- Add the following
pom.xmldependencies to inherit the correct JSF2 artifacts.<dependency> <groupId>org.jboss.portletbridge</groupId> <artifactId>portletbridge-api</artifactId> <version>3.1.2.Final</version> </dependency> <dependency> <groupId>org.jboss.portletbridge</groupId> <artifactId>portletbridge-impl</artifactId> <version>3.1.2.Final</version> <scope>runtime</scope> </dependency>
- For RichFaces 4 portlets, add the following additional dependency to inherit the additional RichFaces dependencies.
<dependency> <groupId>org.jboss.portletbridge</groupId> <artifactId>portletbridge-extension-richfaces</artifactId> <version>3.1.2.Final</version> <scope>runtime</scope> </dependency>
28.21.3. Declaring Depchain Dependencies
pom.xml configuration to a single dependency, using the Portlet Bridge Depchain pom.xml configuration.
Procedure 28.4. JSF2 Depchain Dependencies
- Add the following dependencies to inherit the correct artifacts using the
pom.xmlDepchain.<dependency> <groupId>org.jboss.portletbridge</groupId> <artifactId>jsf2-depchain</artifactId> <version>3.1.2.Final</version> <type>pom</type> </dependency>
- For RichFaces 4 portlets, add the following additional dependency to inherit the correct artifacts using the
pom.xmlDepchain.<dependency> <groupId>org.jboss.portletbridge</groupId> <artifactId>jsf2-depchain</artifactId> <version>3.1.2.Final</version> <type>pom</type> </dependency> <dependency> <groupId>org.jboss.portletbridge</groupId> <artifactId>richfaces4-depchain</artifactId> <version>3.1.2.Final</version> <type>pom</type> </dependency>
28.21.4. Deploying Portlet Bridge Portlets
Procedure 28.5. Setting the Provided Scope for JSF2 and RichFaces Portlets that use Portlet Bridge API
- Add the following
pom.xmldependencies to declare the JSF2 provided scope.<dependency> <groupId>org.jboss.portletbridge</groupId> <artifactId>portletbridge-api</artifactId> <version>3.1.2.Final</version> <scope>provided</scope> </dependency>
- For RichFaces 4 portlets, add the following additional dependency to declare the RichFaces 4 runtime scope.
Note
The RichFaces 4 extension is not included in the portal by default.<dependency> <groupId>org.jboss.portletbridge</groupId> <artifactId>portletbridge-extension-richfaces</artifactId> <version>portletbridge-extension-richfaces-[VERSION]</version> <scope>runtime</scope> </dependency>
Where [VERSION] is theportletbridge-extension-richfacesversion in$JPP_HOME/modules/org/jboss/portletbridge/api/main
28.21.5. Disable Automatic Portlet Bridge Injection
Procedure 28.6. Disabling automatic Portlet Bridge injection
- Add the following
web.xmldependency to prevent injecting the packaged Portlet Bridge implementation into a portlet application.Note
If a portlet application specifies either WAR_BUNDLES_JSF or JSF_CONFIG_NAME context parameters in theweb.xml, Portlet Bridge will not be automatically injected. <context-param> <param-name>org.gatein.portletbridge.WAR_BUNDLES_PORTLETBRIDGE</param-name> <param-value>true</param-value> </context-param>
28.21.6. Supported Portlet Tags
- actionURL
- renderURL
- resourceURL
- namespace
- param
- property
xmlns:pbr="http://jboss.org/portletbridge"
Example 28.7. renderURL example
<pbr:renderURL var="renderUrl" portletMode="edit"> </pbr:renderURL> <h:outputLink value="#{renderUrl}">Edit Mode</h:outputLink>
Example 28.8. namespace example
<script type='text/javascript'> function <pbr:namespace />DoSomething() { } </script>
28.21.7. Excluding Attributes from the Bridge Request Scope
faces-config.xml.
foo.bar, or any attribute beginning with foo.baz.(wild-card) will be excluded from the bridge request scope and only be used for that application's request.
[<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>
28.21.8. Prevent Resources Being Added to Portal Page Head
web.xml file.
<context-param> <param-name>org.jboss.portletbridge.markupHead.enabled</param-name> <param-value>false</param-value> </context-param>
28.21.9. JSF Facelet View
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "> <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" > <!-- Unnecessary content removed for clarity --> </html>
<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" > <!-- Unnecessary content removed for clarity --> </f:view>
Note
28.21.10. Error Handling
web.xml file.
<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>
/error, /error.jsf or /error.xhtml.
Note
28.21.11. Switching Portlet Modes
PortletMode represents a distinct render path within an application. There are three standard modes: view, edit, and help.
ExternalContext.encodeActionURL recognizes the query string parameter javax.portlet.faces.PortletMode and uses this parameter's value to set the portlet mode on the underlying portlet actionURL or response. Once processed it then removes this parameter from the query string.
Example 28.9. /edit.xhtml navigation rule
/edit.xhtml viewId in the portlet edit mode.
<navigation-rule> <from-view-id>/register.xhtml</from-view-id> <navigation-case> <from-outcome>edit</from-outcome> <to-view-id>/edit.xhtml?javax.portlet.faces.PortletMode=edit</to-view-id> </navigation-case> </navigation-rule>
28.21.12. Navigating to a mode's last viewId
X return to the last view of mode Y".
EL expression. For example:
Example 28.10. /register.xhtml viewId navigation rule
/edit.xhtml viewId in the portlet edit mode.
<navigation-rule> <from-view-id>/edit.xhtml*</from-view-id> <navigation-case> <from-outcome>view</from-outcome> <to-view-id>#{sessionScope['javax.portlet.faces.viewIdHistory.view']}</to-view-id> </navigation-case> </navigation-rule>
28.21.13. Using Wildcards to Identify the Rule Target
viewId of the form
/viewId?javax.portlet.faces.PortletMode=view&....
edit.jspx<from-view-id> is wild-carded 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>
28.21.14. Clearing the View History when Changing Portlet Modes
portlet.xml to use the default viewId each time you switch modes.
<init-param> <name>javax.portlet.faces.extension.resetModeViewId</name> <value>true</value> </init-param>
28.21.15. Communication Between Portlets
ears/wars or contained in the same war.
war or having them separated does not affect the Portlet Container because each portlet has a different HttpSession.
PortletSession.APPLICATION_SCOPE.
28.21.16. Storing Components in PortletSession.APPLICATION_SCOPE
APPLICATION_SCOPE.
PORTLET_SCOPE but with the annotation below, this class can be pulled out of the PortletSession and its values used in other portlets across different Seam applications.
@PortletScope(PortletScope.ScopeType.APPLICATION_SCOPE)
YourSessionClass yourSessionClass = (YourSessionClass)getRenderRequest().getAttribute("javax.portlet.p./default/seamproject/seamprojectPortletWindow?textHolder");
28.21.17. Using the PortletSession
PortletSession to share a parameter or value across multiple portlets, you can use the following:
Object objSession = FacesContext.getCurrentInstance().getExternalContext().getSession(false); try { if (objSession instanceof PortletSession) { PortletSession portalSession = (PortletSession)objSession; portalSession.setAttribute("your parameter name","parameter value",PortletSession.APPLICATION_SCOPE); ...
#{httpSessionScope['your parameter name']}28.21.18. Linking to a Facelets page within the Same Portlet
<h:outputLink value="#{facesContext.externalContext.requestContextPath}/home.xhtml"> <f:param name="javax.portlet.faces.ViewLink" value="true"/> navigate to the test page </h:outputLink>
28.21.19. Redirecting to an External Page or Resource
<h:commandLink actionListener="#{yourBean.yourListenr}"> <f:param name="javax.portlet.faces.DirectLink" value="true"/> navigate to the test page </h:commandLink>
redirect() must be called.
public class YourBean { public void yourListener() { FacesContext.getCurrentInstance().getExternalContext().redirect("http://www.jboss.org"); } }
28.21.20. Using Provided EL Variables
EL variables found in the JSR-329 (Portlet 2.0) specification are available in the JBoss Portlet Bridge.
Table 28.3.
| portalConfig |
Object of type javax.portlet.PortletConfig
|
| actionRequest |
Object of type
javax.portlet.ActionRequest
(only accessible when processing an ActionRequest)
|
| actionResponse |
Object of type
javax.portlet.ActionResponse
(only accessible when processing an ActionResponse)
|
| eventRequest |
Object of type
javax.portlet.EventRequest
(only accessible when processing an EventRequest)
|
| eventResponse |
Object of type
javax.portlet.EventResponse
(only accessible when processing an EventRequest)
|
| renderRequest |
Object of type
javax.portlet.RenderRequest
(only accessible when processing an RenderResponse)
|
| renderResponse |
Object of type
javax.portlet.RenderResponse
(only accessible when processing an RenderResponse)
|
| resourceRequest |
Object of type
javax.portlet.ResourceRequest
(only accessible when processing an ResourceRequest)
|
| resourceResponse |
Object of type
javax.portlet.ResourceResponse
(only accessible when processing an ResourceResponse)
|
| portletSession |
Current PortletSession object
|
| portletSessionScope |
Map of PortletSession attributes in PORTLET_SCOPE. JSP Expression returns immutable Map, but Faces Expression returns mutable Map.
|
| httpSessionScope |
Mutable Map of PortletSession attributes in APPLICATION_SCOPE
|
| portletPreferences |
Current PortletPreferences object
|
| portletPreferencesValues |
Immutable Map containing entries equivalent to PortletPreferences.getMap()
|
| mutablePortletPreferencesValues |
Mutable Map of type Map<String, javax.portlet.faces.preference.Preference>. This EL variable provides read/write access to each portlet preference.
|
Example 28.11.
<h:form> <h:inputText id="pref" required="true" value="#{mutablePortletPreferencesValues['userName'].value}" /> <h:commandButton actionListener="#{myBean.savePref}" value="Save Preferences" /> </h:form>
Object request = FacesContext.getCurrentInstance().getExternalContext().getRequest(); PortletRequest portletRequest = (PortletRequest)request; if (request instanceof PortletRequest) { try { PortletPreferences portletPreferences = portletRequest.getPreferences(); portletPreferences.store();