tags:

views:

775

answers:

2

Hi,

I have a wicket web application with Page mounted to bookmarkable alias. The page contains a form object with submit action.

The problem is that though the form belongs to the page the action url doesn't contain page alias, but rather created in cryptic form of wicket action. Is there a way to adjust that behavior, so link will be like *page_alias/submit* ?

...
setRenderStrategy(IRequestCycleSettings.ONE_PASS_RENDER);
mountBookmarkablePage("/resetpwd", ResetPasswordPage.class); 
...
public ResetPasswordPage(final String id, final PageParameters parameters) {
    final Form form = new StatelessForm();
    form.add(new Button("submit") { 
     public void onSubmit() {
         ...
        });
 add(form);
+1  A: 

What you're looking for is called stateless pages in Wicket terminology.

If you want to make sure a page and all it's components are stateless, you should call page.setStatelessHint(true)

However, you won't get any cleaner than this example (tested with 1.3.7 as I don't have any 1.4.* projects available right now):

/path/to/mounted/page?form2_hf_0=&wicket:interface=:1:form::IFormSubmitListener::&param1=value
sfussenegger
A: 

you can hide a lot of the request mumbo jumbo by using a HybridUrlCodingStrategy like so:

mount(new HybridUrlCodingStrategy("/resetpwd", ResetPasswordPage.class));

Then when the click submit, assuming you don't redirect to a new page, the url would change from

mysite.com/DocRoot/resetpwd

to

mysite.com/DocRoot/resetpwd.1

or if you really want it to be mysite.com/DocRoot/resetpwd/submit you could create a new bookmarkable page, say ResetPasswordResult.class, set your response page to that and mount it at "/resetpwd/submit"

You might look at other encoding strategies to see if their is another that suits you better: http://cwiki.apache.org/WICKET/url-coding-strategies.html

perilandmishap