Example usage for org.apache.wicket.markup.html WebPage render

List of usage examples for org.apache.wicket.markup.html WebPage render

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html WebPage render.

Prototype

public final void render() 

Source Link

Document

Render this component and all its children.

Usage

From source file:gr.abiss.calipso.wicket.BasePanel.java

License:Open Source License

public String renderPageHtmlInNewRequestCycle(Class<? extends WebPage> pageClass,
        PageParameters pageParameters) {
    RequestCycle requestCycle = null;//from   w w w .j  av  a 2 s. c  om
    String html = null;
    try {
        BufferedWebResponse bufferedWebResponse = new BufferedWebResponse(null);

        //      
        // call constructor with page parameters
        Constructor constructor = pageClass.getConstructor(new Class[] { PageParameters.class });
        // obtain page instance
        WebPage webPage = (WebPage) constructor.newInstance(pageParameters);
        webPage.getRequestCycle().setResponse(bufferedWebResponse);
        webPage.render();
        html = bufferedWebResponse.getText().toString();
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        if (requestCycle != null) {
            requestCycle.getResponse().close();
        }
    }
    return html;

}

From source file:org.apache.syncope.client.console.panels.AnyPanel.java

License:Apache License

protected Panel getDirectoryPanel(final String id) {
    final Panel panel;
    final String fiql;
    switch (anyTypeTO.getKind()) {
    case USER:/*from  w  ww . j a v  a  2s.c o  m*/
        fiql = SyncopeClient.getUserSearchConditionBuilder().is("key").notNullValue().query();
        final UserTO userTO = new UserTO();
        userTO.setRealm(realmTO.getFullPath());
        panel = new UserDirectoryPanel.Builder(anyTypeClassRestClient.list(anyTypeTO.getClasses()),
                anyTypeTO.getKey(), pageRef).setRealm(realmTO.getFullPath()).setFiltered(true).setFiql(fiql)
                        .setWizardInModal(true).addNewItemPanelBuilder(FormLayoutInfoUtils.instantiate(userTO,
                                anyTypeTO.getClasses(), formLayoutInfo.getLeft(), pageRef))
                        .build(id);
        MetaDataRoleAuthorizationStrategy.authorize(panel, WebPage.RENDER, StandardEntitlement.USER_SEARCH);
        break;

    case GROUP:
        fiql = SyncopeClient.getGroupSearchConditionBuilder().is("key").notNullValue().query();
        final GroupTO groupTO = new GroupTO();
        groupTO.setRealm(realmTO.getFullPath());
        panel = new GroupDirectoryPanel.Builder(anyTypeClassRestClient.list(anyTypeTO.getClasses()),
                anyTypeTO.getKey(), pageRef).setRealm(realmTO.getFullPath()).setFiltered(true).setFiql(fiql)
                        .setWizardInModal(true).addNewItemPanelBuilder(FormLayoutInfoUtils.instantiate(groupTO,
                                anyTypeTO.getClasses(), formLayoutInfo.getMiddle(), pageRef))
                        .build(id);
        // list of group is available to all authenticated users
        break;

    case ANY_OBJECT:
        fiql = SyncopeClient.getAnyObjectSearchConditionBuilder(anyTypeTO.getKey()).is("key").notNullValue()
                .query();
        final AnyObjectTO anyObjectTO = new AnyObjectTO();
        anyObjectTO.setRealm(realmTO.getFullPath());
        anyObjectTO.setType(anyTypeTO.getKey());
        panel = new AnyObjectDirectoryPanel.Builder(anyTypeClassRestClient.list(anyTypeTO.getClasses()),
                anyTypeTO.getKey(), pageRef).setRealm(realmTO.getFullPath()).setFiltered(true).setFiql(fiql)
                        .setWizardInModal(true)
                        .addNewItemPanelBuilder(
                                FormLayoutInfoUtils.instantiate(anyObjectTO, anyTypeTO.getClasses(),
                                        formLayoutInfo.getRight().get(anyTypeTO.getKey()), pageRef))
                        .build(id);
        MetaDataRoleAuthorizationStrategy.authorize(panel, WebPage.RENDER,
                AnyEntitlement.SEARCH.getFor(anyTypeTO.getKey()));
        break;

    default:
        panel = new LabelPanel(id, null);
    }
    return panel;
}

From source file:org.apache.syncope.client.console.panels.GroupDirectoryPanel.java

License:Apache License

