I got a reply for this on another forum (Javaranch).
Here is the working code:
HtmlSelectOneRadio htmlSelectOneRadio = new HtmlSelectOneRadio();
htmlSelectOneRadio.setId("_777"+random.nextInt());
htmlSelectOneRadio.setTitle("test");
/** ArrayList of Options */
ArrayList radioBtnOptionsList = new ArrayList();
radioBtnOptionsList.add(new SelectItem(new String("1"),"First Option"));
radioBtnOptionsList.add(new SelectItem(new String("2"),"Second Option"));
radioBtnOptionsList.add(new SelectItem(new String("3"),"Third Option"));
/** Adding a group of CheckBox Options */
UISelectItems radioBtnOptions = new UISelectItems();
radioBtnOptions.setValue(radioBtnOptionsList);
// Add radioButton options.
htmlSelectOneRadio.getChildren().add(radioBtnOptions);
// Select a default value.
// This will set the "First Option" to be selected default wise
htmlSelectOneRadio.setValue(new String("1"));
From: "James Ellis" <[EMAIL PROTECTED]>
Reply-To: "MyFaces Discussion" <[email protected]>
To: [email protected]
Subject: Create HtmlSelectOneRadio through backing bean
Date: Thu, 04 May 2006 16:29:41 +0000
I need to create a HtmlSelectOneRadio box and add it to a panelGrid. Can
anyone give me some sample code for how to create a radio box and
initialize it with some test data (any data will do) through a backing
bean.
My problem is I can't seem to figure out what is supposed to be in the
setValue of htmlSelectOneRadio
HtmlSelectOneRadio htmlSelectOneRadio = new HtmlSelectOneRadio();
htmlSelectOneRadio.setId("_"+random.nextInt());
htmlSelectOneRadio.setValue(??????);
htmlSelectOneRadio.setTitle("test");
And without a value nothing is being displayed on the page...