2 Replies Latest reply on Nov 30, 2007 5:25 PM by asookazian

    a4j:support and reRendering a4j:commandButton

    asookazian

      I am trying to hide/display the a4j:commandButton based on whether or not any text is entered in the h:inputTextarea component. I know when I enter 's', the SFSB is returning 's' from getNoteText2() method (I see it logged in the log). But the submit button does not get rendered. why?

      ultimately I would like the JSF EL for the submit rendered attribute to be something like 'not empty noteAction.noteText2'. that doesn't work either. thx.

      <a4j:form id="a4jMainForm1">
       <h:panelGrid columns="2" style="vertical-align:middle">
       <h:outputText id="description1" value=""/>
       <BR/>
       <h:inputTextarea id="noteText1" value="#{noteAction.noteText}" rows="6" cols="50">
       <a4j:support event="onkeyup" reRender="submit1" />
       </h:inputTextarea>
      
       <a4j:commandButton id="submit1" value="submit" action="#{noteAction.submit('mpNote')}"
       onclick="Richfaces.hideModalPanel('mpNote')" rendered="#{noteAction.noteText2 == 's'}"/>
      
       <BR/>
       <a4j:commandButton value="cancel" onclick="Richfaces.hideModalPanel('mpNote');unselectCurrentRadioButton()"/>
       </h:panelGrid>
       </a4j:form>


        • 1. Re: a4j:support and reRendering a4j:commandButton
          asookazian

          I added an h:outputText component and that is working (like in the Richfaces JSF demo example for a4j:support), but the commandButton submit still is not showing:

          <a4j:form id="a4jMainForm1">
           <h:panelGrid columns="2" style="vertical-align:middle">
           <h:outputText id="description1" value=""/>
           <BR/>
           <h:inputTextarea id="noteText1" value="#{noteAction.noteText}" rows="6" cols="50">
           <a4j:support event="onkeyup" reRender="submit1, foo" />
           </h:inputTextarea>
          
           <h:outputText id="foo" value="#{noteAction.noteText2}"/>
           <a4j:commandButton id="submit1" value="submit" action="#{noteAction.submit('mpNote')}"
           onclick="Richfaces.hideModalPanel('mpNote')" rendered="#{noteAction.noteText2 == 's'}"/>
          
           <BR/>
           <a4j:commandButton value="cancel" onclick="Richfaces.hideModalPanel('mpNote');unselectCurrentRadioButton()"/>
           </h:panelGrid>
           </a4j:form>


          • 2. Re: a4j:support and reRendering a4j:commandButton
            asookazian

            This works! Had to surround the submit button with h:panelGroup...

            <a4j:form id="a4jMainForm1">
             <h:panelGrid columns="2" style="vertical-align:middle">
             <h:outputText id="description1" value=""/>
             <BR/>
             <h:inputTextarea id="noteText1" value="#{noteAction.noteText}" rows="6" cols="50">
             <a4j:support event="onkeyup" reRender="out1, foo1" />
             </h:inputTextarea>
            
             <h:outputText id="foo1" value="#{noteAction.noteText2}"/>
            
             <h:panelGroup id="out1">
             <a4j:commandButton id="submit1" value="submit" action="#{noteAction.submit('mpNote')}"
             onclick="Richfaces.hideModalPanel('mpNote')" rendered="#{not empty noteAction.noteText2}"/>
             </h:panelGroup>
             <BR/>
             <a4j:commandButton value="cancel" onclick="Richfaces.hideModalPanel('mpNote');unselectCurrentRadioButton()"/>
             </h:panelGrid>
             </a4j:form>