Search in sources :

Example 81 with PageParameters

use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.

the class ResourceMapper method mapRequest.

@Override
public IRequestHandler mapRequest(final Request request) {
    final Url url = new Url(request.getUrl());
    // now extract the page parameters from the request url
    PageParameters parameters = extractPageParameters(request, mountSegments.length, parametersEncoder);
    if (parameters != null) {
        parameters.setLocale(resolveLocale());
    }
    // remove caching information from current request
    removeCachingDecoration(url, parameters);
    // check if url matches mount path
    if (urlStartsWith(url, mountSegments) == false) {
        return null;
    }
    // check if there are placeholders in mount segments
    for (int index = 0; index < mountSegments.length; ++index) {
        String placeholder = getPlaceholder(mountSegments[index]);
        if (placeholder != null) {
            // extract the parameter from URL
            if (parameters == null) {
                parameters = newPageParameters();
            }
            parameters.add(placeholder, url.getSegments().get(index), INamedParameters.Type.PATH);
        }
    }
    return new ResourceReferenceRequestHandler(resourceReference, parameters);
}
Also used : ResourceReferenceRequestHandler(org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) ResourceUrl(org.apache.wicket.request.resource.caching.ResourceUrl) Url(org.apache.wicket.request.Url)

Example 82 with PageParameters

use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.

the class AbstractAjaxBehavior method getCallbackUrl.

/**
 * Gets the url that references this handler.
 *
 * @return the url that references this handler
 */
public CharSequence getCallbackUrl() {
    Component component = getComponent();
    if (component == null) {
        throw new IllegalArgumentException("Behavior must be bound to a component to create the URL");
    }
    PageParameters parameters = new PageParameters();
    PageParameters pageParameters = component.getPage().getPageParameters();
    List<INamedParameters.NamedPair> allNamedInPath = pageParameters.getAllNamedByType(INamedParameters.Type.PATH);
    for (INamedParameters.NamedPair namedPair : allNamedInPath) {
        parameters.add(namedPair.getKey(), namedPair.getValue(), INamedParameters.Type.PATH);
    }
    return getComponent().urlForListener(this, parameters);
}
Also used : INamedParameters(org.apache.wicket.request.mapper.parameter.INamedParameters) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Component(org.apache.wicket.Component)

Example 83 with PageParameters

use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.

the class BaseWicketTester method submitForm.

/**
 * Submits the {@link Form} in the last rendered {@link Page}.
 * <p>
 * <strong>Note</strong>: Form request parameters have to be set explicitely.
 *
 * @param path
 *            path to component
 */
public void submitForm(String path) {
    Form<?> form = (Form<?>) getComponentFromLastRenderedPage(path);
    Url url = Url.parse(form.getRootForm().urlForListener(new PageParameters()).toString(), Charset.forName(request.getCharacterEncoding()));
    // make url absolute
    transform(url);
    request.setUrl(url);
    processRequest();
}
Also used : Form(org.apache.wicket.markup.html.form.Form) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Url(org.apache.wicket.request.Url)

Example 84 with PageParameters

use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.

the class BaseWicketTester method urlFor.

/**
 * @param link
 * @return url for Link
 */
public String urlFor(Link<?> link) {
    Args.notNull(link, "link");
    Url url = Url.parse(link.urlForListener(new PageParameters()).toString());
    return transform(url).toString();
}
Also used : PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Url(org.apache.wicket.request.Url)

Example 85 with PageParameters

use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.

the class BookmarkablePageLinkTest method bookmarkableRequestWithInterceptWithParams.

/**
 * @throws Exception
 */
@Test
void bookmarkableRequestWithInterceptWithParams() throws Exception {
    PageParameters pp = new PageParameters();
    pp.set("test", "test");
    tester.startPage(BookmarkableThrowsInterceptPage.class, pp);
    assertEquals(tester.getLastRenderedPage().getClass(), BookmarkableSetSecurityPage.class);
    tester.startPage(BookmarkableContinueToPage.class);
    assertEquals(tester.getLastRenderedPage().getClass(), BookmarkableThrowsInterceptPage.class);
}
Also used : PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Test(org.junit.jupiter.api.Test)

Aggregations

PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)272 Test (org.junit.jupiter.api.Test)79 Url (org.apache.wicket.request.Url)56 IRequestHandler (org.apache.wicket.request.IRequestHandler)39 PageProvider (org.apache.wicket.core.request.handler.PageProvider)27 StringValue (org.apache.wicket.util.string.StringValue)26 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)23 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)20 IPageProvider (org.apache.wicket.core.request.handler.IPageProvider)20 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)18 BookmarkablePageRequestHandler (org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler)17 ResourceUrl (org.apache.wicket.request.resource.caching.ResourceUrl)16 Test (org.junit.Test)16 Page (org.apache.wicket.Page)10 WicketRuntimeException (org.apache.wicket.WicketRuntimeException)10 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)10 ResourceReferenceRequestHandler (org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler)10 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)8 IOException (java.io.IOException)8 WebPage (org.apache.wicket.markup.html.WebPage)8