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 />

request completes. JSF 2 provides two callback events, onevent and onerror, which allow you to invoke a<br />

custom JavaScript during the Ajax request. They are described in Table 2-10.<br />

Table 2-10. Standard Ajax request callback events<br />

Attribute Description<br />

onevent Name of JavaScript function to handle UI events.<br />

onerror Name of JavaScript function to handle error events.<br />

onevent consists of three sub-events, described in Table 2-11.<br />

Table 2-11. onevent Sub-Events Descriptions<br />

Event name Description<br />

begin Occurs just before the Ajax request is fired.<br />

complete Occurs right after the Ajax response completes but before the DOM update.<br />

success Occurs after DOM update. In case of an error, this event will be replaced by the onerror<br />

function call.<br />

Let’s start with a simple example. The application looks like Figure 2-5.<br />

Figure 2-5. A simple form with different colors<br />

Listing 2-44 shows the JSF page.<br />

Listing 2-44. Shows the JSF page<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Listing 2-45 shows the managed bean.

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

Saved successfully!

Ooh no, something went wrong!