I have JSP where I am displaying list of data in a tabular format. One of the columns in each will have 3 different links. Have 3 different methods in Action class, so that the respective method will be triggered on click of the link. Once the method has returned the data from Action class, number of rows will be appended based on the list size returned by Action class. I am using struts iterator to iterate and add the <tr>
. I have written the jQuery to perform that operation and everything works fine.
New requirement is that when I click on the first link, it should display the set of records. When I click on the first link again, then the set of records that were displayed should be removed. Its kind of toggling the set of records.
To achieve this, I created a div component, inside which the new set of records would be added and try to do it, but its not working as expected. Have attached the extract of the source code from each file. Please let me know your thoughts.
JSP File:
<s:iterator value="#mbean.myList" var="poItem">
<tr>
<td class="matlNumber"> </td>
<td><s:property value="#poItem.doc" /></td>
<td> </td>
<td> </td>
<td><s:property value="#poItem.weekOne" /> </td>
<td><s:property value="#poItem.weekFive" /></td>
</tr>
</s:iterator>
JS File:
$(".poLink").click(function(){
var myData = $(this).closest('tr').find('td:first').text();
document.forms[0].action = "poListMaterialPlanning.action?myData ="+myData ;
document.forms[0].submit();
}
I tried to use the $.ajax()
, but could not assign the data returned by the Action class to the struts variable in JSP.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…