Wicket redirect: how do I pass parameters and keep the URLs pretty?

Consider Wicket WebPage, which redirects to another page (based on some logic omitted from here):

public class SomePage extends WebPage {
    public SomePage(PageParameters parameters) {
        setResponsePage(AnotherPage.class);
        setRedirect(true);
    }
}

I need to pass the PageParameters pages to this other page, and this seems to be the way to do this:

setResponsePage(new AnotherPage(parameters));

However, when creating such a new page object, I get a URL, for example /?wicket:interface=:1::::, instead of a clean one /another. AnotherPage is defined as:

@MountPath(path = "another")
public class AnotherPage extends WebPage {
    // ...
}

(Where is MountPath from org.wicketstuff.annotation.mount package.)

So my questions are:

  • Any other way to pass parameters?
  • How to save URL? Is the above Wicket Stuff restriction in place of the main Wicket?

Update

, , , - setResponsePage(new AnotherPage(parameters)) - setRedirect(true). URL- ( SomePage), . , , ( , "" )!

( "SomePage" ) , -, URL-. , , .: -/

, , . , .

+5
4

, setResponsePage Component , :

/**
 * Sets the page class and its parameters that will respond to this request
 * 
 * @param <C>
 * 
 * @param cls
 *            The response page class
 * @param parameters
 *            The parameters for this bookmarkable page.
 * @see RequestCycle#setResponsePage(Class, PageParameters)
 */
public final <C extends Page> void setResponsePage(final Class<C> cls, PageParameters parameters)
{
    getRequestCycle().setResponsePage(cls, parameters);
}
+3

seanizer , BookmarkablePageRequestTargetUrlCodingStrategy HybridUrlCodingStrategy:

+5

, :

- , URL . , BookmarkablePageRequestTargetUrlCodingStrategy. "" .

I think you need to mount a different URL encoding strategy, maybe something like that HybridUrlCodingStrategy.

Edit: you just need to add this annotation to do this:

@MountMixedParam(parameterNames={"param1", "param2"})
+4
source

I have successfully used this from the onClick handler, but I'm not sure that it will work from the constructor either:

getRequestCycle().setRequestTarget(new BookmarkablePageRequestTarget(ReportPage.class, params));
+1
source

All Articles