Hi Rodrigo Thanks for your help, but that's not the point. The point is, I need a way to make the radio work the same way textField works, for example. I have a dynamic list of phones and I want the auto bind of propertyModel automatically set the boolean property of my object to true or false according to user choice.
Thank you Marco On Tue, Aug 9, 2011 at 4:34 PM, Rodrigo Heffner <[email protected]> wrote: > Hi Marco, > > I'm not sure why this is happening. I would probably add an > AjaxFormComponentUpdatingBehavior to your radio (here is an example > http://wicketstuff.org/wicket13/ajax/choice) and use some debug lines > to check values. Note that your components must be inside a form > (which I believe yours must be anyways). > > Here's how I think the code would look like: > > //let's say that modelChoices is an array of strings that contains > "default" in it > final RadioChoice radio = new RadioChoice("default", > model.bind("default"), modelChoices); > radio.setOutputMarkupId(true); > > radio.add(new AjaxFormComponentUpdatingBehavior("onchange") > { > protected void onUpdate(AjaxRequestTarget target) > { > target.addComponent(this.getComponent()); > //debug here or add log lines to see the value of > this.getComponent().getDefaultModelObject(); > } > }); > > Sorry this isn't a solution, but it's where I'd start looking for > something. I'm sure someone with more experience may have a much > better suggestion. > > On Tue, Aug 9, 2011 at 7:19 PM, Marco Aurélio Silva <[email protected]> wrote: >> Hi Rodrigo, >> >> Thanks for the fast response, but that approach didn't solve the >> problem. Actually, the problem is not the CompoundPropertyModel, if I >> use a PropertyModel instead it wouldn't work as well... in both cases >> only the textField is updating my model, the radio does not. >> >> Thanks >> Marco >> >> On Tue, Aug 9, 2011 at 4:13 PM, Rodrigo Heffner >> <[email protected]> wrote: >>> Please change my TextField line for >>> >>> add(TextField("number", model.bind("number"))); >>> >>> Please check parenthesis as well :) I'm not working now and my IDE is not >>> open >>> >>> Sorry! >>> >>> On Tue, Aug 9, 2011 at 7:12 PM, Rodrigo Heffner >>> <[email protected]> wrote: >>>> Hi Marco, >>>> >>>> I haven't tested this, but I believe this should do the trick: >>>> >>>> class PhoneNumber { >>>> >>>> String number; >>>> boolean default; >>>> >>>> /* Add getters and setters for both */ >>>> >>>> } >>>> >>>> public void EditPhonePanel(String id, PhoneNumber phoneNumber) { >>>> >>>> CompoundPropertyModel model = new CompoundPropertyModel(phoneNumber); >>>> >>>> add(TextField("number"), model.bind("number")); >>>> >>>> add(Radio("default", model.bind("default"))); >>>> >>>> } >>>> >>>> Let me know if this works. >>>> >>>> >>>> Cheers, >>>> Rodrigo >>>> >>>> On Tue, Aug 9, 2011 at 6:48 PM, Marco Aurélio Silva <[email protected]> >>>> wrote: >>>>> Hi All >>>>> >>>>> I'm having problems to make a radio component work the way I need. >>>>> >>>>> I have a list of PhoneNumber objects: >>>>> >>>>> class PhoneNumber { >>>>> >>>>> String number; >>>>> boolean default; >>>>> } >>>>> >>>>> The list can have only one entry set as default value. I'm trying to >>>>> make the radio button set the value of default in each object, so when >>>>> I submit the form to save the object my model is synced with user >>>>> changes. I don't want to set the value in the radioGroup model. >>>>> >>>>> I've created a Panel to edit a single phoneNumber object: >>>>> >>>>> >>>>> public void EditPhonePanel(String id, PhoneNumber phoneNumber) { >>>>> >>>>> setModel(new CompoundPropertyModel(phoneNumber)); >>>>> >>>>> add(TextField("number")); >>>>> >>>>> add(Radio("default")); >>>>> >>>>> } >>>>> >>>>> >>>>> And I'm using a repeater to add one EditPhonePanel for each phone in my >>>>> list. >>>>> >>>>> The number property of PhoneNumber object is being updated as >>>>> expected, but I don't know how to make the radio button update the >>>>> default property. Can someone help me? Thanks in advance! >>>>> >>>>> I'm using wicket 1.3.6 and java 5 >>>>> >>>>> Marco Silva >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: [email protected] >>>>> For additional commands, e-mail: [email protected] >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> Rodrigo H M Bezerra >>>> >>> >>> >>> >>> -- >>> Rodrigo H M Bezerra >>> >>> --------------------------------------------------------------------- >>> 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] >> >> > > > > -- > Rodrigo H M Bezerra > > --------------------------------------------------------------------- > 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]
