SetResponsePage in Wicket

核能气质少年 提交于 2019-12-10 14:47:17

问题


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?


回答1:


The first one will redirect to a bookmarkable URL.

Please see also the Wicket FAQ.




回答2:


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




回答3:


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


}


来源:https://stackoverflow.com/questions/8849328/setresponsepage-in-wicket

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!