i was refusing to use models (how stubborn :) but i think you're right - not a very mean workaround that just works fine.
thanks! francisco On Fri, Feb 27, 2009 at 4:41 PM, Jonas <[email protected]> wrote: > Have you tried this: add models to the components (even though you don't use > on them), and store the value associated with the Radio you want checked > in the RadioGroup's model: > > final RadioGroup<Boolean> group = new RadioGroup<Boolean>("group", > new Model(Boolean.TRUE)); > Radio<Boolean> radio1 = new Radio<Boolean>("radio1", new > Model(Boolean.TRUE)); > radio1.add(new AjaxEventBehavior("onclick") { > �...@override > protected void onEvent(AjaxRequestTarget target) { > (do stuff) > } > }); > > Radio<Boolean> radio2 = new Radio<Boolean>("radio2", new > Model(Boolean.FALSE)); > radio2.add(new AjaxEventBehavior("onclick") { > �...@override > protected void onEvent(AjaxRequestTarget target) { > (do stuff) > } > }); > group.add(radio1); > group.add(radio2); > add(group); > > > > On Fri, Feb 27, 2009 at 4:35 PM, francisco treacy > <[email protected]> wrote: >> hi people, >> >> i'm quite puzzled with this little problem: >> >> i have two Radio buttons within a RadioGroup. both radios have an >> ajaxeventbehavior("onclick") attached to them, and there are no models >> backing those components. this works fine. >> >> my problem is i want the *first* option to be "checked" by default, >> but no matter what the second one gets checked by default in the >> browser. >> yes, i played around with *checked="checked"* in my html but wicket >> always outputs *checked="checked"* on the second radio button - and >> the browser (firefox) interprets that by checking the second one. >> >> code: >> >> final RadioGroup<Void> group = new RadioGroup<Void>("group"); >> Radio<Void> radio1 = new Radio<Void>("radio1"); >> radio1.add(new AjaxEventBehavior("onclick") { >> �...@override >> protected void onEvent(AjaxRequestTarget target) { >> (do stuff) >> } >> }); >> >> Radio<Void> radio2 = new Radio<Void>("radio2"); >> radio2.add(new AjaxEventBehavior("onclick") { >> �...@override >> protected void onEvent(AjaxRequestTarget target) { >> (do stuff) >> } >> }); >> group.add(radio1); >> group.add(radio2); >> add(group); >> >> >> <span wicket:id="group"> >> <input type="radio" wicket:id="radio1" >> checked="checked" /> Discussie >> <input type="radio" wicket:id="radio2" /> >> Opiniepeiling >> </span> >> >> wicket outputs: >> >> <input type="radio" wicket:id="radio1" checked="checked" id="radio122" >> name="tabs:panel:group" value="radio63" onclick="var >> wcall=wicketAjaxGet('?wicket:interface=:4:tabs:panel:group:radio1:1:IBehaviorListener:0:',null,null, >> function() {return Wicket.$('radio122') != null;}.bind(this));"/> >> Discussie >> <input type="radio" wicket:id="radio2" >> id="radio223" >> name="tabs:panel:group" value="radio64" checked="checked" onclick="var >> wcall=wicketAjaxGet('?wicket:interface=:4:tabs:panel:group:radio2:1:IBehaviorListener:0:',null,null, >> function() {return Wicket.$('radio223') != null;}.bind(this));"/> >> Opiniepeiling >> >> >> any ideas of what could be going wrong? thanks in advance, >> >> francisco >> >> --------------------------------------------------------------------- >> 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]
