2 Replies Latest reply on Apr 27, 2011 5:25 PM by angela leon

    rendering and hiding a panel

    angela leon Newbie

      Good morning everyone!

      I got a simple question: can we render and hide a panel somehow, I managed until now to make the panel appear when somecondition is true but is it possible to hide this same panel in order to show another one instead??

      Thanks a lot

        • 1. Re: rendering and hiding a panel
          Monkey Den Master

          Sure there is.  Generally, I would add the a4j:support tag to the component responsible for making an AJAX request (i.e. changing the condition), adding reRender to the tag to tell RichFaces which components to reRender after the response.  If the condition was changed on the request, the reRendered components will be hidden/shown based on that condition.  Use the rendered attribute on the components that are conditionally rendered. 

          <!-- The "controlling" component -->
          <h:selectOneListbox id="myPropertySelect" value="#{myBean.myProperty}" size="1" >
              <s:selectItems value="#{myBean.myProperties}".../>
              <a4j:support ajaxSingle="true" event="onchange" reRender="propertyNotSelected,propertySelectedPanel" />
          <!-- Render when myProperty has NOT been selected -->
          <a4j:outputPanel id="propertyNotSelectedPanel" rendered="#{myBean.myProperty empty}">
              <h:outputText value="Please choose a myProperty"/>
          <!-- Render when myProperty has been selected -->
          <a4j:outputPanel id="propertySelectedPanel" rendered="#{myBean.myProperty not empty}">
              <h:outputText value="myProperty selected"/>

          Untested code, but you probably get the idea.  Hope it helps.

          • 2. Re: rendering and hiding a panel
            angela leon Newbie

            Hello Kyle!!
            This is exactly what I was searching for!!!Thank you very much