Java & J2EE Page 6 - Introduction to JavaServer Faces Part 2 |
The JSP page is the only component in this application. It is called validatorTest.jsp and is shown in Listing 6. <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %><%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>The validatorTest.jsp page contains a form with a UIInput component represented by the input_text custom tag. The form also contains a command_button tag representing a UICommand, as well as an output_errors tag for displaying any error that occurs during processing. The most important part is the validate_length tag inside the input_text tag.
Figure 8 The directory structure for the validator example The validate_length tag represents one of the standard validators in JSF. It checks for the length of the input and makes sure that it has a minimum of six characters. Any input shorter than six characters will generate an error that will be displayed by the output_errors tag. To run the application, you need to restart Tomcat. Then, use the following URL to invoke the validatorTest.jsp page: http://localhost:8080/JSFCh02b/faces/validatorTest.jsp
Figure 9 The validator example in action
blog comments powered by Disqus |