Java Reference
In-Depth Information
The excerpt taken from the following JSF view demonstrates how to bind a UIInput component to this method
for validation purposes. Note that the userid field does not use bean validation since the JSF validator method is
registered with it.
...
<h:form prependId="false">
<h1>Create User</h1>
<br/>
<h:messages infoStyle="color: green;" errorStyle="color:red;"/>
<h:panelGrid columns="2" width="50%" cellspacing="5px;">
<h:outputLabel for="userid" value="User ID "/>
<h:panelGroup>
<h:inputText id="userid" value="#{usersBean.users.userId}"
validator="#{usersBean.validateUserId}"/>
<h:message for="userid" errorStyle="color: red;"
infoStyle="color: green"/>
</h:panelGroup>
<h:outputLabel for="username" value="Username: "/>
<h:panelGroup>
<h:inputText id="username" value="#{usersBean.users.username}"/>
<h:message for="username" errorStyle="color: red;"
infoStyle="color: green"/>
</h:panelGroup>
<h:outputLabel for="firstname" value="First: "/>
<h:panelGroup>
<h:inputText id="firstname"
value="#{usersBean.users.firstname}"/>
<h:message for="firstname" errorStyle="color: red;"
infoStyle="color: green"/>
</h:panelGroup>
<h:outputLabel for="lastname" value="Last: "/>
<h:panelGroup>
<h:inputText id="lastname" value="#{usersBean.users.lastname}"/>
<h:message for="lastname" errorStyle="color: red;"
infoStyle="color: green"/>
</h:panelGroup>
<h:outputLabel for="password" value="Password: "/>
<h:panelGroup>
<h:inputSecret id="password"
value="#{usersBean.users.password}"/>
<h:message for="password" errorStyle="color: red;"
infoStyle="color: green"/>
</h:panelGroup>
</h:panelGrid>
 
Search WWH ::




Custom Search