Question

I am aware that this is somewhat a re-post, but I feel like re-posting my question will make things more clear.

Here is the code for my table in my JSP page:

<display:table name="table" pagesize="25" requestURI="">
<display:column title="Action" >
    <s:form theme="simple">
        <s:hidden key="cpc" />
        <s:submit action="remove" value="Remove" 
        onclick="return confirm('Are you sure you want to delete this item?');"/>
        <s:submit action="displayEdit" value="Edit"/>
    </s:form>
</display:column>
<display:column property="cpc" title="CPC" sortable="true" headerClass="sortable"/>
<display:column property="companyName" title="Company Name" sortable="true" headerClass="sortable"/>
<display:column property="eventType" title="Event Type" sortable="true" headerClass="sortable"/>
<display:column property="industryType" title="Industry Type" sortable="true" headerClass="sortable"/>
<display:column property="previousEvents" sortable="true" headerClass="sortable"/>
<display:column property="creditNotifications" sortable="true" headerClass="sortable"/>
<display:column property="interimNotifyEnterprise" sortable="true" headerClass="sortable"/>
</display:table>

The source for the table is an ArrayList, where TableRow is a wrapper class of all the various fields (and I have getters and setters for all the fields). Now when I check my HTML source code, I see this for the hidden field:

<input type="hidden" name="cpc" value="" id="displayResults_cpc"/>

For some reason, there is no value to be found... It was working fine before I used Displaytag, and I do have a getter and setter in my Action class (right now it returns an empty String).

Edit: This is the HTML code for the first two rows:

<tr class="odd">
<td>

<form id="displayResults" name="displayResults" onsubmit="return true;" action="/CompanyNameTableManager/displayResults.action;jsessionid=566617D98154AB762002B06D9D1087CD" method="post">
        <input type="hidden" name="cpc" value="" id="displayResults_cpc"/>
        <input type="submit" id="displayResults_remove" name="action:remove" value="Remove" onclick="return confirm('Are you sure you want to delete this item?');"/>

        <input type="submit" id="displayResults_displayEdit" name="action:displayEdit" value="Edit"/>

    </form>  
</td>
<td>10.1.1</td>
<td>Comapny A</td>
<td>abc</td>
<td>123</td>
<td>true</td>
<td>true</td>

<td>true</td></tr>
<tr class="even">
<td>

<form id="displayResults" name="displayResults" onsubmit="return true;" action="/CompanyNameTableManager/displayResults.action;jsessionid=566617D98154AB762002B06D9D1087CD" method="post">
        <input type="hidden" name="cpc" value="" id="displayResults_cpc"/>
        <input type="submit" id="displayResults_remove" name="action:remove" value="Remove" onclick="return confirm('Are you sure you want to delete this item?');"/>

        <input type="submit" id="displayResults_displayEdit" name="action:displayEdit" value="Edit"/>

    </form>
</td>
<td>10.1.2</td>
<td>Comapny B</td>
<td>abc</td>
<td>123</td>
<td>true</td>
<td>false</td>
<td>false</td></tr>
Was it helpful?

Solution

I guess I copped out from using buttons, but if anyone is curious, here is what I ended up using instead:

<s:form theme="simple" method="post">
<display:table name="table" pagesize="25" requestURI="" uid="row">
<display:column title="Select">
    <s:checkbox name="checked[%{#attr.row_rowNum - 1}]" fieldValue="%{#attr.row.cpc}" theme="simple"/>
</display:column>
<display:column property="cpc" title="CPC" sortable="true" headerClass="sortable"/>
<display:column property="companyName" title="Company Name" sortable="true" headerClass="sortable"/>
<display:column property="eventType" title="Event Type" sortable="true" headerClass="sortable"/>
<display:column property="industryType" title="Industry Type" sortable="true" headerClass="sortable"/>
<display:column property="previousEvents" sortable="true" headerClass="sortable"/>
<display:column property="creditNotifications" sortable="true" headerClass="sortable"/>
<display:column property="interimNotifyEnterprise" sortable="true" headerClass="sortable"/>
</display:table>
    <s:submit action="remove" value="Remove" 
    onclick="return confirm('Are you sure you want to delete this item / these items?');"/>
    <s:submit action="displayEdit" value="Edit"/>
    <s:submit value="Add New Row" action="displayAdd"/>
</s:form>

OTHER TIPS

I think what's probably happening is that the row-specific requirements for Struts 2 and the Display taglib are interacting poorly, i.e. that the other taglib is doing its own row-by-row processing, and the OGNL expression for 'cpc' isn't being evaluated properly, because the row isn't being properly pushed onto the value stack (if you don't understand what I mean, it's not crucial).

Since you have the CPC value in another column, is it possible for you to use Javascript in an onClick (or onLoad) of the buttons to retrieve the value from the adjacent field?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top