protected GroupDirectoryPanel(final String id, final Builder builder, final boolean wizardInModal) {
    super(id, builder, wizardInModal);

    typeExtensionsModal.size(Modal.Size.Large);
    addOuterObject(typeExtensionsModal);
    setWindowClosedReloadCallback(typeExtensionsModal);
    typeExtensionsModal.addSubmitButton();

    addOuterObject(membersModal);/*from w w w .j a v a 2  s . c o  m*/
    membersModal.size(Modal.Size.Large);

    templates = new MembersTogglePanel(page.getPageReference()) {

        private static final long serialVersionUID = -8765794727538618705L;

        @Override
        protected Serializable onApplyInternal(final GroupTO groupTO, final String type,
                final AjaxRequestTarget target) {

            final AnyTypeRestClient typeRestClient = new AnyTypeRestClient();
            final AnyTypeClassRestClient classRestClient = new AnyTypeClassRestClient();

            final AnyTypeTO anyTypeTO = typeRestClient.read(type);

            ModalPanel panel = new AnyPanel(BaseModal.CONTENT_ID, anyTypeTO, null, null, false, pageRef) {

                private static final long serialVersionUID = 1L;

                @Override
                protected Panel getDirectoryPanel(final String id) {

                    final Panel panel;

                    if (AnyTypeKind.USER.name().equals(type)) {
                        String query = SyncopeClient.getUserSearchConditionBuilder()
                                .and(SyncopeClient.getUserSearchConditionBuilder().inGroups(groupTO.getKey()),
                                        SyncopeClient.getUserSearchConditionBuilder().is("key").notNullValue())
                                .query();

                        panel = new UserDirectoryPanel.Builder(classRestClient.list(anyTypeTO.getClasses()),
                                anyTypeTO.getKey(), pageRef).setRealm("/").setFiltered(true).setFiql(query)
                                        .disableCheckBoxes()
                                        .addNewItemPanelBuilder(FormLayoutInfoUtils
                                                .instantiate(new UserTO(), anyTypeTO.getClasses(),
                                                        FormLayoutInfoUtils.fetch(typeRestClient.list())
                                                                .getLeft(),
                                                        pageRef),
                                                false)
                                        .setWizardInModal(false).build(id);

                        MetaDataRoleAuthorizationStrategy.authorize(panel, WebPage.RENDER,
                                StandardEntitlement.USER_SEARCH);
                    } else {
                        String query = SyncopeClient.getAnyObjectSearchConditionBuilder(type)
                                .and(SyncopeClient.getUserSearchConditionBuilder().inGroups(groupTO.getKey()),
                                        SyncopeClient.getUserSearchConditionBuilder().is("key").notNullValue())
                                .query();

                        panel = new AnyObjectDirectoryPanel.Builder(
                                classRestClient.list(anyTypeTO.getClasses()), anyTypeTO.getKey(), pageRef)
                                        .setRealm("/").setFiltered(true).setFiql(query).disableCheckBoxes()
                                        .addNewItemPanelBuilder(FormLayoutInfoUtils.instantiate(
                                                new AnyObjectTO(), anyTypeTO.getClasses(),
                                                FormLayoutInfoUtils.fetch(typeRestClient.list()).getRight()
                                                        .get(type),
                                                pageRef), false)
                                        .setWizardInModal(false).build(id);

                        MetaDataRoleAuthorizationStrategy.authorize(panel, WebPage.RENDER,
                                AnyEntitlement.SEARCH.getFor(anyTypeTO.getKey()));
                    }

                    return panel;
                }
            };

            membersModal.header(new StringResourceModel("group.members", GroupDirectoryPanel.this,
                    Model.of(Pair.of(groupTO, type))));

            membersModal.setContent(panel);
            membersModal.show(true);
            target.add(membersModal);

            return null;
        }
    };

    addOuterObject(templates);
}

From source file:org.apache.syncope.client.console.panels.RoleDirectoryPanel.java

License:Apache License

