Example usage for org.apache.wicket Component RENDER

List of usage examples for org.apache.wicket Component RENDER

Introduction

In this page you can find the example usage for org.apache.wicket Component RENDER.

Prototype

Action RENDER

To view the source code for org.apache.wicket Component RENDER.

Click Source Link

Document

Action used with IAuthorizationStrategy to determine whether a component and its children are allowed to be rendered.

Usage

From source file:org.devgateway.toolkit.forms.wicket.page.BasePage.java

License:Open Source License

protected NavbarButton<EditUserPage> newAccountMenu() {
    PageParameters pageParametersForAccountPage = new PageParameters();
    Person person = SecurityUtil.getCurrentAuthenticatedPerson();
    // account menu
    Model<String> account = null;
    if (person != null) {
        account = Model.of(person.getFirstName());
        pageParametersForAccountPage.add(WebConstants.PARAM_ID, person.getId());
    }/*from  www .j  a  v  a 2s  .c o m*/

    NavbarButton<EditUserPage> accountMenu = new NavbarButton<>(EditUserPage.class,
            pageParametersForAccountPage, account);
    accountMenu.setIconType(GlyphIconType.user);
    MetaDataRoleAuthorizationStrategy.authorize(accountMenu, Component.RENDER,
            SecurityConstants.Roles.ROLE_USER);
    return accountMenu;
}

From source file:org.devgateway.toolkit.forms.wicket.page.BasePage.java

License:Open Source License

protected NavbarButton<Homepage> newHomeMenu() {
    // home/*from   w  ww  .  j a v a2s .  c om*/
    NavbarButton<Homepage> homeMenu = new NavbarButton<>(Homepage.class, this.getPageParameters(),
            new ResourceModel("home"));
    homeMenu.setIconType(GlyphIconType.home);
    MetaDataRoleAuthorizationStrategy.authorize(homeMenu, Component.RENDER, SecurityConstants.Roles.ROLE_USER);
    return homeMenu;
}

From source file:org.devgateway.toolkit.forms.wicket.page.BasePage.java

License:Open Source License

protected NavbarButton<ListMyDashboardsPage> newMyDashboardsMenu() {
    // home//from   www  .j  a v  a2s .c o m
    NavbarButton<ListMyDashboardsPage> menu = new NavbarButton<>(ListMyDashboardsPage.class,
            this.getPageParameters(), new ResourceModel("mydashboards"));
    menu.setIconType(GlyphIconType.filter);
    MetaDataRoleAuthorizationStrategy.authorize(menu, Component.RENDER,
            SecurityConstants.Roles.ROLE_PROCURING_ENTITY);
    return menu;
}

From source file:org.devgateway.toolkit.forms.wicket.page.BasePage.java

License:Open Source License

protected NavbarDropDownButton newAdminMenu() {

    // admin menu
    NavbarDropDownButton adminMenu = new NavbarDropDownButton(
            new StringResourceModel("navbar.admin", this, null)) {
        private static final long serialVersionUID = 1L;

        @Override//from   w  w w  .ja  v a 2s.c om
        protected List<AbstractLink> newSubMenuButtons(final String arg0) {
            List<AbstractLink> list = new ArrayList<>();
            list.add(new MenuBookmarkablePageLink<ListGroupPage>(ListGroupPage.class, null,
                    new StringResourceModel("navbar.groups", this, null))
                            .setIconType(FontAwesomeIconType.tags));

            list.add(new MenuBookmarkablePageLink<ListTestFormPage>(ListTestFormPage.class, null,
                    new StringResourceModel("navbar.testcomponents", this, null))
                            .setIconType(FontAwesomeIconType.android));

            list.add(new MenuBookmarkablePageLink<ListUserPage>(ListUserPage.class, null,
                    new StringResourceModel("navbar.users", this, null))
                            .setIconType(FontAwesomeIconType.users));

            list.add(new MenuBookmarkablePageLink<SpringEndpointsPage>(SpringEndpointsPage.class, null,
                    new StringResourceModel("navbar.springendpoints", this, null))
                            .setIconType(FontAwesomeIconType.anchor));

            list.add(new MenuBookmarkablePageLink<JminixRedirectPage>(JminixRedirectPage.class, null,
                    new StringResourceModel("navbar.jminix", this, null)).setIconType(FontAwesomeIconType.bug));

            // MenuBookmarkablePageLink<HALRedirectPage> halBrowserLink =
            // new MenuBookmarkablePageLink<HALRedirectPage>(
            // HALRedirectPage.class, null, new StringResourceModel(
            // "navbar.halbrowser", this, null)) {
            // private static final long serialVersionUID = 1L;
            //
            // @Override
            // protected void onComponentTag(ComponentTag tag) {
            // super.onComponentTag(tag);
            // tag.put("target", "_blank");
            // }
            // };
            // halBrowserLink.setIconType(FontAwesomeIconType.rss).setEnabled(true);

            // list.add(halBrowserLink);

            MenuBookmarkablePageLink<UIRedirectPage> uiBrowserLink = new MenuBookmarkablePageLink<UIRedirectPage>(
                    UIRedirectPage.class, null, new StringResourceModel("navbar.ui", this, null)) {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onComponentTag(final ComponentTag tag) {
                    super.onComponentTag(tag);
                    tag.put("target", "_blank");
                }
            };
            uiBrowserLink.setIconType(FontAwesomeIconType.dashboard).setEnabled(true);

            list.add(new MenuBookmarkablePageLink<Void>(EditAdminSettingsPage.class,
                    new StringResourceModel("navbar.adminSettings", BasePage.this, null))
                            .setIconType(FontAwesomeIconType.briefcase));

            list.add(new MenuBookmarkablePageLink<Void>(ListAllDashboardsPage.class,
                    new StringResourceModel("navbar.allDashboard", BasePage.this, null))
                            .setIconType(FontAwesomeIconType.filter));

            list.add(uiBrowserLink);

            return list;
        }
    };

    adminMenu.setIconType(GlyphIconType.cog);
    MetaDataRoleAuthorizationStrategy.authorize(adminMenu, Component.RENDER,
            SecurityConstants.Roles.ROLE_ADMIN);

    return adminMenu;
}

