8.1.6.2 Sample JavaServer Face Page Files
Two JSF files are shown in Figures 8.25 and 8.26. In Figure 8.25, a Current.jsp page that works as a receiving page to get the username is shown. In Figure 8.26, Next.jsp, which works as a responding page to select and return a matching password based on the username to the Current. jsp page, is shown.
The function of the Current.jsp page is:
A. In order to use JSF tags, you need to include the taglib directives to the html and core tag libraries that refer to the standard HTML render kit tag library and the JSF core tag library, respectively.
B. A body tag with the bgcolor attribute is defined.
C. A page containing JSF tags is represented by a tree of components whose root is UIViewRoot, which is represented by the view tag. All component tags must be enclosed in the view tag. Other content such as HTML and other JSP pages can be enclosed within that tag.
D. A typical JSP page includes a form, which is submitted to the next page when a button is clicked. The tags representing the form components (such as text fields and buttons) must be nested inside the form tag.
E. The inputText tag represents an input text field component. The id attribute represents the ID of the component object represented by this tag, and if it is missing, then the imple-mentation will generate one. The validator attribute refers to a method-binding expres-sion pointing to a Java backing bean method that performs validation on the component’s data. The Java backing bean’s property userName is bound to the value attribute by using the Unified Expression Language value expression.

FIGURE 8.25 The code for the Current.jsp page.
F. The commandButton tag represents the button used to submit the data entered in the text field. The action attribute helps the navigation mechanism decide which page to open next. That is, the next page is defined in the application configuration resource file faces-config.xml using the tag, which is Next.jsp.
G. The message tag displays an error message if the data entered is not valid. The for attribute refers to the component whose value failed validation.