Search This Blog

Thursday 24 June 2010

JSF 2.0 My First Look

Heard enough about JSF 2.0 to look into it today. Step 1was to find an IDE which supported it but unfortunately JDeveloper 11g didn't, so for the first time in a long time I had to move into another IDE and NetBeans IDE seemed the way to go here.

Although I just created some very basic demos it didn't take long to get into building tables from collections and other more useful demos. Few things really impressed me about JSF 2.0.

1. Finally I can add references to my model attributes as follows without the need to use a h:outputText component

#{TaskBean.info}

2. You can simply use a default bean name for backing beans without the need to declare beans with managed-bean in faces-config.xml. You simple put @ManagedBean above the class definition.

@ManagedBean(eager=true)
@SessionScoped
public class CalculatorManagedBean implements Serializable {
public static char[] operands = { '+', '-', '*', '/' };

3. The use of Facelets, not JSP, as the standard technology for all your JSF pages. So you name your page pas.xhtml and can reference it as pas.jsf as long as your web.xml contains the following.


<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>


4. No real need to define explicit navigation rules. If your bean methods return a a string as follows then the resulting page pas.xhtml will be called.

return "pas";

Hope to spend more time on JSF 2.0 and of course there is more to it then just this but thats a good enough start for me.

3 comments:

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

Hey - I am certainly happy to find this. Good job!

Anonymous said...

Hi - I am definitely happy to find this. cool job!