portals-jetspeed-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tiwari, Sunil Kumar" <c_sti...@qualcomm.com>
Subject How to use a VTL variable in a javascript?
Date Mon, 09 Jan 2006 18:22:05 GMT
Hi All,

How to assign the value of a VTL variable to a form element in
For example: I have a variable $test="somevalue".
I want it to assign it to some form element say an input text element
using javascript. How can I do it?


-----Original Message-----
From: Tiwari, Sunil Kumar [mailto:c_stiwar@qualcomm.com] 
Sent: Friday, January 06, 2006 9:35 PM
To: Jetspeed Users List
Subject: RE: Re: How to create a new skin and add custom mode to it

-----Original Message-----
From: news on behalf of Aaron Evans
Sent: Fri 1/6/2006 11:41 AM
To: jetspeed-user@jakarta.apache.org
Subject:  Re: How to create a new skin and add custom mode to it
Tiwari, Sunil  Kumar <c_stiwar <at> qualcomm.com> writes:

> The search box request must be passed to a servlet.
> I have created a .vm file for this where I have a html form tag and I
> try to call an action on it but somehow it doesn't work.
> Any ideas?

If you are simply trying to post to a servlet outside of jetspeed (but
on the 
same server), just make the URL of the action the URI of the servlet.
That is, 
something like:


Just remember that the user will then leave the portal and be brought to
response of your servlet.  Further, unless you have tomcat SSO turned
on, you 
will lose the identity of the user that has invoked the servlet.

What would probably be better is to turn your search servlet into a
portlet and
then figure out how to have the search form (in the header) trigger your

portlet. Let me know when you figure that out! :)


Thanks for your advise and I tried out your suggestion and it worked
I am simply trying to post to a servlet outside of jetspeed.

But I have a query here which doesnt concern with servlet but to
velocity template and java script.

Suppose the request url is generated dynamically i.e the action can be
triggered to different servlets depending on some parameter.

Now I have a search box and the search string can be posted to google,
yahoo or some custom servlet(provided as radio buttons).

I have a form element in my jsp.

<form name="form1" action="javascript:null"

In the javascript function, I find out which radio button was selected
and accordingly specify the form.action="some url". The url is a
complete one like http://google.com

If the user selects the custom servlet radio button then I assign the
form.action= <%=servletURl%> (servletUrl is computed in a jsp scriplet)

This code works fine for a websphere theme.

I moved it to Jetspeed by making it a .vm file and it works fine except
for the servlet case.
The problem is that it doesnt recognise <%=servletURl%> within the
javascript. Its obvious so I changed it accordingly using VTL variable.

I store the servletUrl in $url and then form.action=$url in javascript.
It didnt work. I tried form.action=#url and #$url but I knew it wldnt

The question is how to use VTL variable within javascript??

You must be wondering why I have explained all this instead of asking
directly, but I guess it makes the picture clear.

I think there must be some way to do it and if there is no way then how
to get a work around for it.


To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org

View raw message