Hi Nino,
I believe that this is not what Archie asked about, he wanted to place
database id's in the value of the radios.. Dont know why he wanted to
though... I might have gotten it wrongly though..
You're right that he wanted to use the database id but from his example
there didn't seem to be any client side use of this information. My
thinking is that he renders a list of users denoted by radio buttons and
he want to encode the user id (for a LDM?) as the value for use on the
form submission processing (i.e. which user to work with in the next stage).
Because there is no requirement for the user id on the client side there
is no reason to care about the value used by the Radio as it is just
used internally by RadioGroup to know which model object to use when the
form is submitted.
There is no need for an IChoiceRenderer in this case because the Model
object of each Radio is never rendered.
He should just encode what he needs in the Model of each Radio and
expect to find it in the model of the RadioGroup when the form submits.
In his example:
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
Model(option.getValue()) // <-- this is how to wire the Radio Model
item.add(radio);
item.add(new Label("name", option.getLabel()));
}
};
group.add(persons);
add(group);
This will make group.getModelObject() return the option.getValue() (i.e
the user id) for the selected view item and allow him to proceed to the
next step.
Regards,
Mike