I have problem to validate more than one component in h:form ... I need to validate these 2 inputText components but if I do it like this:
<p:inputText id="actionNameInput"
title="TO DO"
value="#{repositoryBean.newActionName}"
label="Action name"
required="true"
requiredMessage="Action name is missing.">
<f:validator validatorId="inputTextValidator"/>
<f:attribute name="input1" value="Action name" />
</p:inputText>
<p:inputText id="identifierInput"
title="TO DO"
value="#{repositoryBean.newActionRegex}"
label="Identifier"
required="true"
requiredMessage="Identifier is missing.">
<f:validator validatorId="inputTextValidator"/>
<f:attribute name="input1" value="Identifier" />
</p:inputText>
here is validator class:
@FacesValidator(value = "inputTextValidator")
public class AddActionValidatorInputText implements Validator{
@Override
public void validate(FacesContext facesContext, UIComponent uiComponent, Object o) throws ValidatorException {
if(((String)o).length() < 3){
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
uiComponent.getAttributes().get("input1")+" should be longer than 3characters.", null);
FacesContext.getCurrentInstance().addMessage(null, message);
throw new ValidatorException(message);
}
}
}
it will only validate first inputText ... I have tryied this, but I cant get values from components(always null) ... I read smthing about seam-faces, but If I applied it, there was some bigger error(like it needs more and more dependecies...) . I do not want to validate it in my bean class.