Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
wicket-joint-core
wicket-joint-example
README.md
pom.xml

README.md

Wicket Example

HomePage.java

@Joint(id = "Home")
@Navigation(navRegistryIds = {"nav.main","nav.home.menu"})
@Export({Viewable.class, Navigatable.class})
public class HomePage extends WebPage implements Viewable,Navigatable {
...
}

NavPanel.java

@Joint(id="navPanel")
public class NavPanel extends Panel {
    private HierarchicalRegistry<? extends Navigatable> nav;

    public NavPanel(String id, HierarchicalRegistry<Navigatable> nav) {
        super(id);
        this.nav = nav;
        String registryName = nav.getClass().getName();
        if (nav.getClass().isAnnotationPresent(Joint.class)) {
            registryName = nav.getClass().getAnnotation(Joint.class).id();
        }
        add(new Label("navContext", registryName));
        add(new NavList(
                "navList",
                new ArrayList<Class<? extends Navigatable>>(nav.getJoints())));
    }
}

NavList.java

public class NavList extends ListView<Class<? extends Navigatable>> {

    public NavList(String id,
            List<Class<? extends Navigatable>> list) {
        super(id, list);

    }

    @Override
    protected void populateItem(ListItem<Class<? extends Navigatable>> item) {

        Link link = new BookmarkablePageLink("navLink",
                item.getModelObject());
        Object obj = null;
        try {
            obj =
                    item.getModelObject().getAnnotation(Navigation.class).labeler().newInstance();
        } catch (InstantiationException ex) {
            Exceptions.printStackTrace(ex);
        } catch (IllegalAccessException ex) {
            Exceptions.printStackTrace(ex);
        }
        /*
         * Still need a label
         */
        String label = item.getModelObject().getName();

        if (obj != null && obj instanceof Labeler) {
            Labeler navModel = (Labeler) obj;
            label = navModel.getLabel(JointLookup.getJointId(item.getModelObject()));
        }
        link.add(new Label("navLabel", label));
        item.add(link);
    }
}