简体   繁体   中英

wicket: StalePageException

I am using wicket 6.20. In this wicket page I am using an AbstractDefaultAjaxBehavior for receiving mouse clicks (x,y coordinate) inside wicket:

class CallFromJavaScript extends AbstractDefaultAjaxBehavior {

    private static final long serialVersionUID = -123956851227148114L;

    @Override
    public void renderHead(Component component, IHeaderResponse response) {
        super.renderHead(component, response);

        String callbackUrl = getCallbackUrl().toString();

        String javaScript = "$(document).ready(function()"
                + "{$(document).click(function(e) {"
                + "Wicket.Ajax.get({ u: '" + callbackUrl
                + "&x='+e.clientX+'&y='+e.clientY});});});";
        response.render(OnDomReadyHeaderItem.forScript(javaScript));

    }

    @Override
    protected void respond(final AjaxRequestTarget target) {
        Request request = RequestCycle.get().getRequest();
        x = Integer.parseInt(request.getRequestParameters()
                .getParameterValue("x").toString());
        y = Integer.parseInt(request.getRequestParameters()
                .getParameterValue("y").toString());

        //more code....

        }
    }
}

If I open the page with one user (one session), everything works fine. But If I open the page with an other user(different session/other computer) I receive a StalepageException:

RequestCycleExtra/qtp848034544-122 - /wicket/wicket/page?2-.... WARN : - Handling the following exception org.apache.wicket.core.request.mapper.StalePageException: null

I have noticed that, If I click with computer A on the page, java goes into the renderHead method. If I click with computer B on the page java goes into the renderHead method again. Alternately java goes into the renderHead method.

If I only open the page with one computer (one session) java goes only a single time into the renderHead method.

Could anybody help me?

Which URL are you using to open the page on the second computer? Specifically, does the URL contain the page ID? Page IDs are only valid within the same session; you can't open the same page instance from within another session. You can only create another instance of the same page class in another session.

I think some clarification between page class vs. page instance is needed here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM