how to get the string in a choicegroup.popup...

here is my sample code...

Form frm=new Form("Sample");
ChoiceGroup cg=new ChoiceGroup("Sample",Choice.POPUP);
frm.append(cg);
cg.append("1");
cg.append("2");
cg.append("3");

int index=cg.getSelectedIndex();
String str=cg.getString(index);

but i got null pointer exception..
anybody knows about it????

You did not indicate selection with setSelectedIndex(int elementNum, boolean selected) . You need to select as GroupChoice is rendered without any pre-selection

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.