1

I have come in a situation where I need to create a hiperlink for each entry in collection following is my code..

       <td><a href="#" onclick="javascript:openWindow(--------)">Click 

How can i get ${current.product_id} value in blank space... so that i can pass my value to next jsp for internal processing....

Pedantic
  • 1,368
  • 10
  • 39
  • 70

3 Answers3

2

I'm not familiar with struts, but won't this do the trick?

<td><a href="#" onclick="javascript:openWindow(<%=current.getProductId()%>)">Click
RonK
  • 9,472
  • 8
  • 51
  • 87
  • 1
    I respect your answer but that wont work because while iteration we cant use id any where else.. thanks – Pedantic Jun 16 '10 at 11:30
  • @Rozer: And how do you think your method call would be different for each link then? Or do you want to do the same thing no matter what on click of every link? – Adeel Ansari Jun 16 '10 at 11:38
  • yes i have done it in different way, have to use javascript but achieved the same. – Pedantic Jun 16 '10 at 12:46
1

Try this i have given sample code

<%
String str = "/details.do?method=showQuestions&surveyId="+arrayNew.get(0);
%>

<html:link page='<%=str%>'><%=arrayNew.get(1)%></html:link><br>

In action class under showQuestion method you can get the value of surveyId by using simple String str = request.getParameter("surveyId");

Read url rewritting topic for more details.

Satya
  • 1,421
  • 4
  • 19
  • 32
0

How about this?...

<javascript>
  var hasEditRightsJSProp = <s:property value="#hasEditRights" default="false" />;
  function openWindow() {
    window.open(url+"&param1="+hasEditRightsJSProp,'name','height=200,width=150'); 
  }
<javascript>
<td><a href="#" onclick="javascript:openWindow()</td>

I dont like programs that open popups, but if you reall do and you want to pass parameter over the URL then see the code above.

Hope that helps Jeff Porter

jeff porter
  • 6,560
  • 13
  • 65
  • 123