title: Wicket container that is hidden when all its child components are hidden
body: <p>I have a block level element, a container, that should be hidden when <em>all</em> its child Wicket elements (buttons) are hidden.  In other words, if <em>any</em> child button is visible, the container should be visible.</p>
  
  <p>Earlier one of the buttons was always visible if any buttons were, so I used that button to control the visibility of a <code>&lt;wicket:enclosure&gt;</code>, handling all of this purely on HTML side.</p>
  
  <p>Now, the specs have changed so that the buttons can be hidden/visible independently, so a simple enclosure won't work anymore (I think).</p>
  
  <p>I got it working with something like this:</p>
  
  <p>HTML: </p>
  
  <pre><code>&lt;wicket:container wicket:id="downloadButtons"&gt;
       &lt;wicket:message key="download.foo.bar"/&gt;:
       &lt;input type="button" wicket:id="excelDownloadButton" wicket:message="value:download.excel"/&gt;
       &lt;input type="button" wicket:id="textDownloadButton" wicket:message="value:download.text"/&gt;
       &lt;!-- etc ... --&gt;
  &lt;/wicket:container&gt;
  </code></pre>
  
  <p>Java:</p>
  
  <pre><code>WebMarkupContainer container = new WebMarkupContainer("downloadButtons");
  
  // ... add buttons to container ...
  
  boolean showContainer = false;
  Iterator&lt;? extends Component&gt; it = container.iterator();
  while (it.hasNext()) {
      if (it.next().isVisible()) {
          showContainer = true;
          break;
      }
  }
  addOrReplace(container.setVisible(showContainer));
  </code></pre>
  
  <p>But the Java side is now kind of verbose and ugly, and I was thinking <strong>there's probably be a cleaner way to do the same thing</strong>. Is there? Can you somehow "automatically" hide a container (with all its additional markup) when none of its child components are visible?</p>
  
  <p>(Wicket 1.4, if it matters.)</p>