Issue Javascript command from Wicket

2010-09-09 Thread Watter

I'm sure this is probably rather simple, but what would be the best way to
issue a javascript command from a wicket action?

That's vague so here's a more specific example. I have an existing app that
has a button. When that button is clicked, the event is handled by Wicket to
perform some action like save something to the database. I now have a new
requirement that says that in addition to what was previously occurring, I
also need to execute some javascript when that button is clicked. The exact
javascript that needs to be executed is dependent upon what happens during
the server side handling of the button click so I can't just statically add
something to the onclick handler of the HTML button.

Is there a best practice for this? Handling the button click with Ajax
perhaps and some kind of callback parameter?


-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Issue-Javascript-command-from-Wicket-tp2533439p2533439.html
Sent from the Wicket - User 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: Issue Javascript command from Wicket

2010-09-09 Thread Michael O'Cleirigh
 You can use the AjaxRequestTarget to emit javascript back to the 
browser like this:


target.prependJavascript(alert('sent from the server'););

Typically you would have placed the javascript method definitions into 
the page so they would exist already in the browsers DOM and then you 
would just emit specific calls to them in the action itself.


e.g.

target.prependJavascript(processCase(+case+););

Regards,

Mike


I'm sure this is probably rather simple, but what would be the best way to
issue a javascript command from a wicket action?

That's vague so here's a more specific example. I have an existing app that
has a button. When that button is clicked, the event is handled by Wicket to
perform some action like save something to the database. I now have a new
requirement that says that in addition to what was previously occurring, I
also need to execute some javascript when that button is clicked. The exact
javascript that needs to be executed is dependent upon what happens during
the server side handling of the button click so I can't just statically add
something to the onclick handler of the HTML button.

Is there a best practice for this? Handling the button click with Ajax
perhaps and some kind of callback parameter?





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



Re: Issue Javascript command from Wicket

2010-09-09 Thread Watter


Michael O'Cleirigh wrote:
 
   You can use the AjaxRequestTarget to emit javascript back to the 
 browser like this:
 
 target.prependJavascript(alert('sent from the server'););
 
 Typically you would have placed the javascript method definitions into 
 the page so they would exist already in the browsers DOM and then you 
 would just emit specific calls to them in the action itself.
 
 e.g.
 
 target.prependJavascript(processCase(+case+););
 

Thanks! I really should have known this as I've done something similar
before. I don't know why I was drawing a blank on this.

-Matt

-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Issue-Javascript-command-from-Wicket-tp2533439p2533530.html
Sent from the Wicket - User 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