JavaServer Faces Programming has 3 ratings and 0 reviews. Offers a GUI solution framework. This book includes theory as well as code that readers can com. Author/s: Budi Kurniawan Publisher: McGraw-Hill Osborne Media Category: J2EE Review by: Gregg Bolinger Rating: 4. JavaServer Faces Programming by Budi Kurniawan, , available at Book Depository with free delivery worldwide.
|Published (Last):||20 November 2010|
|PDF File Size:||8.60 Mb|
|ePub File Size:||19.32 Mb|
|Price:||Free* [*Free Regsitration Required]|
It demonstrates how an event causes a listener to be executed. The listener simply prints messages to the console. However, it shows important information such as the hierarchy of the component tree of the JSP page from which the event was kurrniawan and the component that triggered the event.
The ActionListener is shown in Listing 5. An ActionListener must implement the javax. It provides the implementations for the getPhaseId and processAction methods. The getPhaseId method must return a javax.
PhaseId, and its return value determines in which process event step of the request processing lifecycle the listener will be executed. The processAction method accepts the javax.
Javaserveer object from the Lifecycle object. In the ActionListener in Listing 5, the processAction method first obtains the component that triggered the event by calling the getComponent method of the ActionEvent class, and then it prints the component identifier. Next, it obtains the instance of the current FacesContext and calls its getTree method face acquire the component tree an instance of javax.
Introduction to JavaServer Faces Part 2
Tree class representing the request page. To get the root of the component tree, it calls the getRoot method of the Tree class. Next, it passes the root to the private method navigateComponentTree, which draws the component tree hierarchy. The navigateComponentTree method is called recursively. Kurniawam first prints the identifier of the component passed in to it. The identifier is indented by a number of blank spaces proportionate to the level argument.
The level argument determines the number of spaces before the component name.
The indention gives the effect of a hierarchy. When called from the processAction method, the navigateComponentTree method is passed 0 as the level argument. The navigateComponentTree method then obtains the children of the passed in component by calling the getChildren method of the UIComponent interface.
Bkdi getChildren method returns an Iterator containing all children of the component. If you are using Windows, type the following command: In Tomcat 5, the servlet-api.
JavaServer Faces Programming
You can then direct your browser to the following URL: You will see something similar to Figure 6 in your browser. Model Object Created getFirstNumber: Figure 7 The result of the addition.
Now, type two numbers into the input boxes and click the Add button. You can see the browser now displays the result of the addition, as shown in Figure 7. The example presented in this section demonstrates how you can validate user input very easily in JSF. This application is even simpler than the one presented in the previous section. It consists of only one JSP page, and it does not require a JavaBean or an application configuration file. However, you kurniawa still need a directory structure for the application and the deployment descriptor.
The deployment descriptor is the same as the one in Listing 1. Here, we kurrniawan look at the directory structure and JSP page.
Introduction to JavaServer Faces Part 2 – devshed
Creating the Directory Structure for the Validator Example. In Tomcat, you create this under kurinawan. The directory contains all the required components that you will build in this example.
Again, you must copy the. Then, in the application directory, you have the validatorTest.
The JSP page is the only component in this application. It is called validatorTest. Listing 6 The validatorTest. Figure 8 The directory structure for the validator example. It checks for the length of the input and makes sure that it has a minimum of six characters. Running the Validator Example.
Javaserver Faces Programming: Budi Kurniawan: : Books
To run the application, you need to restart Tomcat. Then, use the following URL to invoke the validatorTest. Running the Validator Example To run the application, you need to restart Tomcat. Figure 9 The validator example in action Remember: