Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SetResponsePage in Wicket

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?

like image 392
Best Avatar asked Jan 13 '12 10:01

Best


3 Answers

The first one will redirect to a bookmarkable URL.

Please see also the Wicket FAQ.

like image 123
magomi Avatar answered Nov 05 '22 16:11

magomi


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

like image 22
Shivan Dragon Avatar answered Nov 05 '22 16:11

Shivan Dragon


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**)


}
like image 41
Nicolas Melendez Avatar answered Nov 05 '22 18:11

Nicolas Melendez