2 Replies Latest reply on Feb 17, 2009 2:43 PM by Kristof Vanhaeren

    HtmlPickList validator only executed when something selected

    Kristof Vanhaeren Newbie

      Hi,

      I have defined and created a custom validator on an HtmlPickList, but the
      problem is that the validator gets called only if there has been interaction with the picklist (eg: item selected)

      <rich:pickList id="usersPickList"
       value="#{selectUsersModuleBean.targetUsers}"
       showButtonsLabel="false"
       converter="UserConverter"
       rendered="false">
       <f:validator validatorId="RecipientsValidator" />
       <f:selectItems value="#{selectUsersModuleBean.users}" />
       </rich:pickList>
      


      public class RecipientsValidator implements Validator {
      
       @Override
       public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
       if ((context == null) || (component == null)) {
       throw new IllegalArgumentException(context == null ? "Context" : "Component" + " cannot be null");
       }
      
       List recipients = (List)value;
       if (recipients.size() < 1) {
       throw new ValidatorException(new FacesMessage("'Recipients' is required"));
       }
       }
      
      }
      


      Any ideas?

      Thx