wicket - Ajax 调用不会重置页面焦点
我有一个页面,其中包含一个文本框。我已将 AjaxFormComponentUpdatingBehavior 添加到文本框 onchange ,其中我根据其 value 更新了一些其他表单元素。
据我了解, wicket 会在调用后将焦点返回到最后一个焦点组件。但是,在这种情况下,焦点不会返回到组件。所展示的错误行为仅发生在页面加载后的第一个 ajax 调用中,在后续调用中它表现良好。
出现错误时的 wicket-ajax 调试日志看起来像
INFO: Response parsed. Now invoking steps...
INFO: returned focused element: [object HTMLInputElement]
INFO: returned focused element: null
INFO: Response processed successfully.
INFO: Invoking post-call handler(s)...
INFO: refocus last focused component not needed/allowed
Now I'm no wicket Expert ,但我注意到每次 ajax 调用后 wicket 都会记录返回的焦点元素的值两次,在本例中第二次记录为 null 。
如果有人能启发我了解我可能做错了什么,我将不胜感激。感谢您的阅读。
I've a page , which contains a textbox . I've added AjaxFormComponentUpdatingBehavior to the textbox onchange , in which I update a few other form elements based on it's value .
As far as I understand , wicket would return to focus to the last focused component after the call . However , In this case , the focus isn't being returned to the component . The erroneous behavior exhibited happens only for the first ajax call made after the page is loaded , on subsequent calls it behaves fine.
The wicket-ajax debug log in case of the error looks like
INFO: Response parsed. Now invoking steps...
INFO: returned focused element: [object HTMLInputElement]
INFO: returned focused element: null
INFO: Response processed successfully.
INFO: Invoking post-call handler(s)...
INFO: refocus last focused component not needed/allowed
Now I'm no wicket expert , but I have noticed that after every ajax call wicket logs the value of returned focused element twice , the second of which is logging null in this case .
I'd be grateful if anyone could enlighten me on what I could be doing wrong . Thanks for reading .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我对可能出现问题的最佳猜测。
Wicket 通过使用组件的 DOM id 设置变量来跟踪最后一个焦点元素。
如果组件的 DOM id 在事件期间发生更改(Wicket 可以做到这一点,而您却不知道:)),则前端中最后一个焦点元素引用将变得无效。
Here's my best guess as to what might be the problem.
Wicket keeps track of the last focused element is by setting a variable with the DOM id of the component .
If the DOM id of the component gets changed during the event (Wicket can do that , without you knowing :) ) , the last focused element reference in the front-end becomes invalid .