سؤال

i am trying to pass parameter from a jquery function. Everything is fine but only problem is passing the parameter value rowObject.themeScreenshot

 <script type="text/javascript">
   function formatLink(cellvalue, options, rowObject)
     {    
        var para=rowObject.themeScreenshot; //here value is coming fine 
        alert("Json object value-"+para);  //correctly i am geting the value of para.
        return "<a style='cursor:pointer;' onClick='javascript:openDialog("+cellvalue+")'><img src='<s:url action='ImageAction' namespace='/myimage/secure'><s:param name='imageId'>"+para+"</s:param></s:url>'></a>";
     //this is returning url with empty imagId  output in url:-http://localhost:8080/visionbooks/myimage/secure/ImageAction?imageId=  
   }

What i want is:-

http://localhost:8080/visionbooks/myimage/secure/ImageAction?imageId=anyvalue

But currectly i am geting output is :

http://localhost:8080/visionbooks/myimage/secure/ImageAction?imageId="+para+" variable name is passing as prameter value.Why?

Please help me to solve this problem.

هل كانت مفيدة؟

المحلول

Struts 2 tags are evaluated at page render time, which is far before your script runs.

If you check the source code of the page you will see those tags have been converted to regular html elements. So it the para javascript variable would not be evaluated.

You can try to update the return line to

return "<a style='cursor:pointer;' onClick='javascript:openDialog("+cellvalue+")'><img src='<s:url action='ImageAction' namespace='/myimage/secure'></s:url>" + "?imageId="+para+ "'></a>";
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top