Wicket - SetResponsePage 回调未触发
我正在编写我的第一个检票口应用程序,今天遇到了我的第一个障碍。问题就在这里。 我有一个包含 AjaxSubmitLink 的页面。在它的 onSubmit 事件中,我使用 setResponsePage 加载一个面板。
从我的应用程序的主页,我可以通过两种方式导航到上述页面 - 通过超链接或切换选项卡(使用 wicket-extensions 中的基本 ITab),这两种方式都使用相同的参数调用相同的构造函数。
现在,如果我使用超链接导航到该页面,则一切正常。但是,如果我使用选项卡导航到该页面,AjaxSubmitLink 不会加载该面板。正在发出一个 Ajax 请求,我可以看到服务器正在处理它,但就像没有执行回调一样。
我注意到的另一个奇怪的事情是,在后一种情况下,firebug 不会在控制台上记录我的 Ajax 请求。它在前一种情况下记录请求就好了。
我有点被难住了,有什么提示、指示或推动吗?
编辑:声明链接的代码。
editLink = new AjaxSubmitLink("editLink") {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> masterForm) {
setResponsePage(new EditPage(programId));
}
};
编辑:我检查了用 fiddler 发出的请求,不成功的 Ajax 调用返回 302,而不是 200。
更新:
我找到了一种解决方法。 fiddler 信息引导我搜索 setResponsePage 行为,这引导我到 https://issues .apache.org/jira/browse/WICKET-1703 。
无论如何,因为我并不严格需要链接的 POST 请求,所以使用 GET 来获得所需的行为。
使用 fiddler 的有趣发现:在错误的情况下,发送的请求的内容类型是 multipart/form-data 而不是 application/x-www-form-urlencoded 。
我对实际问题仍然一无所知,感谢任何解释。
I'm writing my first wicket app , and ran into my first road-block today . Here's the problem .
I have a page which contains an AjaxSubmitLink . In it's onSubmit event , I load a panel using setResponsePage .
From the homepage of my app , I can navigate to the above mentioned page in 2 ways - either by a hyperlink or by switching a tab (use a basic ITab from wicket-extensions), both of which invokes the same constructor with identical arguments.
Now if I navigate to the page using the hyperlink , everything works fine . However , if I use the tab to navigate to the page , the AjaxSubmitLink doesnt load the panel . There's an Ajax request being made , I can see the server processing it , but it's like no callback is being executed .
Another strange thing I noticed , in the latter case , firebug doesn't log my Ajax requests on the console . It logs requests in the former case just fine .
I'm kinda stumped here , any hints,pointers or nudges ?
Edit : Code declaring the link .
editLink = new AjaxSubmitLink("editLink") {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> masterForm) {
setResponsePage(new EditPage(programId));
}
};
Edit : I inspected the requests made with fiddler , the unsuccessful Ajax calls are returning a 302 , instead of 200.
UPDATE :
I kinda found a workaround . The fiddler information lead me to search for the setResponsePage behaviour , which lead me to https://issues.apache.org/jira/browse/WICKET-1703 .
Anyway since I didnt strictly need a POST request for the link , used a GET instead to get the desired behaviour .
Interesting find using fiddler : the content-type of the request sent is multipart/form-data rather than application/x-www-form-urlencoded in the erroneous case.
I'm still kind of in the dark on the actual issue , appreciate any explanations .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
setResponsePage()
应该获取 .class 文件或实例化类。喜欢或
setResponsePage()
should get a .class file or a instantiated class instead. likeor