2

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.

Prasanna
  • 81
  • 1
  • 13
  • 1
    Yes using `` and binding to another component of your interest, if necessary. Basically, you are looking for the cross field validation criteria ([example](http://stackoverflow.com/a/6282509/1391249)). – Tiny Jul 06 '15 at 18:12

1 Answers1

0

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'
}
stg
  • 2,757
  • 2
  • 28
  • 55
  • Cant get unique `selectOneMenuID` as it is in a dataTable and JSF adds rowIndex in the `selectOneMenuID` – Prasanna Jul 07 '15 at 07:02