• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...
 
T Ponraj
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic