HTML and CSS Reference
In-Depth Information
<h:commandButton action="#{testBean.proceed}" value="Proceed"/><br/>
<h:outputText value="#{testBean.location}">
<f:converter converterId="com.jsfprohtml5.LocationConverter" />
<h:messages style="color: red"/>
As shown in the bolded lines, in the converter test page, there is an input text and an output text which uses
LocationConverter using <f:converter> tag. <f:converter> tag is a core tag that is mainly designed in order to
avoid creating a TLD (Tag Library Descriptor) for every custom converter. Passing the ID of the custom converter,
which is defined in the @FacesConverter annotation, to the converterId attribute of the <f:converter> tag will
attach the custom converter to the parent ValueHolder component.
Figure 3-2 shows a conversion error that will be displayed when the user enters invalid location information that
does not cope with the location ( Address, City, Country ) format.
Figure 3-2. LocationConverter error message
Figure 3-3 shows the behavior of LocationConverter when the user inputs valid location information that copes
with the location ( Address, City, Country ) format.
Figure 3-3. LocationConverter behavior for input and output text
In order to understand the JSF validation, we need to know four main topics: the Validator interface APIs, the
standard JSF Validators, how to build a custom validator in JSF, and finally how to work with Java Bean Validation
(JSR 303) APIs. The next subsections illustrate these topics in detail.
Search WWH ::

Custom Search