Reputation: 63
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 .
Upvotes: 2
Views: 1375
Reputation: 1369
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 .
Upvotes: 1