The Two Faces of JSF on WLP
Creating a JSF Portlet
To create a portlet from your JSF Page Flow, the process is more similar to creating a JSP portlet than a standard Beehive Page Flow portlet. Where with Beehive Page Flows, the portlet Content Path is set to the Page Flow Controller, a JSF Page Flow starts from the JSF JSP. Note that, while in the portlet wizard, you will enter the path to the JSP, the resulting .portlet file contains the .faces extension in the path:
<netuix:content> <netuix:facesContent contentUri="/portlets/jsfPageFlowDemo/index.faces"/> </netuix:content>
Because the path starts at the JSF JSP rather than a method on the Page Flow Controller, if you need to initialize values the first time the portlet is loaded, you need to do all of your initialization in the backing bean.
Coding the Old Fashioned Way
In case you skipped to this section, if you already have an investment in skills and/or artifacts based on standard WLP Beehive Page Flows, go back and read the first three paragraphs under the No Going Back for Wizard Lovers heading to add the JSF facet and understand the implications.
With the JSF facet installed, you are now free to develop JSF pages. There is no single wizard like for a Page Flow that will generate all of the base files you need for JSF development. You will need to create your backing beans by hand, although you will still have the standard Eclipse code assist tools. If your development team works from static HTML files, you can use a wizard that will create the JSF JSP for you. The wizard can be started from New\Other, expanding JSF and selecting Convert HTML to JSF:
Figure 2: HTML to JSF Wizard
The wizard simply adds the basic JSP declaration, JSF taglibs, and wraps the HTML in a view tag:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <f:view> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <form action="htmlBaseExample.jsp" method="post"> Type in me:<input type="text" name="test"/><br /> Check me:<input type="checkbox" name="checkMe"/> </form> <table border="1" cellpadding="5" width="300"> <tr><th>Field 1</th><th>Field 2</th></tr> <tr><td>Value 1</td><td>Value 2</td></tr> </table> </body> </html> </f:view>
Although there is also a wizard node for generating a JSF configuration file, one was already created by adding the JSF facet. WorkSpace Studio has a fairly comprehensive GUI for managing faces-config.xml.
Figure 3: WorkSpace Studio Faces GUI
Page 2 of 3