From source file:org.devgateway.toolkit.forms.wicket.page.Homepage.java

License:Open Source License

@Override
protected void onInitialize() {
    super.onInitialize();
    TransparentWebMarkupContainer manageUsersPanel = new TransparentWebMarkupContainer("manageUsers");
    MetaDataRoleAuthorizationStrategy.authorize(manageUsersPanel, Component.RENDER,
            SecurityConstants.Roles.ROLE_ADMIN);
    add(manageUsersPanel);//from  w ww.  j  a  va2 s.com

}

From source file:org.devgateway.toolkit.forms.wicket.page.user.EditUserPage.java

License:Open Source License

@Override
protected void onInitialize() {
    Person person = SecurityUtil.getCurrentAuthenticatedPerson();

    if (!SecurityUtil.isCurrentUserAdmin()) {
        if (person.getId() != getPageParameters().get(WebConstants.PARAM_ID).toLong()) {
            setResponsePage(getApplication().getHomePage());
        }//from   w w w  .jav  a2  s  .c o  m
    }

    super.onInitialize();

    userName.required();
    userName.getField().add(new UsernamePatternValidator());
    StringValue idPerson = getPageParameters().get(WebConstants.PARAM_ID);
    if (!idPerson.isNull()) {
        userName.getField().add(new UniqueUsernameValidator(idPerson.toLong()));
    } else {
        userName.getField().add(new UniqueUsernameValidator());
    }
    userName.setIsFloatedInput(true);
    editForm.add(userName);
    MetaDataRoleAuthorizationStrategy.authorize(userName, Component.ENABLE, SecurityConstants.Roles.ROLE_ADMIN);

    firstName.required();
    firstName.setIsFloatedInput(true);
    editForm.add(firstName);

    lastName.required();
    lastName.setIsFloatedInput(true);
    editForm.add(lastName);

    email.required();
    email.getField().add(EmailAddressValidator.getInstance());
    if (!idPerson.isNull()) {
        email.getField().add(new UniqueEmailAddressValidator(idPerson.toLong()));
    } else {
        email.getField().add(new UniqueEmailAddressValidator());
    }
    email.setIsFloatedInput(true);
    editForm.add(email);

    title.setIsFloatedInput(true);
    editForm.add(title);

    group.required();
    group.setIsFloatedInput(true);
    editForm.add(group);
    MetaDataRoleAuthorizationStrategy.authorize(group, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN);

    editForm.add(defaultDashboard);
    MetaDataRoleAuthorizationStrategy.authorize(defaultDashboard, Component.ENABLE,
            SecurityConstants.Roles.ROLE_ADMIN);

    roles.required();
    roles.getField().setOutputMarkupId(true);
    roles.setIsFloatedInput(true);
    editForm.add(roles);
    MetaDataRoleAuthorizationStrategy.authorize(roles, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN);

    // stop resetting the password fields each time they are rendered
    password.getField().setResetPassword(false);
    cpassword.getField().setResetPassword(false);
    if (SecurityUtil.isCurrentUserAdmin() && !SecurityUtil.isUserAdmin(compoundModel.getObject())
            && idPerson.isNull()) {
        // hide the change password checkbox and set it's model to true
        compoundModel.getObject().setChangePass(true);
        changePass.setVisibilityAllowed(false);
    } else {
        compoundModel.getObject().setChangePass(compoundModel.getObject().getChangePassword());
        password.getField().setEnabled(compoundModel.getObject().getChangePassword());
        cpassword.getField().setEnabled(compoundModel.getObject().getChangePassword());
    }

    changePass.setIsFloatedInput(true);
    editForm.add(changePass);

    password.getField().add(new PasswordPatternValidator());
    password.setOutputMarkupId(true);
    password.setIsFloatedInput(true);
    editForm.add(password);

    cpassword.setOutputMarkupId(true);
    cpassword.setIsFloatedInput(true);
    editForm.add(cpassword);

    editForm.add(new EqualPasswordInputValidator(password.getField(), cpassword.getField()));

    enabled.setIsFloatedInput(true);
    editForm.add(enabled);
    MetaDataRoleAuthorizationStrategy.authorize(enabled, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN);

    changePassword.setIsFloatedInput(true);
    editForm.add(changePassword);
    MetaDataRoleAuthorizationStrategy.authorize(changePassword, Component.RENDER,
            SecurityConstants.Roles.ROLE_ADMIN);

    MetaDataRoleAuthorizationStrategy.authorize(deleteButton, Component.RENDER,
            SecurityConstants.Roles.ROLE_ADMIN);
}

