2 Replies Latest reply on Aug 3, 2010 11:57 AM by Hai-Yun Du

    Validation message not showing up

    Hai-Yun Du Newbie

      When I enter the password in the following code, the validation message appears:



                <s:decorate id="password" template="/layout/edit.xhtml">
                     <ui:define name="label">Password</ui:define>
                     <a4j:outputPanel ajaxRendered="true">
                          <h:inputSecret id="passwordValue" value="#{passwordBean.newPassword}" 
                               valueChangeListener="#{passwordBean.validate}">
                               <a4j:support event="onkeyup" reRender="password, passwordValue" ajaxSingle="true"/>
                           </h:inputSecret>
                     </a4j:outputPanel>
                </s:decorate>
      



      If I just add the testing input to the field in the following, the error style and image appear but not the validation message:



                <s:decorate id="password" template="/layout/edit.xhtml">
                     <ui:define name="label">Password</ui:define>
                     <h:inputText value="testing" />
                     <a4j:outputPanel ajaxRendered="true">
                          <h:inputSecret id="passwordValue" value="#{passwordBean.newPassword}" 
                               valueChangeListener="#{passwordBean.validate}">
                               <a4j:support event="onkeyup" reRender="password, passwordValue" ajaxSingle="true"/>
                           </h:inputSecret>
                     </a4j:outputPanel>
                </s:decorate>
      



      The template edit.xhtml



      <ui:composition  xmlns="http://www.w3.org/1999/xhtml"
                       xmlns:ui="http://java.sun.com/jsf/facelets"
                       xmlns:h="http://java.sun.com/jsf/html"
                       xmlns:f="http://java.sun.com/jsf/core"
                       xmlns:s="http://jboss.com/products/seam/taglib">
      
          <div class="prop">
      
              <s:label styleClass="name #{invalid?'errors':''}">
                  <ui:insert name="label"/>
                  <s:span styleClass="required" rendered="#{required}">*</s:span>
              </s:label>
      
              <span class="value #{invalid?'errors':''}">
                  <s:validateAll>
                      <ui:insert/>
                  </s:validateAll>
              </span>
      
              <span class="error">
                  <h:graphicImage value="/img/error.gif" rendered="#{invalid}" styleClass="errors"/>
                  <s:message styleClass="errors"/>
              </span>
      
          </div>
      
      </ui:composition>
      



      The page bean




      @Name("passwordBean")
      @Scope(ScopeType.CONVERSATION)
      public class PasswordBean implements Serializable {
      
           private String newPassword;
           // plus getters and setters
      
           public void validate(ValueChangeEvent e) {
                FacesMessages.instance().addToControlFromResourceBundle("passwordValue", "Validation failed");
           }
      }



      It works fine with the one password input, but I need to include other input elements in the s:decorate field. Any ideas what could be wrong?


      Thanks,
      hdu