You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Benjamin Klum (Commented) (JIRA)" <ji...@apache.org> on 2012/01/13 15:27:41 UTC

[jira] [Commented] (WICKET-4116) Ajax link reports weird error when session is expired

    [ https://issues.apache.org/jira/browse/WICKET-4116?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13185604#comment-13185604 ] 

Benjamin Klum commented on WICKET-4116:
---------------------------------------

I would prefer if a PageExpiredException would be thrown in such a case. In our project, we need to show the user a special message if he clicks on an Ajax link but the session has expired. If the ListenerInterfaceRequestHandler just does a repaint, you have a hard time detecting what actually happened. Or am I missing something?

Currently I use an ugly workaround on the page which is repainted to detect the timeout and throw a PageExpiredException:


    @Override
    protected void onInitialize() {
        super.onInitialize();
        if (wasRequestedAfterSessionExpiration()) {
            throw new PageExpiredException("attempt to invoke request on expired listener interface");
        }
    }

    private boolean wasRequestedAfterSessionExpiration() {
        return getSession().isTemporary() && isListenerInterfaceRequest(getRequest());
    }

    private boolean isListenerInterfaceRequest(Request request) {
        return extractPageComponentInfo(request.getUrl()) != null;
    }

    private PageComponentInfo extractPageComponentInfo(Url url) {
        for (Url.QueryParameter p: url.getQueryParameters()) {
            if (Strings.isEmpty(p.getValue())) {
                PageComponentInfo i = PageComponentInfo.parse(p.getName());
                if (i != null) {
                    return i;
                }
            }
        }
        return null;
    }
                
> Ajax link reports weird error when session is expired
> -----------------------------------------------------
>
>                 Key: WICKET-4116
>                 URL: https://issues.apache.org/jira/browse/WICKET-4116
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.1
>            Reporter: Robin Shine
>            Assignee: Martin Grigorov
>             Fix For: 1.5.2
>
>
> Reproducing steps:
> 1. Put below simple page into a Wicket application and get it mounted:
> TestPage.java:
> import org.apache.wicket.ajax.AjaxRequestTarget;
> import org.apache.wicket.ajax.markup.html.AjaxLink;
> import org.apache.wicket.markup.html.WebPage;
> @SuppressWarnings("serial")
> public class TestPage extends WebPage {
> 	
> 	public TestPage() {
> 		
> 		add(new AjaxLink<Void>("test") {
> 			@Override
> 			public void onClick(AjaxRequestTarget target) {
> 			}
> 			
> 		});
> 		
> 	}
> 	
> }
> TestPage.html:
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <?xml version="1.0" encoding="UTF-8"?>
> <html xmlns="http://www.w3.org/1999/xhtml">
> 	<head>
> 		<title>Test Page</title>
> 	</head>
> 	<body>
> 		<a wicket:id="test">test</a>
> 	</body>
> </html>
> 2. Access the page in browser via mounted url, the page will display a link. 
> 3. Wait until current session is expired (do not refresh the page or click the link while waiting). 
> 4. Hit the link and below exception will be thrown:
> Message: Cannot find behavior with id: 0 on component: [ [Component id = test]]. Perhaps the behavior did not properly implement getStatelessHint() and returned 'true' to indicate that it is stateless instead of returning 'false' to indicate that it is stateful.
> 5. In wicket 1.5.0, this results in a PageExpiredException which is more comprehensive. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira