Radio Button Value/Caption

Hi,

The situation is I have a set of radio button, it has two radio buttons. What I cannot figure out is how to get the value of which ever i choose, either the FIRST CHOICE or the SECOND CHOICE, and display it to a tab.

The sample code goes like this:


final OptionGroup SampleOptions= new OptionGroup("");
	layoutSampleOption.addComponent(SampleOptions); // supposedly there's a layout code given for the layoutSampleOption

	SampleOptions.addItem(0);
	SampleOptions.setItemCaption(0, "FIRST CHOICE");
	SampleOptions.addItem(1);
	SampleOptions.setItemCaption(1, "SECOND CHOICE");
	SampleOptions.select(0);
	SampleOptions.setNullSelectionAllowed(false);
	SampleOptions.setHtmlContentAllowed(true);
	SampleOptions.setImmediate(true);

How can I get which ever i ticked the radio buttons caption to display on my tab? Would you care to help or just tips and references.
Thank you!

Regards,
Chi

Use SampleOptions.getValue to get the ItemId of the selected Option. When you’re not in MultiSelect mode it will return either 0 or 1 (or null if nothing is selected for some reason). When you are in MultiSelect mode it returns a Set of ItemIds.