20.04.2013 Views

Practical RichFaces, Second Edition

Practical RichFaces, Second Edition

Practical RichFaces, Second Edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 2 GETTING STARTED<br />

Listing 2-36. Shows the result.xhtml page<br />

<br />

<br />

<br />

Listing 2-37 shows the managed bean.<br />

Listing 2-37. Shows the managed bean<br />

@ManagedBean<br />

@RequestScoped<br />

public class Bean2 {<br />

private String name;<br />

private Integer age;<br />

// getters and setters<br />

}<br />

This is a very simple registration form with Ajax-based validation. In other words, when we blur the<br />

field (tab out or click outside), an Ajax request is fired. We start going through JSF phases. If there is a<br />

validation error, after Process Validations, we go to Render Response. If there is no validation error, then<br />

we finish all the phases, going through Update Model and Invoke Application. To see this in action, let’s<br />

create a phase listener that will print a message to the console as we pass each phase.<br />

In case you need to review the JSF phases, they are shown in Figure 2-4.<br />

Figure 2-4. JSF life cycle diagram

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!