You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Dmitriy Neretin <dm...@googlemail.com> on 2012/06/15 10:01:49 UTC

"ChangeListener" for the RadioGroup Component

Hi all,

I have a little problem with my RadioGroup component. I have 2 radio
buttons inside of a ListView, witch is inside of the RadioGroup I mentioned
above. The amount of the radios is not predefined that's because I use
RadioGroup instead of RadioChoise. There can be 2 or 1000...

The Problem is following: I also have a Label below that RadioGroup and I
want that this label updates itself every time I select the other radio
button. I tried to override the onSelectionChanged method of the RadioGroup
but the method will not be executed! (I set a method- breakpoint on it)

What do I wrong?

The whole thing looks like that:

RadioGroup
  ListView
   Rado, Text, Links etc.

Label to update

RadioGroup
  - o Option A
  - o Option B

Label: You have selected option A/option B

Thank you!
Dmitriy

Re: "ChangeListener" for the RadioGroup Component

Posted by Dmitriy Neretin <dm...@googlemail.com>.
Perfect! Thank you!

2012/6/15 Martin Grigorov <mg...@apache.org>

> either make 'sites' final or use Wicket events (
> http://www.wicket-library.com/wicket-examples/events/ )
>
> On Fri, Jun 15, 2012 at 12:42 PM, Dmitriy Neretin
> <dm...@googlemail.com> wrote:
> > Thanks! It was really helpful! But I am only to 99% ready :)
> >
> > There is a little problem in your code example:
> >
> > if I make so:
> > label.setDefaultModelObject(sites.getModelObject());
> >
> > I get a compiler error: "Cannot refer to a non-final variable sites
> inside
> > an inner class..." Is there any workaround for this?
> >
> > Thank you!
> >
> >
> > 2012/6/15 Martin Grigorov <mg...@apache.org>
> >
> >> Something like:
> >>
> >> final Label label = ...
> >> RadioChoice<String> sites = new RadioChoice<String>("site", SITES);
> >>                sites.add(new AjaxFormChoiceComponentUpdatingBehavior()
> >>                {
> >>                        @Override
> >>                        protected void onUpdate(AjaxRequestTarget target)
> >>                        {
> >>
> >> label.setDefaultModelObject(sites.getModelObject());
> >>                                target.add(label);
> >>                        }
> >>                });
> >>
> >> On Fri, Jun 15, 2012 at 11:25 AM, Dmitriy Neretin
> >> <dm...@googlemail.com> wrote:
> >> > Thanks!
> >> >
> >> > Can you describe how can I use the
> >> AjaxFormChoiceComponentUpdatingBehavior()
> >> > with the label?
> >> >
> >> > 2012/6/15 Martin Grigorov <mg...@apache.org>
> >> >
> >> >> Hi,
> >> >>
> >> >> #onSelectionChanged() works only if you override
> >> >> #wantOnSelectionChanged() to return true.
> >> >> Otherwise you can also use AjaxFormChoiceComponentUpdatingBehavior()
> >> >> and update the label with Ajax.
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> >> >>
> >> >>
> >>
> >>
> >>
> >> --
> >> Martin Grigorov
> >> jWeekend
> >> Training, Consulting, Development
> >> http://jWeekend.com
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: "ChangeListener" for the RadioGroup Component

Posted by Martin Grigorov <mg...@apache.org>.
either make 'sites' final or use Wicket events (
http://www.wicket-library.com/wicket-examples/events/ )

On Fri, Jun 15, 2012 at 12:42 PM, Dmitriy Neretin
<dm...@googlemail.com> wrote:
> Thanks! It was really helpful! But I am only to 99% ready :)
>
> There is a little problem in your code example:
>
> if I make so:
> label.setDefaultModelObject(sites.getModelObject());
>
> I get a compiler error: "Cannot refer to a non-final variable sites inside
> an inner class..." Is there any workaround for this?
>
> Thank you!
>
>
> 2012/6/15 Martin Grigorov <mg...@apache.org>
>
>> Something like:
>>
>> final Label label = ...
>> RadioChoice<String> sites = new RadioChoice<String>("site", SITES);
>>                sites.add(new AjaxFormChoiceComponentUpdatingBehavior()
>>                {
>>                        @Override
>>                        protected void onUpdate(AjaxRequestTarget target)
>>                        {
>>
>> label.setDefaultModelObject(sites.getModelObject());
>>                                target.add(label);
>>                        }
>>                });
>>
>> On Fri, Jun 15, 2012 at 11:25 AM, Dmitriy Neretin
>> <dm...@googlemail.com> wrote:
>> > Thanks!
>> >
>> > Can you describe how can I use the
>> AjaxFormChoiceComponentUpdatingBehavior()
>> > with the label?
>> >
>> > 2012/6/15 Martin Grigorov <mg...@apache.org>
>> >
>> >> Hi,
>> >>
>> >> #onSelectionChanged() works only if you override
>> >> #wantOnSelectionChanged() to return true.
>> >> Otherwise you can also use AjaxFormChoiceComponentUpdatingBehavior()
>> >> and update the label with Ajax.
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>>
>>
>>
>> --
>> Martin Grigorov
>> jWeekend
>> Training, Consulting, Development
>> http://jWeekend.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: "ChangeListener" for the RadioGroup Component

