You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Rodrigo Heffner <ro...@gmail.com> on 2011/07/22 13:32:51 UTC

AjaxEventBehavior("onchange) and AjaxFormComponentUpdatingBehavior("onchange") on same DropDownChoice

Hi guys,

I'm very new to Wicket, and I came across this:

What I want to do:
- I have a DropDownChoice component and I'd like to update it's model
when it changes through AJAX. Also, I want to refresh (repaint,
reload) this dropdown's parent when a value is changed, also though
AJAX.

My approach:
- Adding an AjaxEventBehavior("onchange") AND an
AjaxFormComponentUpdatingBehavior("onchange"). Here's the code:

        dropDownChoice.add(new AjaxEventBehavior("onchange") {

            protected void onEvent(AjaxRequestTarget target) {
                LOG.debug("DroDownChoice's parent " +
IntegrityLevelDropDownPanel.this.getParent().getParent().getParent());

target.addComponent(IntegrityLevelDropDownPanel.this.getParent().getParent().getParent());
            }
        });

        dropDownChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {

            @Override
            protected void onUpdate(AjaxRequestTarget target) {
                LOG.debug("New updated value: " +
this.getComponent().getDefaultModelObjectAsString());
                target.addComponent(this.getComponent());
            }

        });

The Problem:
- Unfortunately both "onchange" events don't work together. Depending
on the order of my code, the AjaxFormComponentUpdatingBehavior or the
AjaxEventBehavior are executed, but not both.

I've changed one of them to happen "onblur" and then they're both
executed, but this is not a solution to my issue.

Does anybody have any tips for this? I've been searching for a while
but couldn't find anything that solves this.


Thank you in advance,

-- 
Rodrigo H M Bezerra

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


