Tuesday, July 26, 2011

GWT widgets with radio buttons

Here's something I learned today.

First the problem, which was that setValue didn't seem to be doing anything -- my radioButton's weren't getting set. This isn't actually true. It turns out that if I scrolled down, one of the radio buttons on the page WAS getting set. Can you guess what was going on? That's right, all of the radio buttons from all sets all had the same name.

Heres the lesson: If you make a GWT widget that has radio buttons in it, and you use more than one of these widgets on a single page, you're going to need to make the name of each radio set unique.

And my solution: What I did was to use the hashCode of the panel that contains the buttons, and this worked just fine.

You're welcome!

No comments: