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

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

Introduction

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

Prototype

public MarkupContainer add(final Component... children) 

Source Link

Document

Adds the child component(s) to this container.

Usage

From source file:fiftyfive.wicket.test.WicketTestUtils.java

License:Apache License

/**
 * A variation of/*  w  ww. j  a va  2s.com*/
 * {@link #startComponentWithXHtml(WicketTester,Component,String) startComponentWithXHtml()}
 * that accepts {@link PageParameters}. These page parameters are passed to
 * the page that wraps the component under test.
 * 
 * @since 2.0.4
 */
public static void startComponentWithXHtml(WicketTester tester, PageParameters parameters, Component c,
        final String markup) {
    WebPage page = new PageWithInlineMarkup(
            String.format(
                    "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
                            + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">%n"
                            + "<html xmlns=\"http://www.w3.org/1999/xhtml\" " + "xml:lang=\"en\" lang=\"en\">%n"
                            + "<head>%n  <title>untitled</title>%n</head>%n" + "<body>%n%s%n</body>%n</html>",
                    markup),
            parameters);
    page.add(c);
    tester.startPage(page);
}

From source file:fiftyfive.wicket.test.WicketTestUtils.java

License:Apache License

/**
 * A variation of//from   ww  w .  j a  va  2  s.  com
 * {@link #startComponentWithHtml(WicketTester,Component,String) startComponentWithHtml()}
 * that accepts {@link PageParameters}. These page parameters are passed to
 * the page that wraps the component under test.
 * 
 * @since 2.0.4
 */
public static void startComponentWithHtml(WicketTester tester, PageParameters parameters, Component c,
        final String markup) {
    WebPage page = new PageWithInlineMarkup(String.format("<!DOCTYPE html>%n"
            + "<html>%n<head>%n  <title>untitled</title>%n</head>%n" + "<body>%n%s%n</body>%n</html>", markup),
            parameters);
    page.add(c);
    tester.startPage(page);
}

From source file:jdave.wicket.ComponentSpecification.java

License:Apache License

/**
 * Start component for context, using page with given markup.
 * //from  w  w w. j a v a 2  s.  c om
 * @param model The model passed to component that is used for context.
 * @param pageMarkup Markup (as
 *            <code>org.apache.wicket.util.resource.IResourceStream</code>
 *            ) of the page created to host the specified component.
 * @param rootComponentId Wicket id of the root component in the component
 *            markup hierarchy given by the <code>pageMarkup</code>
 *            parameter. This is the id of the component returned from
 *            <code>newComponent</code> method and used as context, often
 *            a MarkupContainer or Form.
 */
public C startComponent(final IModel<M> model, final IResourceStream pageMarkup, final String rootComponentId) {
    final WebPage page = new TestPage(pageMarkup);
    specifiedComponent = newComponent(rootComponentId, model);
    page.add(specifiedComponent);
    wicket.startPage(page);
    return specifiedComponent;
}

From source file:org.apache.syncope.client.console.SyncopeApplication.java

License:Apache License

public void setupNavigationPanel(final WebPage page, final XMLRolesReader xmlRolesReader,
        final boolean notsel) {
    final ModalWindow infoModal = new ModalWindow("infoModal");
    page.add(infoModal);
    infoModal.setInitialWidth(350);/*from   w  w  w .  j  a  va  2 s.co  m*/
    infoModal.setInitialHeight(300);
    infoModal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    infoModal.setCookieName("infoModal");
    infoModal.setPageCreator(new ModalWindow.PageCreator() {

        private static final long serialVersionUID = -7834632442532690940L;

        @Override
        public Page createPage() {
            return new InfoModalPage();
        }
    });

    final AjaxLink<Page> infoLink = new AjaxLink<Page>("infoLink") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            infoModal.show(target);
        }
    };
    page.add(infoLink);

    BookmarkablePageLink<Page> schemaLink = new BookmarkablePageLink<>("schema", Schema.class);
    MetaDataRoleAuthorizationStrategy.authorize(schemaLink, WebPage.ENABLE,
            xmlRolesReader.getEntitlement("Schema", "list"));
    page.add(schemaLink);
    schemaLink.add(new Image("schemaIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "schema" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> usersLink = new BookmarkablePageLink<>("users", Users.class);
    MetaDataRoleAuthorizationStrategy.authorize(usersLink, WebPage.ENABLE,
            xmlRolesReader.getEntitlement("Users", "list"));
    page.add(usersLink);
    usersLink.add(new Image("usersIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "users" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> groupsLink = new BookmarkablePageLink<>("groups", Groups.class);
    MetaDataRoleAuthorizationStrategy.authorize(groupsLink, WebPage.ENABLE,
            xmlRolesReader.getEntitlement("Groups", "list"));
    page.add(groupsLink);
    groupsLink.add(new Image("groupsIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "groups" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> resourcesLink = new BookmarkablePageLink<>("resources", Resources.class);
    MetaDataRoleAuthorizationStrategy.authorize(resourcesLink, WebPage.ENABLE,
            xmlRolesReader.getEntitlement("Resources", "list"));
    page.add(resourcesLink);
    resourcesLink.add(new Image("resourcesIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "resources" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> todoLink = new BookmarkablePageLink<>("todo", Todo.class);
    MetaDataRoleAuthorizationStrategy.authorize(todoLink, WebPage.ENABLE,
            xmlRolesReader.getEntitlement("Approval", "list"));
    page.add(todoLink);
    todoLink.add(new Image("todoIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "todo" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> reportLink = new BookmarkablePageLink<>("reports", Reports.class);
    MetaDataRoleAuthorizationStrategy.authorize(reportLink, WebPage.ENABLE,
            xmlRolesReader.getEntitlement("Reports", "list"));
    page.add(reportLink);
    reportLink.add(new Image("reportsIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "reports" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> configurationLink = new BookmarkablePageLink<>("configuration",
            Configuration.class);
    MetaDataRoleAuthorizationStrategy.authorize(configurationLink, WebPage.ENABLE,
            xmlRolesReader.getEntitlement("Configuration", "list"));
    page.add(configurationLink);
    configurationLink.add(new Image("configurationIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "configuration" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> taskLink = new BookmarkablePageLink<>("tasks", Tasks.class);
    MetaDataRoleAuthorizationStrategy.authorize(taskLink, WebPage.ENABLE,
            xmlRolesReader.getEntitlement("Tasks", "list"));
    page.add(taskLink);
    taskLink.add(new Image("tasksIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "tasks" + Constants.PNG_EXT)));

    page.add(new BookmarkablePageLink<Page>("logout", Logout.class));
}

From source file:org.apache.syncope.client.console.SyncopeApplication.java

License:Apache License

public void setupEditProfileModal(final WebPage page, final UserSelfRestClient userSelfRestClient) {
    // Modal window for editing user profile
    final ModalWindow editProfileModalWin = new ModalWindow("editProfileModal");
    editProfileModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editProfileModalWin.setInitialHeight(EDIT_PROFILE_WIN_HEIGHT);
    editProfileModalWin.setInitialWidth(EDIT_PROFILE_WIN_WIDTH);
    editProfileModalWin.setCookieName("edit-profile-modal");
    page.add(editProfileModalWin);

    final AjaxLink<Page> editProfileLink = new AjaxLink<Page>("editProfileLink") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override/*from ww w  .ja va2 s .  c  o m*/
        public void onClick(final AjaxRequestTarget target) {
            final UserTO userTO;
            if (SyncopeSession.get().isAuthenticated()) {
                try {
                    userTO = userSelfRestClient.read();
                } catch (Exception e) {
                    throw new WicketRuntimeException(e);
                }
            } else {
                userTO = new UserTO();
            }

            editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = -7834632442532690940L;

                @Override
                public Page createPage() {
                    return new UserSelfModalPage(page.getPageReference(), editProfileModalWin, userTO);
                }
            });

            editProfileModalWin.show(target);
        }
    };

    editProfileLink.add(new Label("username", SyncopeSession.get().getUsername()));

    if ("admin".equals(SyncopeSession.get().getUsername())) {
        editProfileLink.setEnabled(false);
    }

    page.add(editProfileLink);
}

From source file:org.apache.syncope.console.SyncopeApplication.java

License:Apache License

public void setupNavigationPanel(final WebPage page, final XMLRolesReader xmlRolesReader,
        final boolean notsel) {
    final ModalWindow infoModal = new ModalWindow("infoModal");
    page.add(infoModal);
    infoModal.setInitialWidth(350);/*from w w w.ja v a 2 s.  c  om*/
    infoModal.setInitialHeight(300);
    infoModal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    infoModal.setCookieName("infoModal");
    infoModal.setPageCreator(new ModalWindow.PageCreator() {

        private static final long serialVersionUID = -7834632442532690940L;

        @Override
        public Page createPage() {
            return new InfoModalPage();
        }
    });

    final AjaxLink<Page> infoLink = new AjaxLink<Page>("infoLink") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            infoModal.show(target);
        }
    };
    page.add(infoLink);

    BookmarkablePageLink<Page> schemaLink = new BookmarkablePageLink<Page>("schema", Schema.class);
    MetaDataRoleAuthorizationStrategy.authorize(schemaLink, WebPage.ENABLE,
            xmlRolesReader.getAllAllowedRoles("Schema", "list"));
    page.add(schemaLink);
    schemaLink.add(new Image("schemaIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "schema" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> usersLink = new BookmarkablePageLink<Page>("users", Users.class);
    MetaDataRoleAuthorizationStrategy.authorize(usersLink, WebPage.ENABLE,
            xmlRolesReader.getAllAllowedRoles("Users", "list"));
    page.add(usersLink);
    usersLink.add(new Image("usersIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "users" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> rolesLink = new BookmarkablePageLink<Page>("roles", Roles.class);
    MetaDataRoleAuthorizationStrategy.authorize(rolesLink, WebPage.ENABLE,
            xmlRolesReader.getAllAllowedRoles("Roles", "list"));
    page.add(rolesLink);
    rolesLink.add(new Image("rolesIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "roles" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> resourcesLink = new BookmarkablePageLink<Page>("resources", Resources.class);
    MetaDataRoleAuthorizationStrategy.authorize(resourcesLink, WebPage.ENABLE,
            xmlRolesReader.getAllAllowedRoles("Resources", "list"));
    page.add(resourcesLink);
    resourcesLink.add(new Image("resourcesIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "resources" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> todoLink = new BookmarkablePageLink<Page>("todo", Todo.class);
    MetaDataRoleAuthorizationStrategy.authorize(todoLink, WebPage.ENABLE,
            xmlRolesReader.getAllAllowedRoles("Approval", "list"));
    page.add(todoLink);
    todoLink.add(new Image("todoIcon",
            new ContextRelativeResource(IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "todo" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> reportLink = new BookmarkablePageLink<Page>("reports", Reports.class);
    MetaDataRoleAuthorizationStrategy.authorize(reportLink, WebPage.ENABLE,
            xmlRolesReader.getAllAllowedRoles("Reports", "list"));
    page.add(reportLink);
    reportLink.add(new Image("reportsIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "reports" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> configurationLink = new BookmarkablePageLink<Page>("configuration",
            Configuration.class);
    MetaDataRoleAuthorizationStrategy.authorize(configurationLink, WebPage.ENABLE,
            xmlRolesReader.getAllAllowedRoles("Configuration", "list"));
    page.add(configurationLink);
    configurationLink.add(new Image("configurationIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "configuration" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> taskLink = new BookmarkablePageLink<Page>("tasks", Tasks.class);
    MetaDataRoleAuthorizationStrategy.authorize(taskLink, WebPage.ENABLE,
            xmlRolesReader.getAllAllowedRoles("Tasks", "list"));
    page.add(taskLink);
    taskLink.add(new Image("tasksIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "tasks" + Constants.PNG_EXT)));

    page.add(new BookmarkablePageLink<Page>("logout", Logout.class));
}

From source file:org.apache.syncope.console.SyncopeApplication.java

License:Apache License

public void setupEditProfileModal(final WebPage page, final UserSelfRestClient userSelfRestClient) {
    // Modal window for editing user profile
    final ModalWindow editProfileModalWin = new ModalWindow("editProfileModal");
    editProfileModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editProfileModalWin.setInitialHeight(EDIT_PROFILE_WIN_HEIGHT);
    editProfileModalWin.setInitialWidth(EDIT_PROFILE_WIN_WIDTH);
    editProfileModalWin.setCookieName("edit-profile-modal");
    page.add(editProfileModalWin);

    final AjaxLink<Page> editProfileLink = new AjaxLink<Page>("editProfileLink") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override/*from   ww  w.  j a v a2 s . c  om*/
        public void onClick(final AjaxRequestTarget target) {
            final UserTO userTO = SyncopeSession.get().isAuthenticated() ? userSelfRestClient.read()
                    : new UserTO();

            editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = -7834632442532690940L;

                @Override
                public Page createPage() {
                    return new UserSelfModalPage(page.getPageReference(), editProfileModalWin, userTO);
                }
            });

            editProfileModalWin.show(target);
        }
    };

    editProfileLink.add(new Label("username", SyncopeSession.get().getUsername()));

    if ("admin".equals(SyncopeSession.get().getUsername())) {
        editProfileLink.setEnabled(false);
    }

    page.add(editProfileLink);
}

From source file:org.cdlflex.ui.behavior.PopoverBehaviorTest.java

License:Apache License

@Test
public void rendersActivationJavaScriptOnPageCorrectly() throws Exception {
    WebPage page = new TestPage();
    component.add(new PopoverBehavior("message-title", "message-body"));
    page.add(component);

    assertThat(render(page), containsString("$('#test-component').popover();"));
}

From source file:org.odlabs.wiquery.ui.draggable.DraggableAjaxBehaviorTestCase.java

License:Open Source License

/**
 * Test method for {@link DraggableAjaxBehavior#statement()} .
 */// w ww  .  j ava2s.c  o  m
@Test
public void testStatement() {
    InnerDraggableAjaxBehavior draggableAjaxBehavior = new InnerDraggableAjaxBehavior();
    WebMarkupContainer component = new WebMarkupContainer("anId");
    component.setMarkupId("anId");
    component.add(draggableAjaxBehavior);

    WebPage webPage = new InnerPage();
    webPage.add(component);
    String generateAjaxStatment = draggableAjaxBehavior.statement().render().toString();
    String expectedAjaxStatement = "$('#anId').draggable({stop: function(event, ui) {\n\t"
            + "var isInvalid = $.ui.draggable._dragElementDroppedWasInvalid(this);var wcall=wicketAjaxGet('wicket/page?0-0.IBehaviorListener.1-anId&dragType=stop&dragStatus='+isInvalid,function() { }.bind(this),function() { }.bind(this), function() {return Wicket.$('anId') != null;}.bind(this));\n"
            + "}, start: function(event, ui) {\n\t"
            + "var wcall=wicketAjaxGet('wicket/page?0-0.IBehaviorListener.1-anId&dragType=start',function() { }.bind(this),function() { }.bind(this), function() {return Wicket.$('anId') != null;}.bind(this));\n"
            + "}, drag: function(event, ui) {\n\t"
            + "var wcall=wicketAjaxGet('wicket/page?0-0.IBehaviorListener.1-anId&dragType=drag',function() { }.bind(this),function() { }.bind(this), function() {return Wicket.$('anId') != null;}.bind(this));\n"
            + "}, revert: function(dropped) {\n\t"
            + "return $.ui.draggable._dragElementWasDropped(this, dropped);\n" + "}});";
    assertNotNull(draggableAjaxBehavior.getDraggableBehavior());
    assertEquals(expectedAjaxStatement, generateAjaxStatment);
}

From source file:org.odlabs.wiquery.ui.droppable.DroppableAjaxBehaviorTestCase.java

License:Open Source License

/**
 * Test method for/*from w w  w .j a  v  a2s  . c om*/
 * {@link org.odlabs.wiquery.ui.droppable.DroppableAjaxBehavior#statement()} .
 */
@Test
public void testStatement() {
    InnerDroppableAjaxBehavior droppableAjaxBehavior = new InnerDroppableAjaxBehavior();
    WebMarkupContainer component = new WebMarkupContainer("anId");
    component.setMarkupId("anId");
    component.add(droppableAjaxBehavior);

    WebPage webPage = new InnerPage();
    webPage.add(component);

    String ajaxCallResult = droppableAjaxBehavior.statement().render().toString();
    String expectedResult = "$('#anId').droppable({drop: function(event, ui) {\n\t"
            + "var wcall=wicketAjaxGet('wicket/page?0-0.IBehaviorListener.1-anId&droppedId='+ui.draggable[0].id,function() { }.bind(this),function() { }.bind(this), function() {return Wicket.$('anId') != null;}.bind(this));\n"
            + "}});";
    assertNotNull(droppableAjaxBehavior.getDroppableBehavior());
    assertEquals(expectedResult, ajaxCallResult);
}