Re: AjaxEventBehavior("onchange) and AjaxFormComponentUpdatingBehavior("onchange") on same DropDownChoice

Posted by Rodrigo Heffner <ro...@gmail.com>.
So far it seems to work.

Thank you Clint

On Fri, Jul 22, 2011 at 12:55 PM, Rodrigo Heffner
<ro...@gmail.com> wrote:
> Hi Clint,
>
> Thank you very much for your (quick) response.
>
> I had the (maybe incorrect) idea that AjaxEventBehavior's
> target.addComponent(aComponent) would only make aComponent refresh
> itself through AJAX (and not store new changed values on it's model).
>
> I also thought that the AjaxFormComponentUpdatingBehavior's
> target.addComponent(aComponent) would make the opposite: save
> aComponent's model without a form submission (thorugh AJAX) but
> without refreshing anything.
>
> I'll apply your changes and check if, "onchange", new values are
> stored in the dropdown's model and it's parent is refreshed to show
> the changes.
>
> Thanks
>
> On Fri, Jul 22, 2011 at 12:39 PM, Clint Checketts <ch...@gmail.com> wrote:
>> Why not put everything in the AjaxFormComponentUpdatingBehavior?
>>
>> As in:
>>
>>       dropDownChoice.add(new AjaxFormComponentUpdatingBehavior("onchange")
>> {
>>
>>           @Override
>>           protected void onUpdate(AjaxRequestTarget target) {
>>               LOG.debug("New updated value: " +
>> this.getComponent().getDefaultModelObjectAsString());
>>               target.addComponent(this.getComponent());
>> *
>> //This code was in the AjaxEventBehavior before
>>  LOG.debug("DroDownChoice's parent " +
>> IntegrityLevelDropDownPanel.*
>> *this.getParent().getParent().**getParent());
>>
>> target.addComponent(* *IntegrityLevelDropDownPanel.**
>> this.getParent().getParent().**getParent());*
>>
>>           }
>>
>>       });
>>
>>
>> On Fri, Jul 22, 2011 at 6:32 AM, Rodrigo Heffner
>> <ro...@gmail.com>wrote:
>>
>>> Hi guys,
>>>
>>> I'm very new to Wicket, and I came across this:
>>>
>>> What I want to do:
>>> - I have a DropDownChoice component and I'd like to update it's model
>>> when it changes through AJAX. Also, I want to refresh (repaint,
>>> reload) this dropdown's parent when a value is changed, also though
>>> AJAX.
>>>
>>> My approach:
>>> - Adding an AjaxEventBehavior("onchange") AND an
>>> AjaxFormComponentUpdatingBehavior("onchange"). Here's the code:
>>>
>>>        dropDownChoice.add(new AjaxEventBehavior("onchange") {
>>>
>>>            protected void onEvent(AjaxRequestTarget target) {
>>>                LOG.debug("DroDownChoice's parent " +
>>> IntegrityLevelDropDownPanel.this.getParent().getParent().getParent());
>>>
>>>
>>> target.addComponent(IntegrityLevelDropDownPanel.this.getParent().getParent().getParent());
>>>            }
>>>        });
>>>
>>>        dropDownChoice.add(new AjaxFormComponentUpdatingBehavior("onchange")
>>> {
>>>
>>>            @Override
>>>            protected void onUpdate(AjaxRequestTarget target) {
>>>                LOG.debug("New updated value: " +
>>> this.getComponent().getDefaultModelObjectAsString());
>>>                target.addComponent(this.getComponent());
>>>            }
>>>
>>>        });
>>>
>>> The Problem:
>>> - Unfortunately both "onchange" events don't work together. Depending
>>> on the order of my code, the AjaxFormComponentUpdatingBehavior or the
>>> AjaxEventBehavior are executed, but not both.
>>>
>>> I've changed one of them to happen "onblur" and then they're both
>>> executed, but this is not a solution to my issue.
>>>
>>> Does anybody have any tips for this? I've been searching for a while
>>> but couldn't find anything that solves this.
>>>
>>>
>>> Thank you in advance,
>>>
>>> --
>>> Rodrigo H M Bezerra
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>
>
>
> --
> Rodrigo H M Bezerra
>



-- 
Rodrigo H M Bezerra

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


Re: AjaxEventBehavior("onchange) and AjaxFormComponentUpdatingBehavior("onchange") on same DropDownChoice

Posted by Rodrigo Heffner <ro...@gmail.com>.
Hi Clint,

Thank you very much for your (quick) response.

I had the (maybe incorrect) idea that AjaxEventBehavior's
target.addComponent(aComponent) would only make aComponent refresh
itself through AJAX (and not store new changed values on it's model).

I also thought that the AjaxFormComponentUpdatingBehavior's
target.addComponent(aComponent) would make the opposite: save
aComponent's model without a form submission (thorugh AJAX) but
without refreshing anything.

I'll apply your changes and check if, "onchange", new values are
stored in the dropdown's model and it's parent is refreshed to show
the changes.

Thanks

On Fri, Jul 22, 2011 at 12:39 PM, Clint Checketts <ch...@gmail.com> wrote:
> Why not put everything in the AjaxFormComponentUpdatingBehavior?
>
> As in:
>
>       dropDownChoice.add(new AjaxFormComponentUpdatingBehavior("onchange")
> {
>
>           @Override
>           protected void onUpdate(AjaxRequestTarget target) {
>               LOG.debug("New updated value: " +
> this.getComponent().getDefaultModelObjectAsString());
>               target.addComponent(this.getComponent());
> *
> //This code was in the AjaxEventBehavior before
>  LOG.debug("DroDownChoice's parent " +
> IntegrityLevelDropDownPanel.*
> *this.getParent().getParent().**getParent());
>
> target.addComponent(* *IntegrityLevelDropDownPanel.**
> this.getParent().getParent().**getParent());*
>
>           }
>
>       });
>
>
> On Fri, Jul 22, 2011 at 6:32 AM, Rodrigo Heffner
> <ro...@gmail.com>wrote:
>
>> Hi guys,
>>
>> I'm very new to Wicket, and I came across this:
>>
>> What I want to do:
>> - I have a DropDownChoice component and I'd like to update it's model
>> when it changes through AJAX. Also, I want to refresh (repaint,
>> reload) this dropdown's parent when a value is changed, also though
>> AJAX.
>>
>> My approach:
>> - Adding an AjaxEventBehavior("onchange") AND an
>> AjaxFormComponentUpdatingBehavior("onchange"). Here's the code:
>>
>>        dropDownChoice.add(new AjaxEventBehavior("onchange") {
>>
>>            protected void onEvent(AjaxRequestTarget target) {
>>                LOG.debug("DroDownChoice's parent " +
>> IntegrityLevelDropDownPanel.this.getParent().getParent().getParent());
>>
>>
>> target.addComponent(IntegrityLevelDropDownPanel.this.getParent().getParent().getParent());
>>            }
>>        });
>>
>>        dropDownChoice.add(new AjaxFormComponentUpdatingBehavior("onchange")
>> {
>>
>>            @Override
>>            protected void onUpdate(AjaxRequestTarget target) {
>>                LOG.debug("New updated value: " +
>> this.getComponent().getDefaultModelObjectAsString());
>>                target.addComponent(this.getComponent());
>>            }
>>
>>        });
>>
>> The Problem:
>> - Unfortunately both "onchange" events don't work together. Depending
>> on the order of my code, the AjaxFormComponentUpdatingBehavior or the
>> AjaxEventBehavior are executed, but not both.
>>
>> I've changed one of them to happen "onblur" and then they're both
>> executed, but this is not a solution to my issue.
>>
>> Does anybody have any tips for this? I've been searching for a while
>> but couldn't find anything that solves this.
>>
>>
>> Thank you in advance,
>>
>> --
>> Rodrigo H M Bezerra
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>



-- 
Rodrigo H M Bezerra

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


Re: AjaxEventBehavior("onchange) and AjaxFormComponentUpdatingBehavior("onchange") on same DropDownChoice

Posted by Clint Checketts <ch...@gmail.com>.
Why not put everything in the AjaxFormComponentUpdatingBehavior?

As in:

       dropDownChoice.add(new AjaxFormComponentUpdatingBehavior("onchange")
{

           @Override
           protected void onUpdate(AjaxRequestTarget target) {
               LOG.debug("New updated value: " +
this.getComponent().getDefaultModelObjectAsString());
               target.addComponent(this.getComponent());
*
//This code was in the AjaxEventBehavior before
 LOG.debug("DroDownChoice's parent " +
IntegrityLevelDropDownPanel.*
*this.getParent().getParent().**getParent());

target.addComponent(* *IntegrityLevelDropDownPanel.**
this.getParent().getParent().**getParent());*

           }

       });


On Fri, Jul 22, 2011 at 6:32 AM, Rodrigo Heffner
<ro...@gmail.com>wrote:

> Hi guys,
>
> I'm very new to Wicket, and I came across this:
>
> What I want to do:
> - I have a DropDownChoice component and I'd like to update it's model
> when it changes through AJAX. Also, I want to refresh (repaint,
> reload) this dropdown's parent when a value is changed, also though
> AJAX.
>
> My approach:
> - Adding an AjaxEventBehavior("onchange") AND an
> AjaxFormComponentUpdatingBehavior("onchange"). Here's the code:
>
>        dropDownChoice.add(new AjaxEventBehavior("onchange") {
>
>            protected void onEvent(AjaxRequestTarget target) {
>                LOG.debug("DroDownChoice's parent " +
> IntegrityLevelDropDownPanel.this.getParent().getParent().getParent());
>
>
> target.addComponent(IntegrityLevelDropDownPanel.this.getParent().getParent().getParent());
>            }
>        });
>
>        dropDownChoice.add(new AjaxFormComponentUpdatingBehavior("onchange")
> {
>
>            @Override
>            protected void onUpdate(AjaxRequestTarget target) {
>                LOG.debug("New updated value: " +
> this.getComponent().getDefaultModelObjectAsString());
>                target.addComponent(this.getComponent());
>            }
>
>        });
>
> The Problem:
> - Unfortunately both "onchange" events don't work together. Depending
> on the order of my code, the AjaxFormComponentUpdatingBehavior or the
> AjaxEventBehavior are executed, but not both.
>
> I've changed one of them to happen "onblur" and then they're both
> executed, but this is not a solution to my issue.
>
> Does anybody have any tips for this? I've been searching for a while
> but couldn't find anything that solves this.
>
>
> Thank you in advance,
>
> --
> Rodrigo H M Bezerra
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>