Example usage for org.apache.wicket.markup.html.link BookmarkablePageLink getPageClass

List of usage examples for org.apache.wicket.markup.html.link BookmarkablePageLink getPageClass

Introduction

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

Prototype

public final Class<? extends Page> getPageClass() 

Source Link

Document

Get the page class registered with the link

Usage

From source file:com.effectivemaven.centrepoint.web.AbstractPageWithStoreTest.java

License:Apache License

@SuppressWarnings("unchecked")
public void assertBookmarkablePageLink(String path, Class<?> expectedPageClass) {
    BookmarkablePageLink<String> pageLink = (BookmarkablePageLink<String>) wicketTester
            .getComponentFromLastRenderedPage(path);
    assert expectedPageClass.equals(pageLink.getPageClass());
}

From source file:com.effectivemaven.centrepoint.web.AbstractPageWithStoreTest.java

License:Apache License

@SuppressWarnings("unchecked")
public void assertBookmarkablePageLink(String path, Class<?> expectedPageClass, PageParameters expectedParams) {
    BookmarkablePageLink<String> pageLink = (BookmarkablePageLink<String>) wicketTester
            .getComponentFromLastRenderedPage(path);
    assert expectedPageClass.equals(pageLink.getPageClass());
    assert expectedParams.equals(pageLink.getPageParameters());
}

From source file:fiftyfive.wicket.util.ParameterSpecTest.java

License:Apache License

@Test
public void testCreateLink_indexed() {
    TestBean bean = new TestBean(1L, "foo");
    ParameterSpec builder = new ParameterSpec<TestBean>(TestPage.class, "id", "name");

    BookmarkablePageLink link = builder.createLink("bar", new Model(bean));
    this.tester.startComponent(link);

    Assert.assertEquals("bar", link.getId());
    Assert.assertEquals(TestPage.class, link.getPageClass());

    PageParameters params = link.getPageParameters();
    Assert.assertEquals(bean.getId(), params.get("id").toLongObject());
    Assert.assertEquals(bean.getName(), params.get("name").toString());
}

From source file:fiftyfive.wicket.util.ParameterSpecTest.java

License:Apache License

@Test
public void testCreateLink_named() {
    TestBean bean = new TestBean(1L, "foo");
    ParameterSpec builder = new ParameterSpec<TestBean>(TestPage.class);
    builder.registerParameter("beanId", "id");
    builder.registerParameter("beanName", "name");

    BookmarkablePageLink link = builder.createLink("bar", new Model(bean));
    this.tester.startComponent(link);

    Assert.assertEquals("bar", link.getId());
    Assert.assertEquals(TestPage.class, link.getPageClass());

    PageParameters params = link.getPageParameters();
    Assert.assertEquals(bean.getId(), params.get("beanId").toLongObject());
    Assert.assertEquals(bean.getName(), params.get("beanName").toString());
}

From source file:org.cast.isi.ISIApplication.java

License:Open Source License

/**
 * Method to call with any BookmarkablePageLink that will set appropriate PopupSettings
 * (or it can be extended to do other link configuration if necessary).
 * //from   ww  w. j a va2 s .  co  m
 * @param link BookmarkablePageLink
 */
public void setLinkProperties(BookmarkablePageLink<?> link) {
    if (GlossaryPage.class.isAssignableFrom(link.getPageClass())) {
        link.setPopupSettings(glossaryPopupSettings);
    } else if (Notebook.class.isAssignableFrom(link.getPageClass())) {
        link.setPopupSettings(notebookPopupSettings);
    } else if (Whiteboard.class.isAssignableFrom(link.getPageClass())) {
        link.setPopupSettings(whiteboardPopupSettings);
    } else if (TeacherNotesPopup.class.isAssignableFrom(link.getPageClass())) {
        link.setPopupSettings(teacherNotesPopupSettings);
    } else if (PeriodResponsePage.class.isAssignableFrom(link.getPageClass())) {
        link.setPopupSettings(periodResponsePopupSettings);
    } else if (AuthoredPopup.class.isAssignableFrom(link.getPageClass())) {
        link.setPopupSettings(authoredPopupSettings);
    }
}

From source file:org.devproof.portal.core.app.PortalSession.java

License:Apache License

/**
 * Whether an user has the right for this component
 *
 * @param component component/*from  w w w.  j  a  v  a  2  s  . co  m*/
 * @param action
 * @return true if the user has the right
 */
public boolean hasRight(Component component, Action action) {
    List<Right> allRights = rightService.getAllRights();
    if (component instanceof BookmarkablePageLink<?>) {
        /*
        * This will remove the links for pages where the user hasn't got
        * rights. If there exists a right starting with page.PageClassName,
        * the user must have the right to access the page!
        */
        BookmarkablePageLink<?> l = (BookmarkablePageLink<?>) component;
        Class<? extends Page> pageClass = l.getPageClass();
        return hasRight(pageClass, action);
    } else if (hasSecuredAnnotation(component.getClass())) {
        return evaluateSecuredAnnotation(component.getClass(), action);
    }
    // problem with tree table, i dont know why
    else if (!(component instanceof TreeTable)) {
        String rightName = RightConstants.COMPONENT_RIGHT_PREFIX
                + component.getPage().getClass().getSimpleName() + "." + component.getId();
        Right right = rightService.newRightEntity(rightName);
        if (allRights.contains(right)) {
            return hasRight(right);
        }

        rightName = RightConstants.GENERAL_RIGHT_PREFIX + component.getClass().getSimpleName();
        right = rightService.newRightEntity(rightName);
        if (allRights.contains(right)) {
            return hasRight(right);
        }
    }
    return true;
}

From source file:org.ronsmits.navigationpanel.NavigationPanel.java

License:Apache License

/**
 * Create the navigation list./*from   w ww  .j  av a  2 s.  c om*/
 * @param builder the initialized builder
 */
public NavigationPanel(Builder builder) {

    super(builder.id);
    RepeatingView rv = new RepeatingView("menuItems");

    for (BookmarkablePageLink<?> link : builder.links) {
        boolean isActive = link.getPageClass().equals(builder.activePage.getClass());
        rv.add(new MenuItem(rv.newChildId(), link, isActive));
    }
    add(rv);
}