2 Replies Latest reply on Sep 26, 2007 10:13 AM by wu haixing

    seam don't set the invalid after an ajax request

    wu haixing Newbie

      I have a s:decorate like this

      <a4j:region id="#{fieldId}Field" selfRendered="true" regionRenderOnly="true">
       <ui:insert/>
       <div id="#{fieldId}Label" class="formlabel #{invalid?'errlabel':''}">
       <ui:insert name="label"/>
       </div>
      
       <div id="#{fieldId}Input" class="formfield #{invalid?'flderr':''}">
       <ui:insert name="field"/>
       <a4j:status for="#{fieldId}Field">
       <f:facet name="start">
       <h:graphicImage value="/img/ajax_process.gif"/>
       </f:facet>
       </a4j:status>
       </div>
       <a4j:outputPanel id="#{fieldId}MessageBlock" layout="block" styleClass="errorMsg" ajaxRendered="true" rendered="#{invalid}">
       <s:message for="#{fieldId}" globalOnly="false"/>
       </a4j:outputPanel>
      </a4j:region>
      

      I just want to set the label and field styleClass based on the invalid status,but seems it not work after the ajax request.The server side told me
      there is a invalid field,but message is just queued and may not be displayed.I think the reason is the invalid not be changed after the ajax request.any suggestion is appreciate!
      thanks in advance!

        • 1. Re: seam don't set the invalid after an ajax request
          Pete Muir Master

          #{invalid} is made available by s:decorate - reRender the s:decorate, not its contents. Follow the examples!

          • 2. Re: seam don't set the invalid after an ajax request
            wu haixing Newbie

            thanks,I had figure it out.and there is the code can do it's work!
            in the form:

            <s:decorate id="emailFormRow" template="/layout/formRow.xhtml">
             <ui:define name="label">
             <h:outputLabel for="email" value="#{messages['register.email']}"/>
             </ui:define>
             <ui:define name="field">
             <h:inputText id="email" value="#{member.email}" required="true"
             onfocus="emailHelperShow({duration:0.5,from:0.0,to:1.0})"
             onblur="emailHelperHide({duration:0.7})">
             <a4j:support event="onchange" reRender="emailFormRow" requestDelay="0" ajaxSingle="true"/>
             </h:inputText>
             </ui:define>
             <ui:param name="fieldId" value="email"/>
             <ui:param name="validateMessage" value="#{register.emailMessage}"/>
             <ui:param name="helperContent" value="tip.email"/>
             </s:decorate>
            

            it's the template

            <a4j:region id="#{fieldId}Field" selfRendered="true" regionRenderOnly="true">
            <a4j:outputPanel id="#{fieldId}Block" layout="block" styleClass="formRow">
             <ui:insert/>
             <a4j:outputPanel id="#{fieldId}Label" layout="block" styleClass="formlabel #{invalid?'errlabel':''} #{required?'required':''}">
             <ui:insert name="label"/>
             </a4j:outputPanel>
            
             <a4j:outputPanel id="#{fieldId}Input" layout="block" styleClass="formfield #{invalid?'flderr':''}">
             <ui:insert name="field"/>
             <a4j:status for="#{fieldId}Field">
             <f:facet name="start">
             <h:graphicImage value="/img/icons/ajax_process.gif"/>
             </f:facet>
             </a4j:status>
             </a4j:outputPanel>
            
             <a4j:outputPanel id="#{fieldId}Helper" layout="block" rendered="#{not empty helperContent}"
             style="left:368px;display:none;" styleClass="helpMsg helperBlock" >
             <h:outputText escape="false" value="#{messages[helperContent]}"/>
             </a4j:outputPanel>
             <rich:effect name="#{fieldId}HelperHide" for="#{fieldId}Helper" type="Fade" rendered="#{not empty helperContent}"/>
             <rich:effect name="#{fieldId}HelperShow" for="#{fieldId}Helper" type="Appear" rendered="#{not empty helperContent}"/>
             <a4j:outputPanel id="#{fieldId}MessageBlock" layout="block" styleClass="errorMsg" ajaxRendered="true" rendered="#{invalid}">
             <s:message for="#{fieldId}" globalOnly="false"/>
             </a4j:outputPanel>
            </a4j:outputPanel>
            </a4j:region>
            

            I also replace div with outputPanel,put the region as the wrapper to keep the style