row selection bug in Datatable

UI Components for JSF
Post Reply
cj91
Posts: 96
Joined: 04 Feb 2010, 00:07

13 Aug 2010, 21:50

I've discovered a small bug in the datatable component with row selection. If you select multiple rows, do a non-ajax submit, then hold down control and select the same rows, then hit submit again, the server will send an array to the backing bean with the information repeated twice.

There are two problems. One, the javascript is recording duplicate row selections and two the server isn't validating the datatable response.

my workaround is to change the setter to this:

Code: Select all

	public void setSelectedMembers(Member[] selectedMembers) {
		LinkedHashSet<Member> tempSet = new LinkedHashSet<Member>();
		for (Member member : selectedMembers) {
			tempSet.add(member);
		}
		this.selectedMembers = tempSet.toArray(new Member[tempSet.size()]);
	}
My jsf snippet:

Code: Select all

<p:dataTable
		id="memberList" value="#{userManagedBean.currentUserAndFamily}"
		selection="#{claimHistoryManagedBean.selectedMembers}"
		selectionMode="multiple" var="member" ajax="true">
		<p:column>
			<h:outputText value="${member.firstName} ${member.lastName}" />
		</p:column>
</p:dataTable>

<p:commandButton action="#{claimHistoryManagedBean.searchClaims}"
		value="Search" ajax="false" update="memberList,claimsHistoryList" />


cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

14 Aug 2010, 10:44


Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 32 guests