Search in sources :

Example 66 with PageParameters

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

the class QueryStringWithVersionResourceCachingStrategyTest method testUndecorateUrl.

@Test
void testUndecorateUrl() throws Exception {
    PageParameters urlParameters = new PageParameters();
    urlParameters.add(versionParameter, TEST_RESOURCE_VERSION, INamedParameters.Type.QUERY_STRING);
    ResourceUrl resourceUrl = new ResourceUrl("some-resource.txt", urlParameters);
    strategy.undecorateUrl(resourceUrl);
    assertEquals("some-resource.txt", resourceUrl.getFileName());
    assertNull(resourceUrl.getParameters().get(versionParameter).toString());
}
Also used : PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) ResourceUrl(org.apache.wicket.request.resource.caching.ResourceUrl) Test(org.junit.jupiter.api.Test)

Example 67 with PageParameters

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

the class FormComponentUpdatingBehavior method renderHead.

@Override
public void renderHead(Component component, IHeaderResponse response) {
    CharSequence url = component.urlForListener(this, new PageParameters());
    String event = getEvent();
    String condition = String.format("if (event.target.name !== '%s') return; ", formComponent.getInputName());
    Form<?> form = component.findParent(Form.class);
    if (form != null) {
        response.render(OnEventHeaderItem.forComponent(component, event, condition + form.getJsForListenerUrl(url.toString())));
    } else {
        char separator = url.toString().indexOf('?') > -1 ? '&' : '?';
        response.render(OnEventHeaderItem.forComponent(component, event, condition + String.format("window.location.href='%s%s%s=' + %s;", url, separator, formComponent.getInputName(), getJSValue())));
    }
}
Also used : PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters)

Example 68 with PageParameters

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

the class StatelessForm method process.

/**
 * Remove the page parameters for all form component otherwise they get appended to action URL
 *
 * {@inheritDoc}
 */
@Override
public void process(IFormSubmitter submittingComponent) {
    // get the parameters before processing the form because the
    // application may remove this form from its parent in #onSubmit() (WICKET-5158)
    final PageParameters parameters = getPage().getPageParameters();
    super.process(submittingComponent);
    if (parameters != null) {
        visitFormComponents(new IVisitor<FormComponent<?>, Void>() {

            @Override
            public void component(final FormComponent<?> formComponent, final IVisit<Void> visit) {
                parameters.remove(formComponent.getInputName());
            }
        });
        if (submittingComponent instanceof AbstractSubmitLink) {
            AbstractSubmitLink submitLink = (AbstractSubmitLink) submittingComponent;
            parameters.remove(submitLink.getInputName());
        }
        // remove the special parameter for IRequestListener
        List<INamedParameters.NamedPair> namedParameters = parameters.getAllNamed();
        Iterator<INamedParameters.NamedPair> iterator = namedParameters.iterator();
        while (iterator.hasNext()) {
            INamedParameters.NamedPair namedParameter = iterator.next();
            if (Strings.isEmpty(namedParameter.getValue())) {
                parameters.remove(namedParameter.getKey());
                break;
            }
        }
    }
}
Also used : INamedParameters(org.apache.wicket.request.mapper.parameter.INamedParameters) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters)

Example 69 with PageParameters

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

the class AjaxCallbackUrlTest method getCallbackUrl.

private String getCallbackUrl(final String pageMountPath) {
    WebApplication application = tester.getApplication();
    application.mountPage(pageMountPath, TestPage.class);
    application.getPageSettings().setRecreateBookmarkablePagesAfterExpiry(false);
    PageParameters pageParameters = new PageParameters();
    pageParameters.set("b", "BBB", INamedParameters.Type.PATH);
    pageParameters.set("c", "CCC", INamedParameters.Type.PATH);
    TestPage page = tester.startPage(TestPage.class, pageParameters);
    return page.getAjaxCallbackUrl();
}
Also used : PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) WebApplication(org.apache.wicket.protocol.http.WebApplication)

Example 70 with PageParameters

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

the class BookmarkableFolderContent method newContentComponent.

@Override
public Component newContentComponent(String id, final AbstractTree<Foo> tree, IModel<Foo> model) {
    return new Folder<Foo>(id, tree, model) {

        private static final long serialVersionUID = 1L;

        @Override
        protected MarkupContainer newLinkComponent(String id, IModel<Foo> model) {
            Foo foo = model.getObject();
            if (tree.getProvider().hasChildren(foo)) {
                return super.newLinkComponent(id, model);
            } else {
                PageParameters parameters = new PageParameters();
                parameters.add("foo", foo.getId());
                return new BookmarkablePageLink<>(id, tree.getPage().getClass(), parameters);
            }
        }
    };
}
Also used : BookmarkablePageLink(org.apache.wicket.markup.html.link.BookmarkablePageLink) IModel(org.apache.wicket.model.IModel) Foo(org.apache.wicket.examples.tree.Foo) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Folder(org.apache.wicket.extensions.markup.html.repeater.tree.content.Folder)

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