Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.58 KB  |  hits: 30  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. how to invoke JSF Validator on keyup event?
  2. <h:inputText id="foo" value="#{bean.foo}">
  3.     <f:ajax event="keyup" execute="@this" render="fooMessage" />
  4.     <f:validator validatorId="fooValidator" />
  5. </h:inputText>
  6. <h:message id="fooMessage" for="foo" />
  7.        
  8. @FacesValidator("fooValidator")
  9. public class FooValidator implements Validator {
  10.  
  11.     @Override
  12.     public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
  13.         // ...
  14.  
  15.         if (invalid) {
  16.             throw new ValidatorException(new FacesMessage("Fail!"));
  17.         }
  18.     }
  19.  
  20. }