File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes maintin checkbox stauts during paginatin(dispalytag) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "maintin checkbox stauts during paginatin(dispalytag)" Watch "maintin checkbox stauts during paginatin(dispalytag)" New topic

maintin checkbox stauts during paginatin(dispalytag)

siddiq syed

Joined: Aug 14, 2008
Posts: 6
I am using a display tag for pagination in my JSP page. I have a checkbox field as one of the columns. I am using displayTagWrapper class to display my checkboxes. I have a submit button in a page which will save checkbox status into the database. I also have pagination and sorting in the page.

The problem i have is, i will loose the status of the checkbox when i go to second page. If i select some of the checkboxes in page 1 and go to page 2 to select some more and if i come back, i loose all the selected checkboxes in page 1.

Is there a way where i could save my check boxes in session and its checked while i browse across pages and gets submitted all at once.

Any help is appreciated

Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 689


Use like this.

<display:column headerClass="Table-Head" title="Status">
<input type="checkbox" id="status"
name="userMap[<%=((User) row).getId()%>].active" value="true"
<%=((User) row).getActive() == true ? "checked"
: ""%>>
<input type="hidden" name="userMap[<%=((User) row).getId()%>].id"
value="<%=((User) row).getId()%>">

Nishan Patel.

Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
siddiq syed

Joined: Aug 14, 2008
Posts: 6
Hi Nishan,

Thanks for your reply.
Below is my Jsp code that display a list of check box,

This is how i am display the contents of a list , in a table.

<display:table name="sessionScope.caseSummaryComposites" style="width:100%" defaultsort="2" requestURI="CONSWEB/task/viewUnallocatedTasks.action" class="display" uid="row" pagesize="5" sort="page">
<s:checkbox name="selectedTaskIds" theme="simple" fieldValue="%{#attr.row.task.taskId}" value="false"></s:checkbox>
<display:column title="Task Priority" property="task.taskPriority.code" sortable="true"/>
<display:column title="Task Name" property="" sortable="true"/>
<display:column title="Report Reason" property="" sortable="true"/>
<display:column title="Case Type" property="" sortable="true"/>
<display:column title="Case Received Date" property="caseSummary.caseReceivedDate" sortable="true"/>
<display:column title="Task Creation Date" property="task.taskCreationDate" sortable="true"/>
<display:column title="Sentence Prefix" property="caseSummary.sentencePrefixType.code" sortable="true"/>
<display:column title="Unique Case Identifer" sortable="true">
<s:url id="caseUrlId" namespace="/team" action="viewCaseDetailAction" encode="true">
<s aram name="caseNumber" value="%{#attr.row.caseSummary.caseId}"/>
<a href="<s roperty value="%{#attr.caseUrlId}"/>" target="_blank"><s roperty value="%{#attr.row.caseSummary.caseNumber}"/></a>
<display:column title="Task Status" property="task.taskStatusType.taskStatusTypeName" sortable="true"/>
<display:column title="Task Origin" property="" sortable="true"/>

As per your sample , i understand that you are using a hidden field that keep track of selected Id's. Can you kindly tell me as per my secnario what will be the value of the hidden filed in order to keep track of selected Id's for multiple page.

I agree. Here's the link:
subject: maintin checkbox stauts during paginatin(dispalytag)
jQuery in Action, 3rd edition