AbstractDefaultAjaxBehavior complete handler

2013-06-04 Thread heikki
hello,

a simple question: I'd like that a certain javascript function is invoked,
after a Wicket Ajax call completes. I'm using Wicket 6.5.

I tried this:

// behaviour works fine except for the onComplete js that I'd like to
execute
public class MyAjaxBehavior extends AbstractDefaultAjaxBehavior {

// this doesn't do anything 
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);

IAjaxCallListener listener = new AjaxCallListener() {
@Override
public CharSequence getCompleteHandler(Component component) {
return alert('onComplete');;
}
};
attributes.getAjaxCallListeners().add(listener);
}

@Override
protected void respond(AjaxRequestTarget target){ ... }
}



Another thing I tried, but with the same result (no js executed on
complete), is client-side:

Wicket.Ajax.get({u:myListenerUrl + params, coh: myfunction });

(where myfunction is an existing js function).


Do you see what I'm doing wrong ?

Kind regards
Heikki Doeleman



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/AbstractDefaultAjaxBehavior-complete-handler-tp4659230.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: AbstractDefaultAjaxBehavior complete handler

2013-06-04 Thread Sven Meier

Hi,

I pasted you #updateAjaxAttributes() into ChoicePage from 
wicket-examples and alert shows up there.


Sven

On 06/04/2013 05:02 PM, heikki wrote:

 // this doesn't do anything
 @Override
 protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
 super.updateAjaxAttributes(attributes);

 IAjaxCallListener listener = new AjaxCallListener() {
 @Override
 public CharSequence getCompleteHandler(Component component) {
 return alert('onComplete');;
 }
 };
 attributes.getAjaxCallListeners().add(listener);
 }



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



Re: AbstractDefaultAjaxBehavior complete handler

2013-06-04 Thread divad91
You could override the getSuccessScript() method. Return the javascript code
or method to be executed.
David



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/AbstractDefaultAjaxBehavior-complete-handler-tp4659230p4659232.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: AbstractDefaultAjaxBehavior complete handler

2013-06-04 Thread heikki
Thanks for your replies.

Could it be that it has something to do with Wicket version ? Wicket
Examples seems to run on Wicket 1.5.10 ?

I also tried the suggested success handler, by adding this to my behavior

@Override
public CharSequence getSuccessHandler(Component component) {
return alert('success handler');;
}

but no luck, still no js executed..


And what about the coh parameter I tried in my Wicket.Ajax.get call ? Is
that supposed to have the same effect as overriding getCompleteHandler() ?
Any idea why it doesn't do anything, did I make some mistake ?



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/AbstractDefaultAjaxBehavior-complete-handler-tp4659230p4659233.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: AbstractDefaultAjaxBehavior complete handler

2013-06-04 Thread divad91
I am using wicket 6.6.0 and these behaviors:
AjaxFormComponentUpdatingBehavior AjaxFormSubmitBehavior.
In both case,  I am overriding the getPreconditionScript() and
getSuccessScript() method to display and hide a please wait gif around
each ajax call.

@Override
protected CharSequence getSuccessScript() {
return $.swtu.event.postAjaxHook();;
}

When I just want to display a dialog box for example after an Ajax call
(onChange behavior), I override the onUpdate or onEvent method and used the
target.appendJavaScript(...) method.

@Override
protected void onUpdate(AjaxRequestTarget target) {
target.appendJavaScript();
}

Hope this helps.
David




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/AbstractDefaultAjaxBehavior-complete-handler-tp4659230p4659234.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: AbstractDefaultAjaxBehavior complete handler

2013-06-04 Thread Andrea Del Bene
As Sven has pointed out your code should work as it is. Try yo see if 
you have any kinds of JavaScript errors using a JavaScript console or a 
tool like FireBug

Hi,

I pasted you #updateAjaxAttributes() into ChoicePage from 
wicket-examples and alert shows up there.


Sven

On 06/04/2013 05:02 PM, heikki wrote:

 // this doesn't do anything
 @Override
 protected void updateAjaxAttributes(AjaxRequestAttributes 
attributes) {

 super.updateAjaxAttributes(attributes);

 IAjaxCallListener listener = new AjaxCallListener() {
 @Override
 public CharSequence getCompleteHandler(Component 
component) {

 return alert('onComplete');;
 }
 };
 attributes.getAjaxCallListeners().add(listener);
 }



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




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



Re: AbstractDefaultAjaxBehavior complete handler

2013-06-04 Thread heikki
thanks. I checked of course that there are no JS errors. I also checked if
any of overridden onComplete(), getCompleteHandler(), and
getSuccessHandler() are executed, and they are not.

So I'm still a bit puzzled here. My behavior's respond() method works fine
and does not throw exceptions or anything.

Does anyone know if the coh param in Wicket.Ajax.get() should be able to
do the same trick ? (although it also doesn't work for me, it'd be good to
know).


Adding target.appendJavascript() in my respond() method works, though.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/AbstractDefaultAjaxBehavior-complete-handler-tp4659230p4659236.html
Sent from the Users forum mailing list archive at Nabble.com.

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