Wicket redirect: how to pass on parameters and keeps URLs “pretty”?

血红的双手。 提交于 2019-12-04 08:54:14
mfunk

Maybe the other setResponsePage method in Component is closer to what you want:

/**
 * 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);
}
Pops

seanizer has the right idea, but just for completeness, there are more options than BookmarkablePageRequestTargetUrlCodingStrategy and HybridUrlCodingStrategy:

I think the key phrase on this reference page is this:

The next step is to determine which URL encoding strategy to use. Unless one is explicity specified, the default used is BookmarkablePageRequestTargetUrlCodingStrategy. In the example above, the Terms page uses the default.

I think you need to mount another url coding strategy, probably something like HybridUrlCodingStrategy.

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

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

I've successfully been using this from an onClick handler, but not yet sure if it'll work from an constructor as well:

getRequestCycle().setRequestTarget(new BookmarkablePageRequestTarget(ReportPage.class, params));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!