HTML and CSS Reference
In-Depth Information
Instead of using the @FacesValidator annotation, you can declare the validator in the JSF faces-config.xml file
as follows:
<faces-config ...>
Now, let's see how to use the EmailValidator in the JSF application. Listing 3-13 shows an updated version of
TestBean managed bean (shown originally in Listing 3-8) which includes an email attribute of type ( String ).
Listing 3-13. Updated Version of TestBean Managed Bean
public class TestBean implements Serializable {
// ...
private String email;
// ...
public String getEmail() {
return email;
public void setEmail(String email) { = email;
// ...
Listing 3-14 shows the EmailValidator validator XHTML test page.
Listing 3-14. EmailValidator XHTML Test Page
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns=" "
xmlns:h=" "
xmlns:f=" " >
<title>Email Validator Test</title>
<h1>Validator Test</h1>
<h:outputText value="Enter Email: "/>
<h:inputText id="email"
value="#{}" required="true">
<f:validator validatorId="com.jsfprohtml5.EmailValidator"/>
Search WWH ::

Custom Search