You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Marieke Vandamme <ma...@tvh.be> on 2012/09/27 09:34:34 UTC

Wicket 6 - add AjaxCallListener to existing component

Hi, 

Is there a way to add a AjaxCallListener to an exiting component? 
The only way I know off is to override updateAjaxAttributes, but that is
only possible when constructing the component.
Is there something like component.getAjaxRequestAttributes() ?

Thanks ! Kind regards, Marieke



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-add-AjaxCallListener-to-existing-component-tp4652404.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Wicket 6 - add AjaxCallListener to existing component

Posted by Martin Grigorov <mg...@apache.org>.
On Thu, Sep 27, 2012 at 11:05 AM, Marieke Vandamme
<ma...@tvh.be> wrote:
> In wicket 1.5 I could do:
> this.visitChildren(new IVisitor<Component, Void>() {
>             public void component(Component component, IVisit<Void> visit) {
>                     component.add(new AjaxEventBehavior(""));

Wicket 6.0 is the same in this respect. You can still add Ajax
*Behavior*s this way.
IAjaxCallListener is IAjaxCallDecorator from Wicket 1.5. You weren't
able to add decorators without extending the behavior.

>             }
> }
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-add-AjaxCallListener-to-existing-component-tp4652404p4652412.html
> Sent from the Users forum mailing list archive at Nabble.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: Wicket 6 - add AjaxCallListener to existing component

Posted by Marieke Vandamme <ma...@tvh.be>.
In wicket 1.5 I could do:
this.visitChildren(new IVisitor<Component, Void>() { 
            public void component(Component component, IVisit<Void> visit) { 
                    component.add(new AjaxEventBehavior("")); 
            } 
}



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-add-AjaxCallListener-to-existing-component-tp4652404p4652412.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Wicket 6 - add AjaxCallListener to existing component

Posted by Marieke Vandamme <ma...@tvh.be>.
Sorry, I don't get it...
When I don't want to change all the constructors of my components, 
how can I use the function updateAjaxAttributes on an already existing
component ?
I thought this function is only overriddable when you are constructing the
component.

So when you want to add the same AjaxCallListener to all components on a
panel:
this.visitChildren(new IVisitor<Component, Void>() {
            public void component(Component component, IVisit<Void> visit) {
                    //here I want to add the AjaxCallListener to the
component. I can't use updateAjaxAttributes here.. The components are all of
different Classes, TextField, TextArea, DropDownChoice, ...
            }
}



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-add-AjaxCallListener-to-existing-component-tp4652404p4652411.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Wicket 6 - add AjaxCallListener to existing component

Posted by Martin Grigorov <mg...@apache.org>.
You don't need to have access to AjaxRequestAttributes all the time.
Just keep the reference to the listener and later add it in
#updateAjaxAttaributes().

On Thu, Sep 27, 2012 at 10:50 AM, Marieke Vandamme
<ma...@tvh.be> wrote:
> Hi,
>
> I have a component that I use to do my own feedback an stuff.
> This component contains a LabeledWebMarkupContainer, which is passed inside
> the constructor.
> This LabeledWebMarkupContainer can be a TextField, DropDownChoice, Radio,
> ...
>
> The constructor is like this:
>
> public MyFeedBackComponent(LabeledWebMarkupContainer component){
>     // here i want to add behavior for all kind of components
>     component.getAjaxRequestAttributes().add(new AjaxCallListener());
> }
>
> So the implementation you suggest isn't applicable in my situation I guess..
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-add-AjaxCallListener-to-existing-component-tp4652404p4652408.html
> Sent from the Users forum mailing list archive at Nabble.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: Wicket 6 - add AjaxCallListener to existing component

Posted by Marieke Vandamme <ma...@tvh.be>.
Hi, 

I have a component that I use to do my own feedback an stuff. 
This component contains a LabeledWebMarkupContainer, which is passed inside
the constructor. 
This LabeledWebMarkupContainer can be a TextField, DropDownChoice, Radio,
...

The constructor is like this: 

public MyFeedBackComponent(LabeledWebMarkupContainer component){
    // here i want to add behavior for all kind of components 
    component.getAjaxRequestAttributes().add(new AjaxCallListener());
}

So the implementation you suggest isn't applicable in my situation I guess..



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-add-AjaxCallListener-to-existing-component-tp4652404p4652408.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Wicket 6 - add AjaxCallListener to existing component

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

class MyComponent extends SomeAjaxComponent {

   @Override
   protected void updateAjaxAttributes(attrs) {
     super.updateAjaxAttributes(attrs);

     attrs.getAjaxCallListeners().add(getListener());
   }

   protected abstract IAjaxCallListener getListener();
}

On Thu, Sep 27, 2012 at 10:34 AM, Marieke Vandamme
<ma...@tvh.be> wrote:
> Hi,
>
> Is there a way to add a AjaxCallListener to an exiting component?
> The only way I know off is to override updateAjaxAttributes, but that is
> only possible when constructing the component.
> Is there something like component.getAjaxRequestAttributes() ?
>
> Thanks ! Kind regards, Marieke
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-add-AjaxCallListener-to-existing-component-tp4652404.html
> Sent from the Users forum mailing list archive at Nabble.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