views:

30

answers:

1

I have four text boxes and one ListBox placed in a FlexTable. I make a request to server to get the list of data to populate the ListBox. When the response comes back, I populate the ListBox. This is stealing focus from the TextBox where I am giving input.

What I want is after populating the ListBox, return the focus back to the exact location where it was before.

How to do it in GWT or even in java script?

+1  A: 

If You need generic solution, create class, that implements BlurHandler or FocusHandler interface. Assign object of this class to your text boxes. In onFocus/onBlur method just remember last focused widget. After populating of ListBox just call something like restoreFocus() which will call setFocus(true) on that remebered object.

Bartek Jablonski
Nice idea, it will work for me (though I still has to check if the cursor position returns exactly to the same character in the text box) since I only have 2 or 3 text boxes; but how everybody is handling this scenario (it seems un-avoidable in AJAX apps)?
Reddy
It seems correct approach but somehow it is not working.
Reddy