velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "G.L. Grobe" <g...@grobe.net>
Subject Re: can method params be javascript?
Date Wed, 03 Jul 2002 03:11:44 GMT
I didn't understand the point on moving the logic to the server side. Though
I can see how what I had tried to do would not work because the parsing is
on the server side. To clarify the problem, here's what it is I'm trying to
do ...

When the user goes to pageA, a <select ...> element using a velocity method
populates the <option ...> values. Then using an onChange() from that
<select ...> element, I'm trying to pass the <option ...> value that was
selected and pass it into another velocity method that will filter a dbase
query so as to populate the second <select ...> element's list box. Then do
the same w/ a third <select ...> from the selection of the second.

Any help much appreciated.

> > 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.




--
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