I saw that there are two ways to set a responsePage in Wicket's WebPage:
setResponsePage(new MyPage());
or
setResponsePage(MyPage.class);
What are the differences between these two?
The first one will redirect to a bookmarkable URL.
Please see also the Wicket FAQ.
Wicket's doc sais it best:
"setResponsePage(new MyWebPage()) (or setResponsePage(new MyWebPage(myPageParameters))) can be used if you want to have a bookmarkable url in the browser (your page must have default constructor or PageParameter constructor). setResponsePage(MyWebPage.class) can be used if you want to pass information to pages on the serverside. This generates a session specific url (most of the time you can use hybrid url coding strategy)."
here
The difference is that you can send parameters to .setResponsePage(new WebPage(p1,p2,p3)) and in .setResponsePage(WebPage.class)
you can't.
If you mount a page, .setResponsePage([WebPage.class])
2 will send a user to the url you defined in the WicketApplication
, when you mounted the page doing something like:
public void init() {
this.mountPage("/myPage", **WebPage.class**)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With