views:

1917

answers:

2

I have following code:

final Radio trDelRadio = new Radio();
trDelRadio.setName("TDRADIO");
trDelRadio.setBoxLabel("Training");

final Radio cdcRadio = new Radio();
cdcRadio.setName("CDCRADIO");
cdcRadio.setBoxLabel("Content");

final Radio msRadio = new Radio();
msRadio.setName("MSRADIO");
msRadio.setBoxLabel("Management");

final Radio osRadio = new Radio();
osRadio.setName("OSRADIO");
osRadio.setBoxLabel("Outsourcing");


final RadioGroup radioGroup = new RadioGroup();
radioGroup.setOrientation(Orientation.VERTICAL);
radioGroup.add(trDelRadio);
radioGroup.add(cdcRadio);
radioGroup.add(msRadio);
radioGroup.add(osRadio);
radioGroup.addListener(Events.Change, new Listener<BaseEvent>(){
       public void handleEvent(BaseEvent be) {
              GWT.log("Service type: " + radioGroup.getValue().getBoxLabel(), null);
        }
});

In this code I'm using GXT 2.0.1 create four radio buttons and then combining them into the radio button group.

Line

GWT.log("Service type: " + radioGroup.getValue().getBoxLabel(), null);

is retrieving Label of selected check box and works fine, but when I'm trying to get name or any other information it's getting value of the RadioGroup. What am I doing wrong here? How do I get selected radio button in RadioGroup?

A: 

Can i ask you why aren't you using JRadioButton instead ? It's the same thing but it's in the default java API. Then you use ButtonGroup to link them. And you can call buttongroup.getSelectedJRadioButton() to get the selected one.

Unless you really don't want to make the switch... But i suggest you do : more documentation, well known to al lot a developers, etc.

The follwing link can help you in this direction.

Silence
This question is regarding Google Web Toolkit, a framework for building web applications. It uses the Java Language, but does not emulate the entire Java API. This is especially the case for UI objects, which are shown on a web page instead of being shown natively. As such, JRadioButton is not an option here.
Wesley
Wow... would never have guessed because it's not MENTIONNED anywhere ! The only keyword is java.
Silence
A: 

I use radio.setValueAttribute(String value) method to store value.