具有历史记录API的Wicket AjaxEventBehavior

问题描述 投票:0回答:1

我正在使用带有历史记录API的Wicket7.x。我目前正在尝试为“ onpopstate”连接一个AjaxEventBehavior。我有在我执行history.pushState时添加对象的代码,我的问题是我无法使用onEvent从Java端访问此额外信息。

示例pushState:

target.appendJavaScript("history.pushState({query: '" + 
searchResults.getQueryString() + "'}, null, window.location.pathname);");

EventBehavior:

this.getPage().add(new AjaxEventBehavior("onpopstate")
{     
     @Override
     protected void onEvent(AjaxRequestTarget target)
     {
         //code to get query defined in pushState
     }
});

updateAjaxAttributes不是解决方案,因为仅在呈现页面时才调用它。调用popstate时,我需要发送这些额外的数据。

java ajax wicket html5-history wicket-7
1个回答
1
投票

updateAjaxAttributes实际上可以为您提供帮助。 AjaxRequestAttributes使您还可以指定动态额外属性(有关更多信息,请参见here)。这些参数是在AjaxEventBehavior触发之前在客户端动态计算的,并作为请求参数发送。

© www.soinside.com 2019 - 2024. All rights reserved.