34
If You Know JSF,You Know Portals and Portlets By: Wesley Hales June 1st, 2010

If You Know JSF, You Know Portals and Portlets

Embed Size (px)

DESCRIPTION

Presented at Jazoon 2010 on June 1st

Citation preview

Page 1: If You Know JSF, You Know Portals and Portlets

If You Know JSF, You Know Portals and Portlets

By: Wesley Hales

June 1st, 2010

Page 2: If You Know JSF, You Know Portals and Portlets

• JBoss Portlet Bridge Project Lead

• RedHat’s representative on JSR-301 & 329

• RichFaces contributor & GateIn core dev

• Side projects include: wesleyhales.com, Firefox Anthem

@wesleyhales vimeo.com/wesleyhales

Page 3: If You Know JSF, You Know Portals and Portlets

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

Page 4: If You Know JSF, You Know Portals and Portlets

Portlets of Yesterday

• “... looking for a strong Portal Developer with experience”.

• JSP’s with awkward portlet API mapping

• Yet another lifecycle to learn

Page 5: If You Know JSF, You Know Portals and Portlets
Page 6: If You Know JSF, You Know Portals and Portlets

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 ;)

Page 7: If You Know JSF, You Know Portals and Portlets

Quick Portlet Overview

• Spec driven (168 & 286)

• Rendered markup fragments on a page.

• Different window modes like edit, help, and view

Portlets are...

Page 8: If You Know JSF, You Know Portals and Portlets

Portlet UI

Page 9: If You Know JSF, You Know Portals and Portlets
Page 10: If You Know JSF, You Know Portals and Portlets

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.

Page 11: If You Know JSF, You Know Portals and Portlets

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

Page 12: If You Know JSF, You Know Portals and Portlets

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

Page 13: If You Know JSF, You Know Portals and Portlets

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

Page 14: If You Know JSF, You Know Portals and Portlets

• 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

Page 15: If You Know JSF, You Know Portals and Portlets

How the Portlet Bridge manages the Faces single

request lifecycle

Portlet Container

Apply Request Values

Restore View

Render

Process Validation

Update Model Values

Invoke Application

Actio

n R

equ

est Faces Engine

JSF Portlet

Ren

der R

equ

est

Reso

urce R

equ

est

Even

t Req

uest

Bridge Request Processing

*See section 5.1 of the Bridge 2.0 spec for full details

Page 16: If You Know JSF, You Know Portals and Portlets

Servlet Processing

• Ability to (simultaneously) process incoming faces requests via servlet container

• Good for debugging

Page 17: If You Know JSF, You Know Portals and Portlets

JSF 1.2 Portlets

• Add a portlet.xml and the portlet bridge jars to your current JSF application.

• Use the archetype for reference

Page 18: If You Know JSF, You Know Portals and Portlets

Working with the portlet API through JSF

• FacesContext.ExternalContext (i.e - dispatch(), encodeActionURL(), getResponse() ...)

• EL Variables - (i.e - portletConfig, renderResponse, portletPreferences, ... )

Environment Based Resolution:

Page 19: If You Know JSF, You Know Portals and Portlets
Page 20: If You Know JSF, You Know Portals and Portlets
Page 21: If You Know JSF, You Know Portals and Portlets

Portlets

Automatic script wrapping (via web.xml)

Supports all Richfaces components (i.e. - upload, push, etc...)

Page 22: If You Know JSF, You Know Portals and Portlets

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

Page 23: If You Know JSF, You Know Portals and Portlets

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

Page 24: If You Know JSF, You Know Portals and Portlets

Sending Events

• Bridge provides its own BridgeEventHandler

• Standard Event configuration in portlet.xml

• Can receive or send events from any portlet

Portlet Container

Seam Portlet

Event

JSF Portlet

*Detailed example of Sending Events: http://vimeo.com/11484018

Page 25: If You Know JSF, You Know Portals and Portlets
Page 26: If You Know JSF, You Know Portals and Portlets

Demo

Page 27: If You Know JSF, You Know Portals and Portlets

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

Page 28: If You Know JSF, You Know Portals and Portlets
Page 29: If You Know JSF, You Know Portals and Portlets

Changing Portlet Modes Using Faces Navigation

Page 30: If You Know JSF, You Know Portals and Portlets

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:

Page 31: If You Know JSF, You Know Portals and Portlets

Other Need to Knows

• Clearing the view history between modes

• Ajax Error Handling

• Redirecting to an External Page or Resource

bit.ly/9fjktn

Page 32: If You Know JSF, You Know Portals and Portlets

Getting Started• Maven Archetypes - bit.ly/9CMKZG

• Eclipse / JBoss Tools support

Page 33: If You Know JSF, You Know Portals and Portlets

Getting Involved

• User Forums

• Articles & How Tos

• Jira - Add your enhancement or try to handle some created issues

Page 34: If You Know JSF, You Know Portals and Portlets

Useful Links

• http://jboss.org/portletbridge

• http://vimeo.com/wesleyhales/videos

• http://jboss.org/gatein