title: How can I hide a DatePicker icon when its DateTextField is hidden?
body: <p>I'm using a <code>DatePicker</code> (<code>org.apache.wicket.extensions.yui.calendar.DatePicker</code> &#8212; <a href="http://wicket.apache.org/apidocs/1.4/org/apache/wicket/extensions/yui/calendar/DatePicker.html" rel="nofollow">Javadoc</a>) in a form. The form consists of two fields. The first field is a dropdown, and the second changes dynamically based on the first. If "text" is selected, a textbox comes up; if "list" is selected, a dropdown menu comes up; and if "date" is selected, a date picker and associated field come up.</p>
  
  <p>Here's a simplified version of my current code:</p>
  
  <pre><code>DateTextField dateField = new DateTextField("dateField", // ...
  DatePicker datePicker = new DatePicker();
  dateField.add(datePicker);
  
  fieldOne.add(new OnChangeAjaxBehavior() {
      protected void onUpdate(AjaxRequestTarget target) {
          if (fieldOne.equalsIgnoreCase("list"))
          {
              dateField.setVisible(false);
              // datePicker.setVisible(false); // This line is impossible
              listField.setVisible(true);
              textField.setVisible(false);
          }
          else if { /* similar visibility settings for dates and text */ }
      }
  });
  </code></pre>
  
  <p>The form currently works properly for changing <em>to</em> the date picker. The problem arises when date is selected and then the user selects something else. The date <em>field</em> disappears, but the date <em>picker</em> remains on the screen. Unfortunately, it doesn't seem to have a <code>setVisible()</code> method, or any equivalent. In fact, it's not even a true Wicket <code>Component</code>.</p>
  
  <p>How can I make them appear/disappear together? If I can't set the picker's visibility directly, can I tie it to the field's visibility somehow?</p>