• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Deletion using checkboxes in struts2 application

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
0 down vote favorite
share [g+] share [fb] share [tw]


i want to implement delete functionality using checkboxes in my struts2 application. i'm using display tag in my jsp page to show the reports. i need to provide checkboxes with reports to delete the selected reports. i have tried this code in my jsp page :

<s:form name="listPage">
<display:table name="egnreports" class="table" id="egnreports" requestURI="" export="true" pagesize="30">

<display:column>
<s:checkbox name="checked" fieldValue='%{egnreports.id}' />
</display:column>

<display:column value="<%=egnreports_rowNum%>" title="S.No." />

<display:column property="createDate" sortable="true" titleKey="egnreport.createDate" style="width:13.5%"/>

<-- Other Table data here -->

</display:table>
</s:form>
<c:out value="${buttons}" escapeXml="false" />[/code]

In my action class, i have used this :

private String[] checked;

public String[] getChecked() {

return checked;
}

public void setChecked(String[] checked) {

this.checked=checked;

}

When i try to retrive the selected values to delete the corresponding reports, i get a null pointer exception :

for (String code : checked) {

egnreportManager.remove(egnreport.getId());
saveMessage(getText("ireport.deleted"));
}

If i use

<display:column>
<input type="checkbox" name="checked" value="${egnreports.id}"/>
</display:column>

in place of s:checkbox tag, i'm able to see the values in the reports page (using firebug), but still they do not get populated in the action class.

(I can't use "${egnreports.id}" with s:checkbox tag, it shows "fieldvalue does not support runtime expression" and with "%{egnreports.id}", firebug shows checkbox value as empty ie, value="").

Where did i go wrong? can anybody help me with this???
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

shashikant mourya wrote:0 down vote favorite
share [g+] share [fb] share [tw]



So what other site did you copy and paste your question from? We ask that you let us know when you do that so we aren't duplicating effort.
 
shashikant mourya
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, i would keep that in my mind from now on. I've asked this question at http://stackoverflow.com/questions/10530371/deletion-using-checkboxes-in-struts2-application and since i require a solution on urgent basis, so i though i might ask it here as well. but i have got your point and from next time i'll keep that in mind.... :-)
 
reply
    Bookmark Topic Watch Topic
  • New Topic