How to set focus on a Component?

I'm doing a simple DATA ENTRY program. My web apps contains the ff:

- 4- buttons (add, save, undo, del)

- table

To avoid mistakes on the data entry by a user. I make it a point to limit possible areas of risk. Like:

ie: when addButton is clicked.

- we set addButton.setDISABLED(true)

- also we set delButton.setDISABLED(true)

Problem: On the web browser, we get an error that saysn"Can't move to the focus control ... blah, blah blah"

Howdo I set the focus on other control?

[685 byte] By [davest] at [2007-11-26 11:49:29]
# 1

I suppose this is a javascript error.

If you are using firefox, could you please add what the error is that you are seeing.

How are you trying to set the focus on the other button?

You could try adding javascript code to onclick functionality of the button you are disabling.

something like:

onclick = "<client id of the button to have focus>.focus()";

deepsix at 2007-7-7 12:02:51 > top of Java-index,Development Tools,Java Tools...
# 2
I only got an error that says "undoButton is undefined"
davest at 2007-7-7 12:02:51 > top of Java-index,Development Tools,Java Tools...
# 3
Please make sure that if you access the button from the javascript,that you have the client id (something like form1:undoButton) specified.Specifying the id that you have provided in the jsp page in the javascript wont work.
deepsix at 2007-7-7 12:02:51 > top of Java-index,Development Tools,Java Tools...
# 4
Try the solution at http://blogs.sun.com/divas/entry/disabling_a_button_after_it
jetsons at 2007-7-7 12:02:51 > top of Java-index,Development Tools,Java Tools...