سؤال

When my session times out before an AJAX request I don't get redirected to the log in page instead i get this error message:

ERROR: Wicket.Ajax.Call.failure: Error while parsing response: Error: Invalid XML

followed by my log in page html. Preferably I would like to get redirected to the login page as soon as the session has expired. But if that is not possible, redirect on some sort of click would do. How would be the best way to handle this?

هل كانت مفيدة؟

المحلول

final Button searchButton = new AjaxButton(buttonId) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            // TODO Auto-generated method stub
            super.updateAjaxAttributes(attributes);
            AjaxCallListener ajaxCallListener = new AjaxCallListener() {

                /**
                 * 
                 */
                private static final long serialVersionUID = 1L;

                @Override
                public CharSequence getFailureHandler(Component component) {
                    return "window.location.replace(\"stackoverflow.com\");";
                }


            };
            attributes.getAjaxCallListeners().add(ajaxCallListener);
        }}

After adding this to every AJAX component it worked. As soon as there is a problem with the AJAX call there will be a redirect. In my case I have it redirecting to my log in page as the user has been logged out when this happens. It may not be the best way but it is the only way I been able to solve it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top