velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Pearson <pear...@intecgroup.com.au>
Subject Re: can method params be javascript?
Date Wed, 03 Jul 2002 02:41:25 GMT
G.L. Grobe wrote:
> Anyone happen to know if it's possible to pass a javascript property
> through a velocity method (and if so, what the syntax is like) ?
> Something like ...
> 
> #foreach ( $key in $productList.keySet(
> my_javascript_property_somehow_here ) )
>  ...
> #end

No. VM parsing is performed on the server side, whereas JavaScript 
parsing is performed on the client side. They're two seperate systems. 
You can, however, do this:

form1.vm:
<form action="form2.vm" name=form1>
  <input type=hidden name=jscriptVar>
  <input type=button onClick="document.form1.jscriptVar = 'foo'; 
document.form1.submit()">
</form>

form2.vm:
<p>jscriptVar is now: $jscriptVar

> And here's the javascript property (which returns a string) that I want
> to pass into the velocity method above ... (of course I can shorten this
> to a js function, etc...)
> 
> document.myForm.myName[document.myForm.myName.selectedIndex].value

Nope. Pass the value as a request attribute instead. If the value is set 
  by some javascript on the page, either move the logic into the 
server-side Java or have a mechanism which will pass the javascript 
value through to the server and redraw the page.

-- 
Michael Pearson
Intec Consulting Group
Tel: +61 8 8359 2332
pearson@intecgroup.com.au


--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message