6 Replies Latest reply on Dec 9, 2010 11:37 AM by jsf_joe

    rich:simpleTogglePanel - opened ignored after user selection

    tri77ion

      I've got a rich:simpleTogglePanel whose opened attribute is bound to a backing bean. The panel is rerendered based on some other action on the page and the panel displays based on the opened attribute.

      The problem is that after I manually Show/Hide the panel, all subsequent rerenders use the opened state based on what was selected, not based on the opened attribute. The backing bean action does get called, but the state is never used. Shouldn't a rerender cause the opened attribute to be used and not the last client selection? If the current behaviour is by design is there any way to achieve what I want?

      Using RichFaces 3.2.2.GA. Trivial example follows:

      Facelet

      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:c="http://java.sun.com/jstl/core"
       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:a4j="http://richfaces.org/a4j"
       xmlns:rich="http://richfaces.org/rich">
      <body>
       <a4j:form id="myForm">
       <a4j:commandButton action="#{toggleBean.toggle}" id="myButton" reRender="myOutputPanel" value="Re-render toggle panel"/>
       <br/>
       <a4j:outputPanel id="myOutputPanel">
       Opened? #{toggleBean.opened}
       <rich:simpleTogglePanel id="myTogglePanel" opened="#{toggleBean.opened}" switchType="ajax">
       <f:facet name="closeMarker">
       <u>Hide</u>
       </f:facet>
       <f:facet name="openMarker">
       <u>Show</u>
       </f:facet>
       Contents
       </rich:simpleTogglePanel>
       </a4j:outputPanel>
       </a4j:form>
      
      </body>
      </html>
      

      Backing Bean (Session scope)
      public class ToggleBean {
       private boolean opened = false;
       public boolean isOpened() {
       return opened;
       }
       public void toggle() {
       opened = !opened;
       }
      }