1. If You Know JSF,You Know
Portals and Portlets
By: Wesley Hales
June 1st, 2010
2. @wesleyhales vimeo.com/wesleyhales
• JBoss Portlet Bridge Project Lead
• RedHat’s representative on JSR-301 & 329
• RichFaces contributor & GateIn core dev
• Side projects include: wesleyhales.com,
Firefox Anthem
3. Take Aways
• Understand what a portlet is and does
• Learn how a JSF application maps to the
portlet API
• Best practices for working with multiple JSF
apps within a portal environment
4. Portlets of Yesterday
• “... looking for a strong Portal Developer
with experience”.
• JSP’s with awkward portlet API mapping
• Yet another lifecycle to learn
5.
6. Portlets Just Got Easier
• JSF developers are portlet developers (and
most don’t even know it)
• With a JSF portlet bridge, you’re not
required to learn the underlying portlet
development concepts or APIs.
• But there are a few things that are nice to
know ;)
7. Quick Portlet
Overview
Portlets are...
• Spec driven (168 & 286)
• Rendered markup fragments on a page.
• Different window modes like
edit, help, and view
10. Portals & Portlets
• Portals integrate
services across
organizational boundries.
i.e. - SSO, collaboration and social, etc...
• Portlet windows deliver the data to the
user and can come from various sources -
wars/ears/wsrp.
11. If you really want to
know...
• Servlets vs. Portlets
• Wrapping your head around 2 (or more)
requests.
• Portlets generate a page with multiple
portlet windows that can be rendered
multiple times.
• All links are generated by the portlet api
12. What is a Bridge, and why do we
need one?
• There are many different bridges to handle
different web applications.
• Wicket
• Seam
• Spring MVC
• JSF
• Struts
• PHP
13. Cool Usecases?
• Most larger companies have a need for a
portal
• Multiple teams working in parallel
• Blended content with legacy apps
• Communication between 2+ wars on same
page
• leverage existing investments
14. • Allows JSF 1.2, JSF 2, RichFaces, and Seam
to run as portlets
• Extensions and components
• Backed by a healthy community,
documentation, screencasts, and archetypes
15. Portlet Container
JSF Portlet How the Portlet Bridge
manages the Faces single
request lifecycle
Resource Request
Event Request
Render Request
Action Request
*See section 5.1 of the Bridge 2.0 spec for full details
Faces Engine
Apply
Bridge Request Restore Process
Request
Processing View Validation
Values
Update
Invoke
Render Model
Application
Values
16. Servlet Processing
• Ability to (simultaneously) process
incoming faces requests via servlet
container
• Good for debugging
17. JSF 1.2 Portlets
• Add a portlet.xml and the portlet bridge
jars to your current JSF application.
• Use the archetype for reference
18. Working with the portlet API
through JSF
Environment Based Resolution:
• FacesContext.ExternalContext (i.e - dispatch(),
encodeActionURL(), getResponse() ...)
• EL Variables - (i.e - portletConfig,
renderResponse, portletPreferences, ... )
22. Portlets
*Detailed example of Portlet Application Scope: http://vimeo.com/11484018
Simple SSO config between portal and seam app
(via components.xml)
Portlet Application Scope
23. JSF 2.0 Portlets
• JSF 2 is currently available as “Tech Preview”
• Add a portlet.xml and the portlet bridge jars
to your current JSF 2 application.
• Use the archetype for reference
24. Sending Events
Portlet Container
Seam Portlet JSF Portlet
Event
• Bridge provides its own BridgeEventHandler
• Standard Event configuration in portlet.xml
• Can receive or send events from any portlet
*Detailed example of Sending Events: http://vimeo.com/11484018
27. Public Render Parameters
• Simple way of providing a parameter which
can be consumed by any portlet
• BridgePublicRenderParameterHandler
• Map parameters to any BackingBean member
(via faces-config.xml)
*Full example of working with Render Params here: http://vimeo.com/11484018
30. Rendering Multiple JSF Apps on
One Page ?!?
• The bridge takes care of JSF + Portlet
namespacing
• Shared custom js will require it’s own NS
• Getting the bridge NS:
31. Other Need to Knows
• Clearing the view history between modes
• Ajax Error Handling
• Redirecting to an External Page or
Resource
bit.ly/9fjktn