File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes How to include a javascript variable in the value field of param, thanks. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to include a javascript variable in the value field of param, thanks." Watch "How to include a javascript variable in the value field of param, thanks." New topic
Author

How to include a javascript variable in the value field of param, thanks.

Raimann Zhao
Greenhorn

Joined: Aug 31, 2011
Posts: 1
Pass a value from the js in one jsp page to struts 2 servlet.

The struts 2 action name is myaction.

In the jsp page, I have below function.

function(){

...

myid=document.getElementById("idValue");
dispName('<s:url value="myaction.action"><s:param name="id" value="myid"/></s:url>');

...

}

In the myaction action class, the id value is null, and I checked it in the Chrome seems myaction.action didn't take id as a param.

If I just replace value="myid" to value="%{'1234'}", I'll get the id value 1234 in myaction class.

Based on it, I guess the only problem is the js variable myid has not been passed to id.

I tried value="myid", value="#myid", value="%{myid}", value="%{#myid}", they all won't work. Almost every possible cases...

Can anybody help me? Thanks!
 
 
subject: How to include a javascript variable in the value field of param, thanks.