简体   繁体   中英

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?

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


}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM