Search in sources :

Example 26 with Page

use of org.apache.wicket.Page in project wicket by apache.

the class AjaxRequestHandler method add.

@Override
public void add(Component... components) {
    for (final Component component : components) {
        Args.notNull(component, "component");
        if (component.getOutputMarkupId() == false && !(component instanceof Page)) {
            throw new IllegalArgumentException("Cannot update component that does not have setOutputMarkupId property set to true. Component: " + component.toString());
        }
        Page pageOfComponent = component.findParent(Page.class);
        if (component == getPage() || pageOfComponent == getPage()) {
            add(component, component.getMarkupId());
        } else {
            String msg = "Cannot update component because its page is not the same as " + "the one this handler has been created for. Component: " + component.toString();
            IllegalArgumentException error = new IllegalArgumentException(msg);
            if (Application.get().usesDevelopmentConfig()) {
                throw error;
            } else {
                // log the error to the application log, but don't block the user of the
                // application (which was the behavior in Wicket <= 7.
                log.error(msg, error);
            }
        }
    }
}
Also used : Page(org.apache.wicket.Page) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) Component(org.apache.wicket.Component)

Example 27 with Page

use of org.apache.wicket.Page in project wicket by apache.

the class LocaleAwarePageParametersTest method localeAware.

@Test
public void localeAware() {
    tester.executeUrl("aware?number=1.234,0");
    final Page page = tester.getLastRenderedPage();
    assertThat(page.getPageParameters().get("number").toDouble(), is(1234d));
}
Also used : Page(org.apache.wicket.Page) WebPage(org.apache.wicket.markup.html.WebPage) Test(org.junit.Test)

Example 28 with Page

use of org.apache.wicket.Page in project wicket by apache.

the class ConversationPropagator method onRequestHandlerScheduled.

@Override
public void onRequestHandlerScheduled(RequestCycle cycle, IRequestHandler handler) {
    // propagate current non-transient conversation to the newly scheduled page
    Conversation conversation = getConversation(cycle);
    if (conversation == null || conversation.isTransient()) {
        return;
    }
    Page page = getPage(handler);
    if (page != null) {
        if (propagation.propagatesViaPage(page, handler)) {
            // propagate a conversation across non-bookmarkable page instances
            setConversationOnPage(conversation, page);
        }
    }
    if (propagation.propagatesViaParameters(handler)) {
        // propagate cid to a scheduled bookmarkable page
        logger.debug("Propagating non-transient conversation {} via page parameters of handler {}", conversation.getId(), handler);
        PageParameters parameters = getPageParameters(handler);
        if (parameters != null) {
            parameters.set(CID, conversation.getId());
        }
    }
}
Also used : Conversation(javax.enterprise.context.Conversation) Page(org.apache.wicket.Page) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters)

Example 29 with Page

use of org.apache.wicket.Page in project wicket by apache.

the class EnclosureTest method testRender10.

/**
 * It must not be a difference if the enclosure controller child is a FormComponent.
 *
 * @throws Exception
 */
@Test
public void testRender10() throws Exception {
    Class<? extends Page> clazz = EnclosurePage_10.class;
    executeTest(clazz, "EnclosurePageExpectedResult_10.html");
    Page page = tester.getLastRenderedPage();
    page.get("input").setVisible(false);
    tester.startPage(page);
    tester.assertRenderedPage(clazz);
    tester.assertResultPage(getClass(), "EnclosurePageExpectedResult_10-2.html");
    page.get("input").setVisible(true);
    tester.startPage(page);
    tester.assertRenderedPage(clazz);
    tester.assertResultPage(getClass(), "EnclosurePageExpectedResult_10.html");
    page.get("label").setVisible(false);
    tester.startPage(page);
    tester.assertRenderedPage(clazz);
    tester.assertResultPage(getClass(), "EnclosurePageExpectedResult_10-3.html");
    page.get("input").setVisible(false);
    tester.startPage(page);
    tester.assertRenderedPage(clazz);
    tester.assertResultPage(getClass(), "EnclosurePageExpectedResult_10-2.html");
    page.get("input").setVisible(true);
    tester.startPage(page);
    tester.assertRenderedPage(clazz);
    tester.assertResultPage(getClass(), "EnclosurePageExpectedResult_10-3.html");
    page.get("label").setVisible(true);
    tester.startPage(page);
    tester.assertRenderedPage(clazz);
    tester.assertResultPage(getClass(), "EnclosurePageExpectedResult_10.html");
}
Also used : Page(org.apache.wicket.Page) WebPage(org.apache.wicket.markup.html.WebPage) Test(org.junit.Test)

Example 30 with Page

use of org.apache.wicket.Page in project wicket by apache.

the class MergedMarkupTest method test2.

/**
 * test2()
 */
@Test
public void test2() {
    Page page = new SubPageWithMarkup();
    MarkupStream markup = page.getAssociatedMarkupStream(true);
    assertEquals("utf-8", markup.getEncoding());
    assertEquals(MarkupParser.WICKET, markup.getWicketNamespace());
}
Also used : Page(org.apache.wicket.Page) MarkupStream(org.apache.wicket.markup.MarkupStream) Test(org.junit.Test)

Aggregations

Page (org.apache.wicket.Page)94 Test (org.junit.Test)50 WebPage (org.apache.wicket.markup.html.WebPage)22 Component (org.apache.wicket.Component)11 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)7 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)7 WicketRuntimeException (org.apache.wicket.WicketRuntimeException)6 IRequestHandler (org.apache.wicket.request.IRequestHandler)6 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)6 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)6 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)5 PageProvider (org.apache.wicket.core.request.handler.PageProvider)5 IMarkupFragment (org.apache.wicket.markup.IMarkupFragment)5 DummyPage (org.apache.wicket.resource.DummyPage)5 ArrayList (java.util.ArrayList)4 AbstractAjaxBehavior (org.apache.wicket.behavior.AbstractAjaxBehavior)4 AccessDeniedPage (org.apache.wicket.markup.html.pages.AccessDeniedPage)4 Url (org.apache.wicket.request.Url)4 MockInnerClassPage (org.apache.wicket.util.tester.MockPageParameterPage.MockInnerClassPage)4 SuccessPage (org.apache.wicket.util.tester.apps_1.SuccessPage)4