HTML and CSS Reference
In-Depth Information
Figure 3-6. The subscriber application
The user information is validated as follows:
1.
All of the fields are required.
2.
User name must be at least 4 characters and at most 30 characters.
3.
Address must be at least 12 characters and at most 120 characters.
4.
E-mail must be valid.
Technically speaking, we will implement the first validation requirement using the JSF required field validator.
All of the other validations will be implemented using the JSR 303 APIs. In the validation requirement numbers 2 and 3,
the JSR 303 @Size annotation will be used, while for requirement number 4, we will implement a custom JSR 303
constraint. Listing 3-15 shows a Person managed bean which is used in the application main XHTML page.
Listing 3-15. Person Managed Bean
package com.jsfprohtml5.subscriber.model;
import com.jsfprohtml5.subscriber.bean.validation.custom.EmailAddress;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.validation.constraints.Size;
@ManagedBean
@RequestScoped
public class Person implements Serializable {
@Size(min = 4, max = 30)
private String name;
@Size(min = 12, max = 120)
private String address;
@EmailAddress
private String email;
public Person() {
}
public String subscribe() {
return null;
}
 
Search WWH ::




Custom Search