2 Replies Latest reply on Aug 3, 2010 11:57 AM by hdu

    Validation message not showing up

    hdu

      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




        • 1. Re: Validation message not showing up
          lvdberg

          Hi,


          The s:decorate is a small template for inputs with a label and validation. The template holds the label
          (with the ui:define ) and the input. When you add the input test, everything shifts down and the input text takes the place of to-be-validated panel.


          You can change the edit.xhtml template if you want to add the test, but I don't think that is what you want.


          Leo


          • 2. Re: Validation message not showing up
            hdu

            Thanks for the reply, Leo.


            Do you mean that s:validateAll doesn't validate all the input components from the ui:insert? How could I change the template to fix this?


            -hdu