Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

maintin checkbox stauts during paginatin(dispalytag)

 
siddiq syed
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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

Thanks
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...

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()%>">
</display:column>


Thanks,
Nishan Patel.
 
siddiq syed
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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">
<display:column>
<s:checkbox name="selectedTaskIds" theme="simple" fieldValue="%{#attr.row.task.taskId}" value="false"></s:checkbox>
</display:column>
<display:column title="Task Priority" property="task.taskPriority.code" sortable="true"/>
<display:column title="Task Name" property="task.taskType.name" sortable="true"/>
<display:column title="Report Reason" property="caseSummary.reportReasonType.name" sortable="true"/>
<display:column title="Case Type" property="caseSummary.considType.name" 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}"/>
</s:url>
<a href="<s roperty value="%{#attr.caseUrlId}"/>" target="_blank"><s roperty value="%{#attr.row.caseSummary.caseNumber}"/></a>
</display:column>
<display:column title="Task Status" property="task.taskStatusType.taskStatusTypeName" sortable="true"/>
<display:column title="Task Origin" property="task.taskOriginType.name" sortable="true"/>
</display:table>


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.

Regards
siddiq.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic