Java Code Examples for org.apache.wicket.markup.html.link.Link#setModelObject()

The following examples show how to use org.apache.wicket.markup.html.link.Link#setModelObject() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VisibilityAndSortToggler.java    From oodt with Apache License 2.0 4 votes vote down vote up
/**
 * @param id
 */
public VisibilityAndSortToggler(String id, String showLinkId,
    String hideLinkId, String sortLinkId, String unsortLinkId, String moreId,
    final ListModel model) {
  super(id, showLinkId, hideLinkId, moreId, model);

  Link<Link> sortLink;
  Link<Link> unsortLink = null;

  sortLink = new Link<Link>(sortLinkId, new Model<Link>(null)) {
    /*
     * (non-Javadoc)
     * 
     * @see org.apache.wicket.markup.html.link.Link#onClick()
     */
    @Override
    public void onClick() {
      Vector obj = (Vector) model.getObject();
      sortByStatus(obj);
      model.setObject(obj);
      getModelObject().setVisible(true);
      setVisible(false);
    }
  };

  unsortLink = new Link<Link>(unsortLinkId, new Model<Link>(sortLink)) {
    /*
     * (non-Javadoc)
     * 
     * @see org.apache.wicket.markup.html.link.Link#onClick()
     */
    @Override
    public void onClick() {
      Vector obj = (Vector) model.getObject();
      sortByName(obj);
      model.setObject(obj);
      getModelObject().setVisible(true);
      setVisible(false);
    }
  };

  unsortLink.setVisible(false);
  sortLink.setModelObject(unsortLink);
  unsortLink.setModelObject(sortLink);

  add(sortLink);
  add(unsortLink);

}
 
Example 2
Source File: VisibilityToggler.java    From oodt with Apache License 2.0 4 votes vote down vote up
/**
 * @param id
 */
public VisibilityToggler(String id, String showLinkId, String hideLinkId,
    String moreId, final ListModel model) {
  super(id, model);

  Link<Link> showLink;
  Link<Link> hideLink = null;
  final Vector allStatusList = (Vector) ((Vector) model.getObject()).clone();

  // subset the model
  model.setObject(subsetModelObject(model.getObject()));
  final WebMarkupContainer moreComponent = new WebMarkupContainer(moreId);
  add(moreComponent);

  showLink = new Link<Link>(showLinkId, new Model<Link>(null)) {
    /*
     * (non-Javadoc)
     * 
     * @see org.apache.wicket.markup.html.link.Link#onClick()
     */
    @Override
    public void onClick() {
      Vector obj = (Vector) model.getObject();
      obj.clear();
      obj.addAll(allStatusList);
      model.setObject(obj);
      moreComponent.setVisible(false);
      getModelObject().setVisible(true);
      setVisible(false);
    }
  };

  hideLink = new Link<Link>(hideLinkId, new Model<Link>(showLink)) {
    /*
     * (non-Javadoc)
     * 
     * @see org.apache.wicket.markup.html.link.Link#onClick()
     */
    @Override
    public void onClick() {
      Vector obj = (Vector) model.getObject();
      obj.clear();
      obj.addAll(getTopN(allStatusList, 3));
      model.setObject(obj);
      getModelObject().setVisible(true);
      setVisible(false);
      moreComponent.setVisible(true);
    }
  };

  hideLink.setVisible(false);
  showLink.setModelObject(hideLink);
  hideLink.setModelObject(showLink);

  add(showLink);
  add(hideLink);
}