|
We have a button that, when clicked, should deselect ALL radio
buttons in a separate radio group. Can this be done in Wicket? Yours
sincerely, Chris
Colman Pagebloom
Team Leader, Step
Ahead Software pagebloom
- your business & your website growing together Email: [hidden email] Website: <a
href="blocked::http://www.pagebloom.com/"
title="blocked::http://www.pagebloom.com/ blocked::http://pagebloom.comm/">http://www.pagebloom.com <a
href="blocked::http://develop.stepaheadsoftware.com/"
title="blocked::http://develop.stepaheadsoftware.com/">http://develop.stepaheadsoftware.com |
|
What about using Javascript? e.g. jQuery:
$('input:radio').attr('checked', false); or $('input[name=myRadio]:radio').attr('checked', false); -Tom On 31.05.2012 at 08:20 Chris Colman wrote: > We have a button that, when clicked, should deselect ALL radio buttons in a separate radio group. > > Can this be done in Wicket? > > Yours sincerely, > > Chris Colman |
|
Hi,
On Thu, May 31, 2012 at 10:04 AM, Thomas Götz <[hidden email]> wrote: > What about using Javascript? e.g. jQuery: > > $('input:radio').attr('checked', false); > > or > > $('input[name=myRadio]:radio').attr('checked', false); > I guess he will need to update the server state as well. @Chris: Can't you reset the RadioGroup's model so that none of the Radios models match and re-render the whole group ? > > -Tom > > > > On 31.05.2012 at 08:20 Chris Colman wrote: > >> We have a button that, when clicked, should deselect ALL radio buttons in a separate radio group. >> >> Can this be done in Wicket? >> >> Yours sincerely, >> >> Chris Colman > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
>@Chris: Can't you reset the RadioGroup's model so that none of the
>Radios models match and re-render the whole group ? That's what I tried first but it didn't work for some reason. > >> >> -Tom >> >> >> >> On 31.05.2012 at 08:20 Chris Colman wrote: >> >>> We have a button that, when clicked, should deselect ALL radio buttons >in a separate radio group. >>> >>> Can this be done in Wicket? >>> >>> Yours sincerely, >>> >>> Chris Colman >> > > > >-- >Martin Grigorov >jWeekend >Training, Consulting, Development >http://jWeekend.com > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [hidden email] >For additional commands, e-mail: [hidden email] --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
In reply to this post by Martin Grigorov-4
>@Chris: Can't you reset the RadioGroup's model so that none of the
>Radios models match and re-render the whole group ? Bingo! I got it working. I wasn't adding the radio button to the target in the event handler. This is what works: group2Choice1Radio.add(new AjaxEventBehavior("onclick") { @Override protected void onEvent(AjaxRequestTarget target) { // there is no radio button for o1None so choosing this // deselects all radio buttons setGroup1Option(new Integer(MyModel.o1None)); target.add(group1Choice1Radio); target.add(group1Choice2Radio); } }); Using this option I need to target.add() for each individual radio button in the group I want to have deselected. I tried using the RadioGroup object as the component added to the target like: target.add(option1Group); but got: Last cause: Ajax render cannot be called on component that has setRenderBodyOnly enabled. Component: [RadioGroup [Component id = option1Group]] Which makes sense because the RadioGroup component's tags disappear when the markup is rendered. Regards, Chris --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
Doh! That approach fails when I target.add a second radio button.
I needed to create a new MarkupContainer to wrap the group in and then I target.add() that div and deselection of all items works well. So it looks like this: <span wicket:id="radioGroup1"> <div wicket:id="radioGroup1Div"> <input id="choice1" name="option1" type="radio" value="01" wicket:id="choice1"> <input id="choice2" name="option1" type="radio" value="02" wicket:id="choice2"> </div> </span> >>@Chris: Can't you reset the RadioGroup's model so that none of the >>Radios models match and re-render the whole group ? > >Bingo! I got it working. > >I wasn't adding the radio button to the target in the event handler. > >This is what works: > > group2Choice1Radio.add(new AjaxEventBehavior("onclick") { > @Override > protected void onEvent(AjaxRequestTarget target) { > // there is no radio button for o1None so >choosing this > // deselects all radio buttons > setGroup1Option(new Integer(MyModel.o1None)); >target.add(group1Choice1Radio); > target.add(group1Choice2Radio); > } > }); > >Using this option I need to target.add() for each individual radio >button in the group I want to have deselected. > >I tried using the RadioGroup object as the component added to the >like: > >target.add(option1Group); > >but got: > >Last cause: Ajax render cannot be called on component that has >setRenderBodyOnly enabled. Component: [RadioGroup [Component id = >option1Group]] > >Which makes sense because the RadioGroup component's tags disappear >the markup is rendered. > >Regards, >Chris > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [hidden email] >For additional commands, e-mail: [hidden email] --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
On Thu, May 31, 2012 at 11:48 AM, Chris Colman
<[hidden email]> wrote: > Doh! That approach fails when I target.add a second radio button. > > I needed to create a new MarkupContainer to wrap the group in and then I > target.add() that div and deselection of all items works well. > > So it looks like this: > > <span wicket:id="radioGroup1"> > <div wicket:id="radioGroup1Div"> > <input id="choice1" name="option1" type="radio" > value="01" wicket:id="choice1"> > <input id="choice2" name="option1" type="radio" > value="02" wicket:id="choice2"> > > > </div> > </span> <div> inside <span> is invalid HTML. I know that one of those is not rendered at all because it is attached to the RadioGroup but ... can't you do radioGroup.setRenderBodyOnly(false) and remove the extra component ? > >>>@Chris: Can't you reset the RadioGroup's model so that none of the >>>Radios models match and re-render the whole group ? >> >>Bingo! I got it working. >> >>I wasn't adding the radio button to the target in the event handler. >> >>This is what works: >> >> group2Choice1Radio.add(new AjaxEventBehavior("onclick") { >> @Override >> protected void onEvent(AjaxRequestTarget target) { >> // there is no radio button for o1None so >>choosing this >> // deselects all radio buttons >> setGroup1Option(new Integer(MyModel.o1None)); >>target.add(group1Choice1Radio); >> target.add(group1Choice2Radio); >> } >> }); >> >>Using this option I need to target.add() for each individual radio >>button in the group I want to have deselected. >> >>I tried using the RadioGroup object as the component added to the > target >>like: >> >>target.add(option1Group); >> >>but got: >> >>Last cause: Ajax render cannot be called on component that has >>setRenderBodyOnly enabled. Component: [RadioGroup [Component id = >>option1Group]] >> >>Which makes sense because the RadioGroup component's tags disappear > when >>the markup is rendered. >> >>Regards, >>Chris >> >>--------------------------------------------------------------------- >>To unsubscribe, e-mail: [hidden email] >>For additional commands, e-mail: [hidden email] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
>> <span wicket:id="radioGroup1">
>> <div wicket:id="radioGroup1Div"> >> <input id="choice1" name="option1" type="radio" >> value="01" wicket:id="choice1"> >> <input id="choice2" name="option1" type="radio" >> value="02" wicket:id="choice2"> >> >> >> </div> >> </span> > ><div> inside <span> is invalid HTML. I know that one of those is not >rendered at all because it is attached to the RadioGroup but ... >can't you do radioGroup.setRenderBodyOnly(false) and remove the extra >component ? Hmmm, probably could do it that way. > > >> >>>>@Chris: Can't you reset the RadioGroup's model so that none of the >>>>Radios models match and re-render the whole group ? >>> >>>Bingo! I got it working. >>> >>>I wasn't adding the radio button to the target in the event handler. >>> >>>This is what works: >>> >>> group2Choice1Radio.add(new AjaxEventBehavior("onclick") { >>> @Override >>> protected void onEvent(AjaxRequestTarget target) { >>> // there is no radio button for o1None so >>>choosing this >>> // deselects all radio buttons >>> setGroup1Option(new Integer(MyModel.o1None)); >>>target.add(group1Choice1Radio); >>> target.add(group1Choice2Radio); >>> } >>> }); >>> >>>Using this option I need to target.add() for each individual radio >>>button in the group I want to have deselected. >>> >>>I tried using the RadioGroup object as the component added to the >> target >>>like: >>> >>>target.add(option1Group); >>> >>>but got: >>> >>>Last cause: Ajax render cannot be called on component that has >>>setRenderBodyOnly enabled. Component: [RadioGroup [Component id = >>>option1Group]] >>> >>>Which makes sense because the RadioGroup component's tags disappear >> when >>>the markup is rendered. >>> >>>Regards, >>>Chris >>> >>>--------------------------------------------------------------------- >>>To unsubscribe, e-mail: [hidden email] >>>For additional commands, e-mail: [hidden email] >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [hidden email] >> For additional commands, e-mail: [hidden email] >> > > > >-- >Martin Grigorov >jWeekend >Training, Consulting, Development >http://jWeekend.com > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [hidden email] >For additional commands, e-mail: [hidden email] --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
| Powered by Nabble | Edit this page |
