final MyObject object = (MyObject)
item.getModelObject();
                               final RadioGroup radioGroup = new
RadioGroup("radio-group", new Model());

                               final Model radioModel1 = new
Model(myObject1);
                               final Model radioModel2 = new
Model(myObject2);
                               final Model radioModel3 = new
Model(myObject3);
                               radioGroup.add(new
Radio("radio1",radioModel1));
                               radioGroup.add(new
Radio("radio2",radioModel2));
                               radioGroup.add(new
Radio("radio2",radioModel3));

                               // set default value for radio.
                               if (object.isTrue() != null &&
object.isTrue()) {

radioGroup.setModel(radioModel1);
                               } else if (object.isFalse() != null &&
object.isFalse()) {

radioGroup.setModelObject(radioModel2.getObject());
                               } else {

radioGroup.setModelObject(radioModel3.getObject());
                               }
                               item.add(radioGroup);


On Fri, May 2, 2008 at 3:09 PM, Patel, Sanjay <[EMAIL PROTECTED]> wrote:

> Does anyone have any input on this? Help will be appreciated.
>
> Thanks,
> Sanjay
>
> -----Original Message-----
> From: Patel, Sanjay [mailto:[EMAIL PROTECTED]
> Sent: Thursday, May 01, 2008 8:52 AM
> To: [email protected]
> Subject: RE: ListView is not gettting updated
>
> I set model of the radio on the group because I want one of the radio in
> the group to be selected based on some condition.
>
> Let me tell you my exact requirement. There are 12 diff. rows having
> three radio buttons in each row.  I can select only one radio in each
> row so I put all three radios in radio group. Also I want one of the
> radio in the group to be selected by default based on some condition so
> I set model of radio on the group.
>
> Please let me know the better way of doing this.
>
> Thanks,
> Sanjay.
>
> -----Original Message-----
> From: Johan Compagner [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, April 30, 2008 7:27 PM
> To: [email protected]
> Subject: Re: ListView is not gettting updated
>
> And thats logical, your code looks weird.
> You cant set the model of a radio also on the group.
> Then the submit will update the selected in the radio groups model.
> Butthen the radio model is also uopdated. So that one is still
> selected..
>
> On 4/30/08, Patel, Sanjay <[EMAIL PROTECTED]> wrote:
> > I already tried it but it is not working.
> >
> > I have to do following (which I don't want) to update the listView
> > after I submit the form.
> >
> > listView.setModel(new Model((Serializable) updatedList));
> >
> > -----Original Message-----
> > From: Igor Vaynberg [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, April 30, 2008 2:02 PM
> > To: [email protected]
> > Subject: Re: ListView is not gettting updated
> >
> > listview.setreuseitems(true), read listview's javadoc
> >
> > -igor
> >
> > On Wed, Apr 30, 2008 at 10:59 AM, Patel, Sanjay <[EMAIL PROTECTED]>
> > wrote:
> > >
> > >  Hi,
> > >
> > >  I am using ListView and and each item in the listview is
> RadioGroup.
> > > Now  the problem is, If radio1 is selected and I select radio2 and
> > > submit  the form the selection goes back to radio1. What is wrong
> > > with
> >
> > > following  code?
> > >
> > >  final ListView listView = new ListView("abc", myList) {
> > >                         protected final void populateItem(final
> > > ListItem
> > >  item) {
> > >                                 final MyObject object = (MyObject)
> > > item.getModelObject();
> > >                                 final RadioGroup radioGroup = new
> > > RadioGroup("radio-group", new Model());
> > >
> > >                                 final Model radioModel1 = new
> > > Model(myObject1);
> > >                                 final Model radioModel2 = new
> > > Model(myObject2);
> > >                                 final Model radioModel3 = new
> > > Model(myObject3);
> > >
> > >                                 radioGroup.add(new Radio("radio1",
> > > radioModel1));
> > >                                 radioGroup.add(new Radio("radio2",
> > > radioModel2));
> > >                                 radioGroup.add(new Radio("radio2",
> > > radioModel3));
> > >
> > >                                 // set default value for radio.
> > >                                 if (object.isTrue() != null &&
> > >  object.isTrue()) {
> > >
> > >  radioGroup.setModel(radioModel1);
> > >                                 } else if (object.isFalse() != null
> > > &&
> > >  object.isFalse()) {
> > >
> > >  radioGroup.setModel(radioModel2);
> > >                                 } else {
> > >
> > >  radioGroup.setModel(radioModel3);
> > >                                 }
> > >                                 item.add(radioGroup);
> > >                         }
> > >                 };
> > >                 form.add(listView);
> > >
> > >
> > >
> > > --------------------------------------------------------------------
> > > -  To unsubscribe, e-mail: [EMAIL PROTECTED]
> > >  For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to