@Override
protected List<IColumn<RoleTO, String>> getColumns() {
    final List<IColumn<RoleTO, String>> columns = new ArrayList<>();

    columns.add(new PropertyColumn<RoleTO, String>(new ResourceModel("key"), "key", "key"));
    columns.add(new PropertyColumn<RoleTO, String>(new ResourceModel("entitlements", "Entitlements"), null,
            "entitlements"));
    columns.add(new PropertyColumn<RoleTO, String>(new ResourceModel("realms"), null, "realms"));

    columns.add(new ActionColumn<RoleTO, String>(new ResourceModel("actions")) {

        private static final long serialVersionUID = -3503023501954863131L;

        @Override//from   ww  w .java2s .  c om
        public ActionLinksPanel<RoleTO> getActions(final String componentId, final IModel<RoleTO> model) {
            final ActionLinksPanel.Builder<RoleTO> panel = ActionLinksPanel.builder();

            panel.add(new ActionLink<RoleTO>() {

                private static final long serialVersionUID = -7978723352517770644L;

                @Override
                public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
                    final String query = SyncopeClient.getUserSearchConditionBuilder()
                            .and(SyncopeClient.getUserSearchConditionBuilder()
                                    .inRoles(model.getObject().getKey()),
                                    SyncopeClient.getUserSearchConditionBuilder().is("key").notNullValue())
                            .query();

                    final AnyTypeRestClient typeRestClient = new AnyTypeRestClient();
                    final AnyTypeClassRestClient classRestClient = new AnyTypeClassRestClient();

                    final AnyTypeTO anyTypeTO = typeRestClient.read(AnyTypeKind.USER.name());

                    ModalPanel panel = new AnyPanel(BaseModal.CONTENT_ID, anyTypeTO, null, null, false,
                            pageRef) {

                        private static final long serialVersionUID = 1L;

                        @Override
                        protected Panel getDirectoryPanel(final String id) {
                            final Panel panel = new UserDirectoryPanel.Builder(
                                    classRestClient.list(anyTypeTO.getClasses()), anyTypeTO.getKey(), pageRef)
                                            .setRealm("/").setFiltered(true).setFiql(query).disableCheckBoxes()
                                            .addNewItemPanelBuilder(FormLayoutInfoUtils
                                                    .instantiate(new UserTO(), anyTypeTO.getClasses(),
                                                            FormLayoutInfoUtils.fetch(typeRestClient.list())
                                                                    .getLeft(),
                                                            pageRef),
                                                    false)
                                            .setWizardInModal(false).build(id);

                            MetaDataRoleAuthorizationStrategy.authorize(panel, WebPage.RENDER,
                                    StandardEntitlement.USER_SEARCH);

                            return panel;
                        }
                    };

                    membersModal
                            .header(new StringResourceModel("role.members", RoleDirectoryPanel.this, model));
                    membersModal.setContent(panel);
                    membersModal.show(true);
                    target.add(membersModal);
                }
            }, ActionLink.ActionType.MEMBERS, StandardEntitlement.USER_SEARCH).add(new ActionLink<RoleTO>() {

                private static final long serialVersionUID = -7978723352517770644L;

                @Override
                public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
                    send(RoleDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>(
                            new RoleWrapper(new RoleRestClient().read(model.getObject().getKey())), target));
                }
            }, ActionLink.ActionType.EDIT, StandardEntitlement.ROLE_READ).add(new ActionLink<RoleTO>() {

                private static final long serialVersionUID = -7978723352517770644L;

                @Override
                public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
                    final RoleTO clone = SerializationUtils.clone(model.getObject());
                    clone.setKey(null);
                    send(RoleDirectoryPanel.this, Broadcast.EXACT,
                            new AjaxWizard.NewItemActionEvent<>(new RoleWrapper(clone), target));
                }
            }, ActionLink.ActionType.CLONE, StandardEntitlement.ROLE_CREATE).add(new ActionLink<RoleTO>() {

                private static final long serialVersionUID = -7978723352517770644L;

                @Override
                public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
                    ConsoleLayoutInfoModal.ConsoleLayoutInfo info = new ConsoleLayoutInfoModal.ConsoleLayoutInfo(
                            model.getObject().getKey());
                    info.setContent(restClient.readConsoleLayoutInfo(model.getObject().getKey()));

                    utilityModal.header(new ResourceModel("console.layout.info", "JSON Content"));
                    utilityModal.setContent(new ConsoleLayoutInfoModal(utilityModal, info, pageRef));
                    utilityModal.show(true);
                    target.add(utilityModal);
                }
            }, ActionLink.ActionType.LAYOUT_EDIT, StandardEntitlement.ROLE_UPDATE)
                    .add(new ActionLink<RoleTO>() {

                        private static final long serialVersionUID = -7978723352517770644L;

                        @Override
                        public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
                            try {
                                restClient.delete(model.getObject().getKey());
                                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                                target.add(container);
                            } catch (SyncopeClientException e) {
                                LOG.error("While deleting object {}", model.getObject().getKey(), e);
                                SyncopeConsoleSession.get()
                                        .error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName()
                                                : e.getMessage());
                            }
                            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
                        }
                    }, ActionLink.ActionType.DELETE, StandardEntitlement.ROLE_DELETE);

            return panel.build(componentId);
        }

        @Override
        public ActionLinksPanel<RoleTO> getHeader(final String componentId) {
            final ActionLinksPanel.Builder<RoleTO> panel = ActionLinksPanel.builder();

            return panel.add(new ActionLink<RoleTO>() {

                private static final long serialVersionUID = -7978723352517770644L;

                @Override
                public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
                    if (target != null) {
                        target.add(container);
                    }
                }
            }, ActionLink.ActionType.RELOAD, StandardEntitlement.ROLE_LIST).build(componentId);
        }
    });

    return columns;
}