title: Bulk open/close of collapsiblePanel within a4j:repeat
body: <p>I do have a page, where I have a list of rich:collapsiblePanel that hold input elements. These collapsiblePanels themselves store their expanded/collapsed state within a backing bean.</p>
  
  <p>Now I have the use case to Open/Close all of these collapsiblePanels at once, with one mouse click. So I have tried to achieve this with the two commandButtons over the list. These use the attached actionListener to iterate over all backing beans of the collapsiblePanels and set the expanded flag to true/false.</p>
  
  <p>This seems to work, <em>unless</em> you Open or Close one of the collapsiblePanels on their own. As soon as that happens clicking the buttons does not do anything anymore.</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;h:form prependId="false"&gt;
  
    &lt;a4j:commandButton value="Open All"  actionListener="#{viewBean.doOpenAll}" render="c" /&gt;
    &lt;a4j:commandButton value="Close All" actionListener="#{viewBean.doCloseAll}" render="c" style="margin-left: 10px;" /&gt;
  
    &lt;a4j:outputPanel id="c"&gt;
      &lt;a4j:repeat id="repeat" value="#{viewBean.items}" var="item"&gt;
        &lt;rich:collapsiblePanel id="panel" expanded="#{item.expanded}"&gt;
            &lt;h:outputLabel id="text_lbl" value="text" /&gt;
          &lt;h:inputText id="text" value="#{item.text}" /&gt;
        &lt;/rich:collapsiblePanel&gt;
      &lt;/a4j:repeat&gt;
    &lt;/a4j:outputPanel&gt;
  
  &lt;/h:form&gt;
  </code></pre>
  
  <p>I have published <a href="https://github.com/chriseverty/collapsiblepanel" rel="nofollow">a project on github</a> so that you can try around with the code.</p>
  
  <p>For completeness here are the two backing beans</p>
  
  <pre class="lang-java prettyprint-override"><code>@ViewScoped
  @ManagedBean
  public class ViewBean implements Serializable {
      static final Logger LOG = LoggerFactory.getLogger(ViewBean.class);
  
      private static final long serialVersionUID = -6239437588285327644L;
      private List&lt;ListItem&gt; items;
  
      public ViewBean() {
          items = new ArrayList&lt;ListItem&gt;(10);
          for (int i = 0; i &lt; 10; i++) {
              items.add(new ListItem("item " + i));
          }
      }
  
      public void doOpenAll() {
          LOG.debug("open all");
          for (ListItem item : items) {
              item.setExpanded(true);
          }
      }
  
      public void doCloseAll() {
          LOG.debug("close all");
          for (ListItem item : items) {
              item.setExpanded(false);
          }
      }
  
      public List&lt;ListItem&gt; getItems() {
          return items;
      }
  
  }
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>public class ListItem {
  
      private boolean expanded;
      private String text;
  
      public ListItem(String text) {
          super();
          this.text = text;
      }
  
      public boolean isExpanded() {
          return expanded;
      }
  
      public void setExpanded(boolean expanded) {
          this.expanded = expanded;
      }
  
      public String getText() {
          return text;
      }
  
      public void setText(String text) {
          this.text = text;
      }
  
  }
  </code></pre>