Description
I'd like to have a field/request header "nextFoxusedElementId" to be added to ajaxrequests (to be retrieved via AjaxRequestTarget.getNextFocusedElementId() ) so that I can append javascript to the ajaxrequest to manipulate the newly focused element.
Example:
Two textfields, A and B. I've added an ajax event behavior for the "onblur"-event to textfield A. Now when textfield A has focus and I then move focus to textfield B, wicket writes the id of textfield A to the ajaxrequest, saves the id of textfield B, removes focus from textfield B, handles ajaxrequest (including any and all javascript) and then refocuses textfield B.
However, I want the text inside textfield B to be highlighted. I can append javascript to the ajaxrequest to do #textfieldB.select() and set focusComponent(null) on the AjaxRequestTarget but what if textfield B is not the newly focused component? What if the focus instead went to checkbox C, for instance? Since I don't know what element received the focus I can't check to see if it's textfield B. That's why I'd like to be able to request the newly focused component from the ajaxrequest.
AFAICT, this shouldn't be too much work, since the id of the newly focused component is already saved, so it looks like it might just be a case of waiting for that save to be done. But maybe that is an oversimplification and is it quite tricky (or is the wait-time too long) to get the sending of the ajaxrequest to wait for the new component to receive focus.