the short answer is: you cant do that. javascript is asynchronous, so the
request will start _and_ your function will continue running. usually what
is done is that you create a request object, and then register success and
failure handlers that are executed after the request is done.

you can do that using iajaxcalldecorator, or what you tried...calling
ajaxtarget.appendjavascript() should work as well.

if you show us some more code/try to describe your actual usecase we can
probably help you more, right now its all very abstract.

-igor


On 5/3/07, James Renfro <[EMAIL PROTECTED]> wrote:

Hi,
I'd like to do something slightly unusual and wrap the
wicketSubmitFormById call in another javascript function -- I'm able to
do this with no problem by overriding
AjaxFormSubmitBehavor.onRenderHeadInitContribution and calling
JavascriptUtils.writeJavascript on a wrapped getEventHandler. I can stop
the normal attribute for 'onclick' or whatever from appearing inside the
component tag by overriding onComponentTag. And by using text input
boxes, I can pass 'arguments' to my method on the server inside using
FormComponent.getConvertedInput. So far so good.

The problem I have is that I'd like to actually 'return' a value back
from the server in that Javascript function... so my function ends up
looking just like a normal function call inside of my Javascript and
returns the value that the server provides.

I can see inside of wicket-ajax.js that there are three special tags:
"component", "evaluate" and "header-contribution", each with their
appropriate purpose -- I tried messing around with
AjaxRequestTarget.prependJavascript so I could pass something through
the 'evaluate' tag, but my javascript isn't sufficient to the task. Then
I tried using AjaxRequestTarget.addComponent to modify another TextField
and return the value through the DOM tree -- that works fine except for
the fact that the order is wrong, so my method returns _before_ the
component is updated.

Then I noticed this interesting Wicket.Ajax.invokePostCallHandlers()
call, which makes me wonder if there is already some nice clean
mechanism in place for updating javascript variables thru wicket's java
code.

Apologies if this all makes no sense, but any advice or suggestions
would be much appreciated. The basic requirement is just that I make a
call in Javascript and get data back from the server as a 'returned'
variable on the client.

Thanks,
James

--
James Renfro
Programmer
IET Mediaworks, UC Davis
[EMAIL PROTECTED]
W: 530-754-5097


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to