0 Replies Latest reply on Sep 29, 2011 6:08 AM by Dale Ellis

    collapsiblePanel

    Dale Ellis Newbie

      Hi all,

       

      I have recentely developed a application in Richfaces 4, I am currently reading a bokk on RF4 but my knowledge is not up to speed yet, although I have had a about 5 years experiance using JSF 1.2 but with some likely bad haibbts as I learnt what I needed to get by.

       

      I'm using a collapsiblePanel and what I wish to happen is when I perform a search, if results are returned and the panel is not already collapased then I wish to collapse it.

       

      I have been reading the component documentation and looking at the JS code and thought I had figured out how to do it....

       

      <rich:collapsiblePanel id="criteriaCollapsePanel" header="Search Criteria" switchType="client">

       

       

      <!-- Some seaerch fields here -->

       

       

      <a4j:commandButton id="searchSubmit" value="${caseBean.searchFieldConfig.button.label}" action="${caseBean.search}"

      style="${caseBean.searchFieldConfig.button.style}"

      onbegin="this.disabled=true" oncomplete="#{rich:element('searchSubmit')}.disabled=false; hideIfResultsReturned();" render="errorMessages caseResults"/>

       

       

      <script type="text/javascript">

      //<![CDATA[

                function hideIfResultsReturned() {

                          var box = #{rich:component('criteriaCollapsePanel')};

                          var rowCount = parseInt(#{rich:element('casesReturned')}.value, 10);

       

       

                          if (box.activeItem && rowCount > 0) { // If the box is expanded, and some results have been returned, collapse it

                                    box.switchPanel();

                                    alert("Before it puts it back")

                          }

                }

      //]]>

      </script>

       

      <a4j:status id="status">

                <f:facet name="start">

                          <h:graphicImage value="images/loading.gif" alt="Search for cases..." style="margin-left: 10px;" />

                </f:facet>

      </a4j:status>

       

       

      </rich:collapsiblePanel>

       

       

      <!-- table here, and hidden input with ID "casesReturned" containing total rows returned -->

       

      The issue I have is that the panel collapses and that alert displays, all good, I feel pretty pleased with myself, then I remove the alert and it does not work, I was celebrating to soon. What is happening it seems is that the panel is expanding again after the function finishes.

       

      I have no idea why it is doing this, the form is not set to be re rendered as far as I can make out (I stress I'm new to Richfaces) so I don't think its been re rendered which would have explained it.

       

      Can anybody help me, why is it expanding again? What do I need to do to make it work as I had hoped.

       

      Also on a side issue, not particularly important but a nice to have, would be nice to animate the hide/show with a wipe/slide, is there anyway to easily override the hiding and showing functionality so that I could use the JQuery API's slide(Up/Down) to do this?

       

      Thanks in advance,

      Dale