Book review: JSF 2.0 Cookbook

Last July, I was asked to review JSF 2.0 Cookbook by Anghel Leonard. I finally found time to finish reading the book and wrote a review. (If you are interested, back in April I reviewed another book from Packt Publishing: JSF 1.2 Components.)

Chapter 1 – Using Standard and Custom Converters in JSF

The chapter covers how to use standard converters and how to build custom converters. The author does a good job covering the standard out-of-the-box converters with a number of examples. The chapter then shows how to create your own custom converter. There are a number of small typos, but that’s not a big deal. Although standard and custom converters are covered in regular JSF books, it’s a topic that many people have difficulties with so I think there is a place for them in a recipe-type book. Two other things I found useful are discussions of RichFaces build-in converters and MyFaces converters.
Continue reading

My reply to "Top 10 reasons why I don’t like JSF"

Bruno Borges posted Top 10 reasons why I don’t like JSF. Below you will find my replies to his points. A few weeks earlier, I also posted: JVM Web Frameworks Comparison – reply to JSF scoring.

1. Extra step when defining a project’s architecture
People insist on comparing JSF with other frameworks. They should stop doing that. You can compare MyFaces to RichFaces to Tapestry to Vaadin to GWT.

This is true. It makes more sense to compare JSF component frameworks such as RichFaces against other frameworks. And because the component libraries are all based on JSF, you will also be comparing JSF. However, I’m guessing most people already do that, they compare JSF+framework vs framework XYZ.
Continue reading

JVM Web Frameworks Comparison – reply to JSF scoring

At Devoxx conference last month, Matt Raible compared JVM Web Frameworks and posted this score matrix. Matt also posted posted baed on what the score was calculated. I met Matt for the first time in March 2010 during TheServerSide Java Symposium in Las Vages.

As someone who has been working with JSF and RichFaces for long time, I wanted to review and post feedback with regards to Matt’s grades for JSF. I also want to be upfront and tell you that I didn’t attend his session. I was at the conference but attended a different session. My goal is not to strike a debate or increase any scores for JSF, but just to show an alternative side as well as potential feedback and comments. Here we go.

To make it easier, I used the following format:
Category – score
Score context (copied from this page)
My comments


Developer productivity – 0.5
Score context: 0 if no save/reload functionality, 0.5 if provided by JRebel, 1.0 if built into framework.

JSF Facelets allows you to save/reload in most cases.


Continue reading

Exadel jsf4birt – BIRT reporting in JSF applications is now on exadel.org

I’m happy to announce that Exadel jsf4birt project is now open source and has moved to exadel.org. jsf4birt makes it easy to embed a BIRT report inside JSF application. jsf4birt only requires JSF 1.2 but you can easily add RichFaces to add Ajax and other rich functionality.

JSF page:


   
        
        
   

BIRT report is inserted into a JSF page as a JSF component and rendered:

Slides: Ajax Applications with JSF 2 and New RichFaces 4 from Herbstcampus

Slides from my presentation at Herbstcampus conference.

What RichFaces a4j:ajax adds on top JSF 2 f:ajax tag

JSF 2 now has basic Ajax support via f:ajax tag. RichFaces 3 has a very popular a4j:support tag (in fact, f:ajax was inspired by a4j:support). RichFaces 4 comes with a4j:ajax which is based on f:ajax but upgrades the tag with more features and advanced functionality. The table below show the attributes available in both tags and how RichFaces upgrades the core Ajax functionality in JSF 2 (I’ll cover a4j:ajax extra attributes in the future).

In addition to a4j:ajax, RichFaces upgrades JSF 2 with tags such as a4j:commandButton, a4j:commandLink, a4j:poll, a4j:jsFunction, a4j:outputPanel and more (covered in future posts).

Attribute f:ajax a4j:ajax
event Works the same Works the same
execute @all
@this
@form
@none
Id’s
EL
@all
@this
@form
@none
Id’s
EL (different behavior, id’s are resolved in current request)
@region (when a4j:region is used)
render @all
@this
@form
@none
Id’s
EL
@all
@this
@form
@none
Id’s
EL (different behavior, id’s are resolved in current request)
listener Works the same Works the same
onevent Works the same Works the same
onerror Works the same Works the same
immediate Works the same Works the same
disabled Works the same Works the same
onbegin n/a JavaScript to execute before Ajax request
onbeforedomupdate n/a JavaScript to execute after response comes back but before DOM update
oncomplete n/a JavaScript to execute after DOM update
bypassUpdates n/a Skips Update Model and Invoke Application phases, useful for form validation
limitRender n/a Skips all a4j:outputPanel ajaxRender=”true” areas. Only renders what is set in current render
status n/a Status to display during Ajax request
focus n/a Sets focus on component after Ajax request (not yet implemented)

Learning JSF2: Using Flash scope

JSF 2 provides two new scopes on top of the standard Servlet scopes (request, session, application). One of them is the view scope. View scope was covered in Managed beans article. The other scope is Flash which I’m going to cover here. Let’s start with a very simple example.

Managed bean:

@ManagedBean(name = "bean")
public class Bean {
   private String text;
   // getter and setter

   public String nextpage (){
       return "page2";
   }
}

As scope is not specified, the default scope is request.

JSF page (page1.xhtml):


   
	
	
	
   

Continue reading