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 1 THE BASICS<br />

<br />

<br />

<br />

<br />

This example looks very similar to the <strong>RichFaces</strong> 3 example. The obvious changes are the new<br />

behavior (), the event is specified without the on-part and instead of reRender, the render<br />

attribute is used. However, the core Ajax concepts are very similar. In addition to using <br />

behavior, it’s also possible to send an Ajax request in a programmatic way, as follows:<br />

<br />

<br />

<br />

<br />

Even though basic, Ajax is now part of the JSF 2 standard. We will cover more features later<br />

in the book.<br />

Before we tell you more about <strong>RichFaces</strong>, we must ask: why would you use JSF? Well, the shortest<br />

answer is that (after a short learning curve) JSF simplifies development. The basic purpose of any<br />

framework is to simplify development by hiding the tasks that are common to any application. JSF does<br />

exactly that. You don’t have to worry anymore about how to get data from the request or how to define<br />

navigation or convert values. JSF provides all this and more out of the box. If all the plumbing is covered<br />

by the framework, that leaves you more time to work on the actual application. Finally, a JSF component<br />

approach makes it the perfect technology to be used with Ajax.<br />

An Overview of <strong>RichFaces</strong><br />

If you are wondering why we need <strong>RichFaces</strong> if there is now Ajax functionality in JSF 2, it’s because the<br />

Ajax functionality in JSF 2 is very basic. You only get behavior. That’s not enough to build real<br />

rich enterprise Ajax applications. That’s exactly why you need <strong>RichFaces</strong>, a rich framework for JSF. It<br />

consists of the following parts:<br />

• Rich and Ajax components divided into two tag libraries (a4j:, rich:)<br />

• Skins<br />

• Client-side and object validation extension for Bean Validation (JSR 303)<br />

• CDK (Component Development Kit)<br />

Besides these main parts, <strong>RichFaces</strong> extends the standard JSF 2 Ajax request queue, and adds<br />

various rendering optimization attributes that we will cover in this book. A <strong>RichFaces</strong> application can<br />

also be deployed in the cloud, to places such as GAE (Google Apps Engine), Amazon EC2, and<br />

CloudBees, and OpenShift. <strong>RichFaces</strong> not only extends JSF, it makes JSF richer. In fact, you can’t use<br />

<strong>RichFaces</strong> without JSF. You use <strong>RichFaces</strong> with either the Mojarra JSF (Oracle RI) implementation or the<br />

MyFaces implementation. <strong>RichFaces</strong> simply provides ready-to-use Ajax components (and other<br />

features) to enable building Ajax-based applications. Another way to look at it as extra JSF components<br />

beyond what standard JSF provides. These components provide all the necessary JavaScript, so you<br />

almost never have to work with JavaScript directly.

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

Saved successfully!

Ooh no, something went wrong!