How to change Wicket behaviour on Page Expired

前提是你 提交于 2020-01-04 13:42:08

问题


We have a wicket application for our main website. Lately we have implemented a mobile version of the site. The mobile version is special in that it is deployed inside a native app wrapper to some mobile devices and not connected to the rest of the page through links because it is not supposed to be normally visible to web users.

The mobile page makes use of ajax and is therefore prone to receive "Page expired" errors for example when we restart the application on the server.

Since that page is not connected to the rest of the application through links I do not want our standard "Page expired" behaviour. Is it possible to override or intercept this behaviour for the pages belonging to the mobile part of the site? For example I could like to be able to configure the pages to simply reload on a "Page expired" error.


回答1:


Yes,

getApplicationSettings().setPageExpiredErrorPage(YourPage.class)

YourPage.class can then for instance be your HomePage or another Page that depending on it being a request from a mobile device does something else.

If you would like to reload the Page the user was one then it becomes a bit less trivial. Reloading the Page is not possible since you are not on the page anymore. You could have a look at IRequestCycleListener and overriding onException and handle PageExpiredException yourself but it is a dangerous road you travel if you simply reload your Page. Navigating to the home (or other) page seems more logical. I assume you are not restarting your server 100 times per day...



来源:https://stackoverflow.com/questions/9393902/how-to-change-wicket-behaviour-on-page-expired

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