Thanks thats taught me something about radio groups that I wasn't able to
find in the books I have. Your example was very helpful.


Michael O'Cleirigh wrote:
> 
> Hi ArchieC,
> 
> The way RadioGroup works is that it renders to a hidden field and stores 
> the selected value of the selected Radio.
> 
> i.e. the rendered markup is not that relevant and the model object for 
> the selected radio will be placed into the model for the RadioGroup when 
> the form submits.
> 
> This is how I've used it:
> 
> RadioGroup group = new RadioGroup ("group", new Model());
> 
> 
> Radio apple = new Radio ("apple", new Model (Fruit.APPLE));
> 
> Radio orange = new Radio ("orange", new Model (Fruit.ORANGE));
> 
> 
> group.setModelObject (Fruit.APPLE);
> 
> Here by default the first radio is selected.
> 
> When the form submits group.getModelObject() will return either 
> Fruit.APPLE or Fruit.ORANGE depending on the selected radio button
> 
> In your case the RadioGroup will have as its model Object the value of 
> the selected radio.getModelObject() so whatever the value of "user" is 
> coming from the PropertyModel() for the selected option.
> 
> Regards,
> 
> Mike
> 
> 
> 
>> RadioGroup group=new RadioGroup("group", new Model(id));
>>             final ArrayList <SelectOptionLevel> selectOptionLevel =
>> getDdcChoices();
>>             ListView persons=new ListView("persons", selectOptionLevel) {
>>             /**
>>              * 
>>              */
>>              private static final long serialVersionUID = 1L;
>>           
>>
>>                 protected void populateItem(ListItem item) {
>>                     SelectOptionLevel option = (SelectOptionLevel)
>> item.getModelObject();
>>                     
>>                     //Exampe of Icon  setting
>>                     item.add(new Label("levelImage", "< img
>> src='images/icons/icon1.gif'/>").setEscapeModelStrings(false));
>>      
>>                     Radio radio = new Radio(
>>                             "radio", 
>>                             new PropertyModel(modelObject, "user")           
>>                
>> <~~ Need to set the value of the radio to
>>                                                                              
>>                                            
>> my option.getValue() value.
>>                     );
>>                     item.add(radio);
>>                     item.add(new Label("name", option.getLabel()));
>>                 }
>>             };
>>             group.add(persons);
>>             add(group);
>>
>> Apart from not getting a value it all looks great just as I want.
>>   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Setting-a-relevant-value-for-radio-buttons-without-using-RadioChoice-tp20978297p21010152.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to