2 Replies Latest reply on Dec 5, 2008 4:01 PM by dh2k7

    change style class of empty fields

    dh2k7

      Hello,

      I've tried to write a jsf validator, that checks if a field is empty.
      If so, it should change the styleClass of the field.
      Than I wanted to attach the ajaxValidator to do this in ajax.
      But then I've noticed, that empty fields get not validated... :(

      How can I solve this now?

        • 1. Re: change style class of empty fields
          nbelaevski

          Hi,

          No way, that's how JSF UIInput class works:

          if (isValid() && !isEmpty(newValue)) {
           if (this.validators != null) {
           for (Validator validator : this.validators) {
           try {
           validator.validate(context, this, newValue);
           }
           catch (ValidatorException ve) {
           ...
          


          Empty values are not validated using validators.

          • 2. Re: change style class of empty fields
            dh2k7

            Yes, I know.
            But does anyone knows a good (and easy) way to change the style if an element if it is empty on form submit.