This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to set javascript varibale in <s:url><s:param> value attribute

 
T Ponraj
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi All,

I m struggling to set javascript variable in s:param value attribute

Here is my code

java script variable.

var contorlName=1;

acridsDiv = document.getElementById("acrids");
acridsDiv.href ='<s:url id="acrid_url" action="SearchAcridAction" namespace="/problemrecord">' +
'<s:param name="acridTypeIdAjax" value="1">' +
'</s:param> </s:url>';

I want to set controlName varibale in to value attribute, Tried with ' and "" , any help would be appreciated.



Regards
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Leaving the debate about whether or not this is the best way to go about this aside, you need to create the URL independent of the JS, then use the value in the JS. The <s:url> tag allows you to specify the var in which to store the results--use it, and the <s:property> tag, in combination.
 
T Ponraj
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David, Many thanks for the help.

Could you please provide me the sample code to use it.

I have tried it, but could not get achive it.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...
 
T Ponraj
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help, I m still struggling bcos I m new to Struts.

Here is my code.

<s:url id="acrid_url" action="SearchAcridAction" namespace="/problemrecord">
<s:param name="acridTypeIdAjax" value="1">'
</s:param> </s:url>




Javascript
var contorlName=<<method parameter which is coming from my Jsp Onclickevent>>;

How do I set my controlName variable in to <s:param value attribute. So that it pass this param to my action class.

var jsVar = <s:property value="#foo"/>';




David Newton wrote:...
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That will be more difficult: JSP runs on the server side, JavaScript runs on the client side. The S2 tags are rendered before any JavaScript executes.

You might need to just build your URL by hand, although in general such things can be worked around by building a URL for each (whatever it is you're iterating over).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic