Note that there are some explanatory texts on larger screens.

plurals
  1. POProviding edit and delete button for each row of a table using display tag
    primarykey
    data
    text
    <p>I am using display tag to display data in a table on a JSP (using struts 2). Now I want to give two links for each row, one for editing &amp; one for deleting the row.</p> <p>My jsp structure and what I am currently trying is :</p> <pre><code>&lt;s:url id="editReport" action="editReport" /&gt; &lt;sd:div href="%{editReport}" listenTopics="editReport" formId="actionForm" showLoadingText="false" preload="false"&gt; &lt;s:url id="updLists" action="updLists" /&gt; &lt;sd:div href="%{updLists}" listenTopics="updLists" formId="enterDayReport" showLoadingText="false" preload="false"&gt; &lt;s:form id="enterDayReport" action="enterDayReport"&gt; &lt;sd:autocompleter label="Customer " name="customer" list="customerList" valueNotifyTopics="updLists" autoComplete="false" searchType="substring"/&gt; &lt;sd:autocompleter label="Contact " name="contact" list="contactList" valueNotifyTopics="updLists" autoComplete="false" searchType="substring"/&gt; &lt;s:select label="Stage " name="stage" list="stageList" headerKey="0" headerValue="Select" /&gt; &lt;s:select label="Type " name="type" list="typeList" headerKey="0" headerValue="Select" /&gt; &lt;sd:datetimepicker label="Date" name="date" formatLength="small" displayFormat="dd - MMM - yyyy"/&gt; &lt;s:textarea label="Summary" name="summary" cols="40" rows="10"/&gt; &lt;s:submit value="Save Report"/&gt; &lt;/s:form&gt; &lt;/sd:div&gt; &lt;/sd:div&gt; &lt;s:url id="deleteReport" action="deleteReport" /&gt; &lt;sd:div href="%{deleteReport}" listenTopics="deleteReport" formId="actionForm" showLoadingText="false" preload="false"&gt; &lt;disp:table name="dayReportsList" export="true" class="dataTable"&gt; &lt;disp:column property="contactCode" title="Contact"/&gt; &lt;disp:column property="customerCode" title="Customer"/&gt; &lt;disp:column property="stage" title="Stage"/&gt; &lt;disp:column property="type" title="Type"/&gt; &lt;disp:column property="summary" title="Summary"/&gt; &lt;disp:column property="reportDate" title="Date" format="{0,date,dd-MMM-yyyy}" /&gt; &lt;disp:column property="rowId" href="%{editReport}" paramId="rowID" paramProperty="rowId" title="Action"&gt; &lt;s:form id="actionForm" name="actionForm"&gt; &lt;s:hidden id="rowId" name="rowId" value="%{rowId}"/&gt; // This is not getting populated. &lt;s:a onclick="dojo.event.topic.publish('editReport')"&gt;Edit&lt;s:property value="rowId"/&gt;&lt;/s:a&gt;&lt;br&gt; &lt;s:a onclick="dojo.event.topic.publish('deleteReport')"&gt;Delete&lt;/s:a&gt; &lt;/s:form&gt; &lt;/disp:column&gt; &lt;/disp:table&gt; &lt;/sd:div&gt; </code></pre> <p>The problem I am facing here is that, the <code>name</code> of the form associated with every row in the display tag is same. So when I try to access the <code>rowId</code> variable in my action class, I get the value of the first row's rowId only, no matter the button of which row is clicked.</p> <p>I have seen some examples on stack overflow and google which use URL rewriting, but I don't want to use that.</p> <p>Please advise.</p> <p>Thanks!!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload