0

I've been playing with the Wicket autocompletetextfield. It has one problem though - when the session times out it stops working if the page itself isn't refreshed. This would be quite confusing for a customer I think, and I guess that it's not meant to work that way. Therefore, how can I make the Wicket autocompletetextfield work even though the session has timed out (and without refreshing the page)

To try it yourself:

  1. Go to http://www.wicket-library.com/wicket-examples-6.0.x/ajax/autocomplete
  2. Write something in the textfield, eg. bel
  3. Wait for 5 minutes (I think that's is the default session timeout they use in the examples) and try again, without refreshing the page. Now you'll only get a blank textfield.
4

1 回答 1

2

我认为你不能。

我知道的唯一解决方法是将 Ajax 错误处理策略设置为 REDIRECT_TO_ERROR_PAGE,评估错误页面中 HTTP 标头中的 Referer-Field 并提供指向发生超时的页面的链接(或自动重定向)。

YourWicketApplication.java

@Override
public void init() {
    super.init();
    // ...
    getExceptionSettings().setAjaxErrorHandlingStrategy(IExceptionSettings.AjaxErrorStrategy.REDIRECT_TO_ERROR_PAGE);

}

YourErrorPage.java:

public YourErrorPage(...) {
    // ...
    WebRequest request = (WebRequest) getRequest();
    String referer = request.getHeader("Referer"));
    // ... provide a link/auto redirect to this address
}
于 2013-04-01T21:54:49.913 回答