title: Java Wicket AjaxFallbackLink needing double click after becoming visible
body: <p>I have two containers, BEFORE and AFTER. When the page loads up, BEFORE is visible and AFTER is not.</p>
  
  <p>BEFORE contains an AjaxFallbackLink that redraws BEFORE and AFTER but makes BEFORE invisible and AFTER visible, i.e. a visibility trigger.</p>
  
  <p>I also have an AjaxFallbackLink inside AFTER that does the reverse: redraws BEFORE and AFTER but makes BEFORE visible and AFTER invisible.</p>
  
  <p>The problem: the link inside AFTER needs two clicks to have the panels redraw themselves when I should only need one. I've  set setOutputMarkupPlaceholderTag to true on every component I can find, but still I need two clicks on the AFTER link to have the panels redraw themselves.</p>
  
  <p>Is there a way to resolve this?</p>
  
  <p>Here's some (simplified) code:</p>
  
  <pre><code>private class ViewDatesFragment extends Fragment&lt;Campaign&gt; {
      private ViewDatesFragment(final MarkupContainer markupProvider) {
          super("flightNoDates", "viewDatesFragment", markupProvider);
          add(new AddDatesLink());
          setOutputMarkupPlaceholderTag(true);
      }
  
      private class AddDatesLink extends AjaxFallbackLink&lt;Campaign&gt; {
  
          private AddDatesLink() {
              super("addDates");
  
              add(new Label("startDate", "This is the start date").setOutputMarkupPlaceholderTag(true));
          setOutputMarkupPlaceholderTag(true);
          }
  
          @Override
          public void onClick(final AjaxRequestTarget target) {
              target.addComponent(viewDatesContainer.setVisible(false));
              target.addComponent(editDatesContainer.setVisible(true));            
      }
      }
  }
  
  private class EditDatesFragment extends Fragment&lt;Campaign&gt; {
  
      private EditDatesFragment(final MarkupContainer markupProvider) {
          super("flightDates", "editDatesFragment", markupProvider);
  
          add(new CancelDatesLink().setOutputMarkupPlaceholderTag(true));
          setOutputMarkupPlaceholderTag(true);
      }
  
      private class CancelDatesLink extends AjaxFallbackLink {
          private CancelDatesLink() {
              super("cancelDates");
              add(new Label("cancelDatesText", "cancel").setOutputMarkupPlaceholderTag(true));
              setOutputMarkupPlaceholderTag(true);
          }
  
          @Override
          public void onClick(final AjaxRequestTarget target) {
              target.addComponent(viewDatesContainer.setVisible(true));
              target.addComponent(editDatesContainer.setVisible(false));
          }
      }
  }
  </code></pre>