3

my map is

mountPage("/page/#{code}/#{name}", Page.class);

but when I click on the link

localhost/page/10/toy?2

wicket add also one parameter like a counter, when I refresh the page I have

localhost/page/10/toy?3

why?

Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277
Armen Arzumanyan
  • 1,939
  • 3
  • 30
  • 56

2 Answers2

6

This is because your page are stateful, Wicket manages its own states to your page by appending this "counter". This way, when your user navigate backward using its browser built-in functionnality, the page is displayed has it has been previously.

If you don't want such a parameter in your URL, you'll need to dig out and eradicate every stateful component in your pages.

Cedric Gatay
  • 1,553
  • 3
  • 12
  • 17
  • Thank you, how can I sole this? params.add("link", components.getModelObject().getPermalink()); params.add("code", code); Link link = new BookmarkablePageLink("link", OrderPage.class, params); link.add(new Label("linksel", "Select")); components.add(link); I am just click on url and second page extended BasePage – Armen Arzumanyan Apr 06 '13 at 21:52
  • You can help Wicket by defining `getStatelessHint()` returning true in your base page. I'm afraid you'll need to fire the debugger in order to find which component is stateful in order to suppress this in your url. – Cedric Gatay Apr 06 '13 at 22:05
  • How we can remove that counter from url? – Armen Arzumanyan Apr 09 '13 at 14:59
1

You can create

public class MountedMapperWithoutPageComponentInfo extends MountedMapper {

public MountedMapperWithoutPageComponentInfo(String mountPath, Class<? extends IRequestablePage> pageClass) {
    super(mountPath, pageClass, new PageParametersEncoder());
}

@Override
protected void encodePageComponentInfo(Url url, PageComponentInfo info) {

}

@Override
public Url mapHandler(IRequestHandler requestHandler) {
    if (requestHandler instanceof ListenerInterfaceRequestHandler) {
        return null;
    } else {
        return super.mapHandler(requestHandler);
    }
}

}

and map page on Application class like this

mount(new MountedMapperWithoutPageComponentInfo("/page/#{code}/#{name}", Page.class));
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Vazgen D.
  • 11
  • 1