Java Reference
In-Depth Information
attributes outside of the implementation class would be to create a custom tag for
it and require the page author to set the attribute values from the page.
Whether you are binding a converter, listener, or validator to a managed bean property, the
process is the same for any of the implementations:
• Nest the converter, listener, or validator tag within an appropriate component tag.
• Make sure that the managed bean has a property that accepts and returns the con-
verter, listener, or validator implementation class that you want to bind to the prop-
erty.
• Reference the managed bean property using a value expression from the binding
attribute of the converter, listener, or validator tag.
For example, say that you want to bind the standard DateTime converter to a managed
bean property because you want to set the formatting pattern of the user's input in the
managed bean rather than on the Facelets page. First, the page registers the converter onto
the component by nesting the f:convertDateTime tag within the component tag.
Then,
the
page
references
the
property
with
the binding attribute
of
the
f:convertDateTime tag:
Click here to view code image
<h:inputText value="#{loginBean.birthDate}">
<f:convertDateTime binding="#{loginBean.convertDate}" />
</h:inputText>
The convertDate property would look something like this:
Click here to view code image
private DateTimeConverter convertDate;
public DateTimeConverter getConvertDate() {
...
return convertDate;
}
public void setConvertDate(DateTimeConverter convertDate) {
convertDate.setPattern("EEEEEEEE, MMM dd, yyyy");
this.convertDate = convertDate;
}
See “Writing Properties Bound to Converters, Listeners, or Validators” in The Java EE
6 Tutorial: Basic Concepts for more information on writing managed bean properties for
converter, listener, and validator implementations.
Search WWH ::




Custom Search