Hmmm but why not just do it with a LDM? Im a bit puzzled, heres what I do:

RadioGroup<EventType> eventTypeRadioGroup = new RadioGroup<EventType>(
                   "eventType");
eventTypeRadioGroup.setLabel(new Model<String>("Type of Event"));

ListView<EventType> eventTypesListView = new ListView<EventType>(
                   "eventTypeRadios", Arrays.asList(EventType.values())) {

               @Override
               protected void populateItem(ListItem<EventType> item) {

                   item
                           .add(new Radio<EventType>("eventType", item
                                   .getModel()));
                   item.add(new Label("label", new Model<String>(item
                           .getModel().getObject().getName())));
                   item.add(new IconPanel("icons", item.getModelObject()
                           .getIconTypes()));

               }
           };
           eventTypesListView.setReuseItems(true);
           eventTypeRadioGroup.setRequired(true);
           eventTypeRadioGroup.add(eventTypesListView);
           add(eventTypeRadioGroup);


Hmm this might be a bad example as I don't use LDM ../ But the important line are : item.add(new Radio<EventType>("eventType", item.getModel()));

if you select a certain radio within a group the group will return the radios objectmodel...


Michael O'Cleirigh wrote:
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


--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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

Reply via email to