Hi all! :)
I am using the latest JSF Tomahawk library and Ajax4JSF components in my application.
Situation is as follows:
I've got an arbitrary number of inputfields with ajax:support:
<h:inputText id="inputfield1" value="${backing.value}" tabindex="1">
<ajax:support event="onblur"
reRender="someIds"
actionListener="${backing.updateSomething}"/>
</h:inputText>
<h:inputText id="inputfield2" value="${backing.value2}" tabindex="2">
<ajax:support event="onblur"
reRender="someIds"
actionListener="${backing.updateSomething}"/>
</h:inputText>
.
.
.
If a user enters inputfield1 and hits tab the cursor does not move to inputfield2. The reason is that onblur an ajax-request is fired and after that the tabIndex gets lost. As a workaround I did the following:
<h:inputText id="inputfield1" value="${backing.value}" tabindex="1">
<ajax:support event="onblur"
oncomplete="document.getElementById('inputfield2').select();"
reRender="someIds"
actionListener="${backing.updateSomething}"/>
</h:inputText>
<h:inputText id="inputfield2" value="${backing.value2}" tabindex="2">
<ajax:support event="onblur"
oncomplete="document.getElementById('inputfield3').select();"
reRender="someIds"
actionListener="${backing.updateSomething}"/>
</h:inputText>
.
.
.
As you can see I added the oncomplete event to the ajax:support tag. When the ajax request is done I focus the next input field via JavaScript... which works fine.
No my problem... what should I do if the user wants to step back from inputfield2 to inputfield1 using shift-tab? Is there a best practice for this problem? Am I heading into the wrong direction?
Thankful for any hint...
Nils :-)
Edited by: pos79 on Nov 14, 2008 5:55 AM
Edited by: pos79 on Nov 14, 2008 5:57 AM