title: Hiding a component in Wicket
body: <p>I have a component inside an <code>&lt;a/&gt;</code> tag that opens a popup window on click. It's an "add to favourite" link which works on KML files. My KML file has a field named "favourite[boolean]". Now I'd like to hide or show my "add to favourite" link. The KML list is generated with a table:</p>
  
  <pre><code>public class CustomTracksAjaxDataTable&lt;T&gt; extends CustomAjaxDataTable&lt;T&gt; {
      public CustomTracksAjaxDataTable(String id, List&lt;IColumn&lt;T&gt;&gt; iColumns,
        ISortableDataProvider&lt;T&gt; tiSortableDataProvider, int rowsPerPage) {
          super(id, iColumns, tiSortableDataProvider, rowsPerPage);
      }
  
      protected void onEventHandler(AjaxRequestTarget ajaxRequestTarget,
        KMLFile file) {
          setKMLData(file); // it just update map, dont care about it
          add(new FavouriteStarIconState(file.isSaved()));
      }
  }
  </code></pre>
  
  <p>I tried to add a behavior thus:</p>
  
  <pre><code>public class FavouriteStarIconState extends AbstractDefaultAjaxBehavior {
      private boolean isFavourite;
  
      public FavouriteStarIconState(boolean isFavourite) {
          super();
          this.isFavourite = isFavourite;
      }
  
      @Override
      protected void respond(AjaxRequestTarget target) {
          if (isFavourite) {
              target.appendJavascript("jQuery('.map_container_star').css(
                {'display' : 'none' });");
          } else {
              target.appendJavascript("jQuery('.map_container_star').css(
                {'display' : 'block' });");
          }
      }
  
      @Override
      public void renderHead(IHeaderResponse response) {
          response.renderOnLoadJavascript(getCallbackScript().toString());
      }
  }
  </code></pre>
  
  <p>The part of the HTML containing the component:</p>
  
  <pre><code>&lt;div id="map_container"&gt;
      &lt;a wicket:id="favourite_star" class="map_container_star"&gt;&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This isn't working. I got the same result with <code>component.setVisible(false)</code>. How can I get hiding to work?</p>