1 Reply Latest reply on Dec 22, 2012 10:08 AM by rhanus

    rich:validator : client side validator : possible to externalize the validation constraints ?

    tvraghavan

      Hi,

       

      We are trying to move our validator framework to Richfaces-4 CSV (client side validation)

      Is there a way to externalize the validation constraints for all beans vs annotation ?

       

       

      We are ok to restart the application layer when the validation rules are altered.

       

      Thanks

      -R

        • 1. Re: rich:validator : client side validator : possible to externalize the validation constraints ?
          rhanus

          depending on what you exactly mean

          to externalize the validation constraints for all beans vs annotation

          you may use event element of jsf core like bellow:

           

          <f:event type="postValidate" listener="#{ourBean.myValidation}"/>

           

          and provide validation listener in your bean code:

           

          public void myValidation(ComponentSystemEvent e) {

                  UIPanel panel = (UIPanel) e.getComponent();

                  UIInput aInput = (UIInput) panel.findComponent("aInput");

           

                  FacesContext fc = FacesContext.getCurrentInstance();

                  if (aInput.getValue() == null) {

                      fc.addMessage(aInput.getClientId(), new FacesMessage(FacesMessage.SEVERITY_ERROR, "empty input", null));

                      fc.renderResponse();

                      return;

                  }

          ...

          }