Dashboard > People > codesmell > 2008 > Mai > 11 > Wicket Breadcrumbs
  codesmell Log In   View a printable version of the current page.  
  Wicket Breadcrumbs
Added by Uwe Schaefer, last edited by Uwe Schaefer on Mai 11, 2008
Labels: 

This template for using a Breadcrumb-like Navigation really shows the beauty of stateful pages that separate wicket from those countless template-based frameworks.

/**
 * Provides a list of Breadcrumbs. THIS IS ONLY A TEMPLATE. DO NOT USE UNMODIFIED 
 * @author igor vaynberg 
 */
public abstract class BreadcrumbPage extends Page
{
    private List<BreadcrumbPage> history = new ArrayList<BreadcrumbPage>();

    public BreadcrumbPage()
    {
        add(new ListView("history", new PropertyModel(this, "history"))
        {
            @Override
            protected void populateItem(final ListItem item)
            {
                final Link link = new Link("link", item.getModel())
                {
                    @Override
                    protected void onClick()
                    {
                        getRequestCycle().setResponsePage((BreadcrumbPage) getModelObject());
                    }
                };
                link.add(new Label("title", ((BreadcrumbPage) item.getModelObject()).getTitle()));
            }
        });
    }

    public BreadcrumbPage(final BreadcrumbPage crumb)
    {
        this();
        this.history.add(crumb); // FIXME you´ll want to limit the list´s size
    }

    protected abstract IModel getTitle();
}
Mai 2008
Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
             

Wicket SecureForm
Wicket DropDownIdChoice

This site is powered by a free Atlassian Confluence Personal Server License. Evaluate Confluence for your organisation or read more about Confluence licensing here.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request - Contact Administrators