From source file:org.eknet.wicket.commons.components.navlist.ListItemWrapper.java

License:Apache License

private boolean isChildVisible(Component component) {
    if (component instanceof MarkupContainer) {
        MarkupContainer container = (MarkupContainer) component;
        Iterator<Component> iter = container.iterator();
        if (iter.hasNext()) {
            Component child = iter.next();
            return child.isVisible() && child.isActionAuthorized(Component.RENDER);
        }/*from w  w  w . j  a  v a  2  s  .c o  m*/
    }
    return true;
}

From source file:org.obiba.onyx.webapp.base.panel.MenuBuilder.java

License:Open Source License

private static void setPageview(Component c, MenuItem mi) {
    // Menu item will be displayed only if user has the roles to see the page
    AuthorizeInstantiation authorizationAnnotation = mi.getPage().getAnnotation(AuthorizeInstantiation.class);
    if (authorizationAnnotation != null) {
        String[] authorizedRoles = authorizationAnnotation.value();
        MetaDataRoleAuthorizationStrategy.authorize(c, Component.RENDER,
                StringUtil.stringArrayToString(authorizedRoles));
    }/*from   w w w .  j a  va2  s . com*/
}

From source file:org.wicketstuff.poi.excel.TableParser.java

License:Apache License

/**
 * Mock a request to table component and return its response.
 *
 * @param tableComponent/*from   w ww .  j  a  va 2s  .c  om*/
 * @return
 */
private BufferedWebResponse doRequest(Component tableComponent) {
    originalResponse = RequestCycle.get().getResponse();
    BufferedWebResponse mockResponse = new BufferedWebResponse(null);
    RequestCycle.get().setResponse(mockResponse);
    Application.get().getComponentPreOnBeforeRenderListeners().add(PathSetupListener.INSTANCE);
    Page page = tableComponent.getPage();
    page.startComponentRender(tableComponent);
    tableComponent.prepareForRender();
    tableComponent.render();
    return mockResponse;
}

From source file:org.wicketstuff.security.swarm.actions.SwarmActionFactoryTest.java

License:Apache License

/**
 * @see SwarmActionFactory#getAction(Action)
 *///from w  w w . j  a v a  2 s. com
public void testGetActionAction() {
    WaspAction action = factory.getAction(Component.RENDER);
    assertNotNull(action);
    assertEquals(factory.getAction(Render.class), action);
    assertEquals(factory.getAction("render"), action);

    Action wicketAction = new Action("inherit, render");
    action = factory.getAction(wicketAction);
    assertNotNull(action);
    assertEquals(factory.getAction(wicketAction.getName()), action);

    assertNull(factory.getAction((Action) null));
    assertNull(factory.getAction(new Action("foo")));
}