Posted by Dmitriy Neretin <dm...@googlemail.com>.
Thanks! It was really helpful! But I am only to 99% ready :)

There is a little problem in your code example:

if I make so:
label.setDefaultModelObject(sites.getModelObject());

I get a compiler error: "Cannot refer to a non-final variable sites inside
an inner class..." Is there any workaround for this?

Thank you!


2012/6/15 Martin Grigorov <mg...@apache.org>

> Something like:
>
> final Label label = ...
> RadioChoice<String> sites = new RadioChoice<String>("site", SITES);
>                sites.add(new AjaxFormChoiceComponentUpdatingBehavior()
>                {
>                        @Override
>                        protected void onUpdate(AjaxRequestTarget target)
>                        {
>
> label.setDefaultModelObject(sites.getModelObject());
>                                target.add(label);
>                        }
>                });
>
> On Fri, Jun 15, 2012 at 11:25 AM, Dmitriy Neretin
> <dm...@googlemail.com> wrote:
> > Thanks!
> >
> > Can you describe how can I use the
> AjaxFormChoiceComponentUpdatingBehavior()
> > with the label?
> >
> > 2012/6/15 Martin Grigorov <mg...@apache.org>
> >
> >> Hi,
> >>
> >> #onSelectionChanged() works only if you override
> >> #wantOnSelectionChanged() to return true.
> >> Otherwise you can also use AjaxFormChoiceComponentUpdatingBehavior()
> >> and update the label with Ajax.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: "ChangeListener" for the RadioGroup Component

Posted by Martin Grigorov <mg...@apache.org>.
Something like:

final Label label = ...
RadioChoice<String> sites = new RadioChoice<String>("site", SITES);
		sites.add(new AjaxFormChoiceComponentUpdatingBehavior()
		{
			@Override
			protected void onUpdate(AjaxRequestTarget target)
			{

label.setDefaultModelObject(sites.getModelObject());
				target.add(label);
			}
		});

On Fri, Jun 15, 2012 at 11:25 AM, Dmitriy Neretin
<dm...@googlemail.com> wrote:
> Thanks!
>
> Can you describe how can I use the AjaxFormChoiceComponentUpdatingBehavior()
> with the label?
>
> 2012/6/15 Martin Grigorov <mg...@apache.org>
>
>> Hi,
>>
>> #onSelectionChanged() works only if you override
>> #wantOnSelectionChanged() to return true.
>> Otherwise you can also use AjaxFormChoiceComponentUpdatingBehavior()
>> and update the label with Ajax.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: "ChangeListener" for the RadioGroup Component

Posted by Dmitriy Neretin <dm...@googlemail.com>.
Thanks!

Can you describe how can I use the AjaxFormChoiceComponentUpdatingBehavior()
with the label?

2012/6/15 Martin Grigorov <mg...@apache.org>

> Hi,
>
> #onSelectionChanged() works only if you override
> #wantOnSelectionChanged() to return true.
> Otherwise you can also use AjaxFormChoiceComponentUpdatingBehavior()
> and update the label with Ajax.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: "ChangeListener" for the RadioGroup Component

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

#onSelectionChanged() works only if you override
#wantOnSelectionChanged() to return true.
Otherwise you can also use AjaxFormChoiceComponentUpdatingBehavior()
and update the label with Ajax.

On Fri, Jun 15, 2012 at 11:01 AM, Dmitriy Neretin
<dm...@googlemail.com> wrote:
> Hi all,
>
> I have a little problem with my RadioGroup component. I have 2 radio
> buttons inside of a ListView, witch is inside of the RadioGroup I mentioned
> above. The amount of the radios is not predefined that's because I use
> RadioGroup instead of RadioChoise. There can be 2 or 1000...
>
> The Problem is following: I also have a Label below that RadioGroup and I
> want that this label updates itself every time I select the other radio
> button. I tried to override the onSelectionChanged method of the RadioGroup
> but the method will not be executed! (I set a method- breakpoint on it)
>
> What do I wrong?
>
> The whole thing looks like that:
>
> RadioGroup
>  ListView
>   Rado, Text, Links etc.
>
> Label to update
>
> RadioGroup
>  - o Option A
>  - o Option B
>
> Label: You have selected option A/option B
>
> Thank you!
> Dmitriy



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org