Seephor Seephor - 1 year ago 119
HTML Question

How to have clickable table row send parameters to Struts action class?

I have a HTML table where each row is clickable. Here is how I have them clickable:

$(".clickable-row").click(function() {
window.document.location = "${pageContext.request.contextPath}/ActionClass";

<tr class="clickable-row">
<td class="text-left">some parameter</td>

I am not sure how to pass the data from the clicked table row to the struts action since I am using a Javascript function to handle the click/navigation. In the past I was able to use something like:

<s:url action="ActionClass" var="actionLink" >
<s:param name="param1">${param1}</s:param>
<s:param name="param2">${param2}</s:param>
<s:a href="%{actionLink}">go to Action</s:a>

But I can't use the
tags inside the JS function. What is the best way to go about this?

Not really a duplication question. This was more specific how to get a table row parameter sent to an action by a clickable row. I was able to get a parameter to send by a column button, but never received an answer that helped with a clickable row.

Answer Source

You can create a column with hyper link that passes parameters to action like:

  <s:a href="test.action?param1=%{param1}><s:property value="param1"/></s:a>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download