Example usage for org.apache.wicket.markup.html.link Link setAnchor

List of usage examples for org.apache.wicket.markup.html.link Link setAnchor

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.link Link setAnchor.

Prototype

public Link<T> setAnchor(Component anchor) 

Source Link

Document

Sets an anchor component.

Usage

From source file:jp.xet.uncommons.wicket.gp.SimplePagingNavigator.java

License:Apache License

@Override
protected PagingNavigation newNavigation(String id, IPageable pageable, IPagingLabelProvider labelProvider) {
    PagingNavigation pg = new PagingNavigation("navigation", pageable, labelProvider) {

        @Override//from   w w  w.  ja  v  a2s  .  c  o  m
        protected Link<Void> newPagingNavigationLink(String id, IPageable pageable, int pageIndex) {
            @SuppressWarnings("unchecked")
            Link<Void> lnk = (Link<Void>) super.newPagingNavigationLink(id, pageable, pageIndex);
            if (isAnchorSelf()) {
                lnk.setAnchor(SimplePagingNavigator.this);
            }
            return lnk;
        }
    };
    pg.setViewSize(getViewsize());
    return pg;
}

From source file:org.antbear.jee.wicket.PlainPage.java

License:Apache License

public PlainPage(final PageParameters parameters) {
    super(parameters);

    add(new FeedbackPanel("feedback").setOutputMarkupId(true));
    StringValue linkId = parameters.get(PAGE_PARAM_LINK_ID);
    if (!linkId.isEmpty()) {
        info("You called us with the page parameter " + PAGE_PARAM_LINK_ID + " and value " + linkId.toString());
    }// ww w.ja v a2  s .c o  m

    final Form<?> form = new Form<Void>("form");
    add(form);

    // The model of the ListView is a List<Integer>
    form.add(new PropertyListView<Integer>("list", getList()) {
        private static final long serialVersionUID = 1L;

        // The model of a ListItem<Integer> is one Integer of the ListView<Integer>
        @Override
        protected void populateItem(ListItem<Integer> item) {
            // The Clou: set the markupId of the item to be the integer of our list
            item.setMarkupId(item.getDefaultModelObjectAsString());
            item.setOutputMarkupId(true);

            PageParameters parameters = new PageParameters();
            parameters.add(PAGE_PARAM_LINK_ID, item.getModelObject());

            // Create link and its text
            Link<Integer> link = new BookmarkablePageLink<Integer>("link", getWebPage().getClass(), parameters);
            link.setAnchor(item); // The anchor of the link now refers to the component of the ListItem (i.e. <li />)
            Component text = new Label("text", item.getDefaultModelObjectAsString()).setRenderBodyOnly(true);

            item.add(link.add(text));
        }
    });
}