Prasanna
Prasanna

Reputation: 91

Can we pass parameters to the JSF Validator

Can we pass parameter values to JSF Validator in xhtml page. For example <h:inputText value='#{myvalue}' validator='#{validator.method(param)}' /> or is there any way to do so. Because i have a dataTable in which there are two columns with fields dealerType (selectOneMenu) and dealerNumber(inputText) where dealerNumber text strength validation is based on previous dealerType.

Upvotes: 2

Views: 1320

Answers (1)

stg
stg

Reputation: 2797

You may access the value of the selectOneMenu in the validator method of the inputText like this:

public void validate(FacesContext context, UIComponent component, Object value) 
        throws ValidatorException {
    UIInput input = (UIInput) context.getViewRoot().findComponent("selectOneMenuID");
    String str = (String) input.getSubmittedValue();
    // now do the validation based on 'str'
}

Upvotes: 0

Related Questions