[xwiki-users] Getting at javascript variables
I have javascript code that will get user input from a simple input form, but I need to use that input to query some groovy objects. If I understand correctly, groovy code is parsed on the server, then the javascript is parsed on the user's machine, so I can't pass javascript variables to the groovy code. Is there a way to reload the page such that I could pass the input values to groovy? Any solution where the user inputs a string to be used in a groovy query is welcome as well. Thanks, -Mike _________________________________________________________________ Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:W...
On Wed, Apr 7, 2010 at 9:11 AM, Mike Davis <[email protected]> wrote:
I have javascript code that will get user input from a simple input form, but I need to use that input to query some groovy objects. If I understand correctly, groovy code is parsed on the server, then the javascript is parsed on the user's machine, so I can't pass javascript variables to the groovy code. Is there a way to reload the page such that I could pass the input values to groovy?
Not directly w/ groovy, but the second half of my post below may be of help
-- similar issues passing back and forth between server/velocity and client/javascript : http://n2.nabble.com/Macros-and-JavaScript-working-together-was-Re-DISCUSSIO... <http://n2.nabble.com/Macros-and-JavaScript-working-together-was-Re-DISCUSSION-XWiki-Chart-Api-Chart-Macro-tc3193800.html#a3193800> Niels http://nielsmayer.com
Hi Mike, Mike Davis wrote:
I have javascript code that will get user input from a simple input form, but I need to use that input to query some groovy objects. If I understand correctly, groovy code is parsed on the server, then the javascript is parsed on the user's machine, so I can't pass javascript variables to the groovy code. Is there a way to reload the page such that I could pass the input values to groovy?
Any solution where the user inputs a string to be used in a groovy query is welcome as well.
The easiest way is to use a form that submits to the same page: ----------8<---------- {{velocity}} #if("$!request.myInput" == "") No value was submitted. #else Submitted value: $request.myInput #end {{html}} <form action=""> <div> <label for="myInput">My Input:</label> <input type="text" id="myInput" name="myInput" value="$!request.myInput" /> <input type="submit" value="Submit" /> </div> </form> {{/html}} {{/velocity}} ---------->8---------- This example is with Velocity, but Velocity is parsed as Groovy on the sever side. I don't know that well groovy, but I'm sure you can do something similar. Hope this helps, Marius
Thanks,
-Mike
_________________________________________________________________ Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:W... _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (3)
-
Marius Dumitru Florea -
Mike Davis -
Niels Mayer