I have the following JSF 2.1 page
<h:selectOneRadio value="#{userBean.newUser}">
<f:selectItem itemValue="0" itemLabel="new User" />
<f:selectItem itemValue="1" itemLabel="existing User" />
</h:selectOneRadio>
<br />
<h:inputText value="#{userBean.customerId}" id="customerId" />
<h:message for="customerid" />
<br />
<h:inputText value="#{userBean.firstName}" id="firstName" />
<h:message for="fisrtName" />
<br />
<h:inputText value="#{userBean.lastName}" id="lastName" />
<h:message for="lastName" />
<br />
<h:commandButton value="Submit" action="#{userBean.login}" />
and this is my bean:
public class UserBean {
private String customerId;
private String newUser= "0";
private String firstName;
private String lastName;
}
I need to check this form as follows:
If the βnew userβ radio button is selected, all input data of the form must be checked. If "existing user" is selected, I only need to check the client ID.
I tried Hibernate Validation, and I also tried my own validator by implementing the interface javax.faces.validator.Validator.
Is it possible to somehow achieve this functionality?
source
share