3 Replies Latest reply on Oct 25, 2009 4:47 AM by Cody Lerum

    Seam Validator Not Working

    mike jones Newbie
      I have a Validator class

      import javax.faces.application.FacesMessage;
      import javax.faces.component.UIComponent;
      import javax.faces.context.FacesContext;
      import javax.faces.validator.ValidatorException;

      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.faces.Validator;
      import org.jboss.seam.annotations.intercept.BypassInterceptors;
      import org.jboss.seam.log.Log;
      import org.jboss.seam.ScopeType;

      @Name("amountValidator")
      @BypassInterceptors
      @Scope(ScopeType.CONVERSATION)
      @Validator

      public class amountValidator implements javax.faces.validator.Validator,
                java.io.Serializable {

           @Logger
           private Log logger;

           private static final long serialVersionUID = 1L;

           public void validate(FacesContext context, UIComponent cmp, Object value)
                     throws ValidatorException {

                String cmpId = cmp.getId();
                
                value = replaceNull((String)value);

                if(value.equals("")){
                     throw new ValidatorException(new FacesMessage("value null"));

                }
                logger.info("validate(): cmpId = " + cmpId);

           }
      I am trying to use no input text field

      <h:inputText value="" validator="#{amountValidator}"/>

      I have a submit button

      <s:button id="backButton" alt="Back button" value="#{messages['button.back']}" action="#{amountChangeFacade.submit}" />

      When I click the button the validation is not getting called.

      It only gets called when I use a regular JSF Command Button

      but I need to use a SEAM button.

      Am I missing anything?