Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataTable: selectionPageOnly='false' with disabledSelection is selecting disabled rows also #9552

Closed
nikolica666 opened this issue Dec 25, 2022 · 4 comments · Fixed by #9553
Assignees
Labels
12.0.3 🐞 defect Bug...Something isn't working
Milestone

Comments

@nikolica666
Copy link

nikolica666 commented Dec 25, 2022

Describe the bug

When using p:dataTable with attributes selectionPageOnly="false" and disabledSelection when request is submitted on serverside every element from value is set to selection (both disabled and enabled).

You can observer that in selection's setter already.

This does not happen if selectionPageOnly="true"

Edit: I forgot to say this is specific to "select all" checkbox that is generated in header in <p:column selectionMode="multiple" />, if enabled rows are clicked "one-by-one" it is working fine ofcourse.

Reproducer

ViewScoped bean:

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;

import javax.faces.view.ViewScoped;
import javax.inject.Named;

@Named
@ViewScoped
public class MyBean implements Serializable {
	private static final long serialVersionUID = 1L;

	private List<String> all = Arrays.asList("string1","string2","string3","string4","string5");
	private List<String> selected;
	
	public void doSomething() {
		System.out.println("Size of selected rows is " + selected.size());
	}
	public List<String> getAll() {
		return all;
	}
	public List<String> getSelected() {
		return selected;
	}
	public void setSelected(List<String> selected) {
		this.selected = selected;
	}
}

XHTML:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:p="http://primefaces.org/ui">
<h:head />	  
<h:body>
	<h:form>
		<p:dataTable value="#{myBean.all}" var="s" selection="#{myBean.selected}" 
			disabledSelection="#{true}" selectionPageOnly="false"
			rowKey="#{s}">
			<p:column>#{s}</p:column>
			<p:column selectionMode="multiple"></p:column>
		</p:dataTable>
		<p:commandButton value="Process" action="#{myBean.doSomething}" process="@form" update="@form" />
	</h:form>
</h:body>	  
</html>

Expected behavior

Only enabled rows to be selected.

PrimeFaces edition

Community

PrimeFaces version

12.0.0

Theme

Saga

JSF implementation

MyFaces

JSF version

2.2

Java version

1.8

Browser(s)

No response

@nikolica666 nikolica666 added ‼️ needs-triage Issue needs triaging 🐞 defect Bug...Something isn't working labels Dec 25, 2022
@melloware
Copy link
Member

I think this is your issue: #9357

It was fixed in 12.0.2 Elite release

@jepsar
Copy link
Member

jepsar commented Dec 26, 2022

@melloware
Copy link
Member

OK nope here is a reproducer its still happening on 13.0:
pf-9552.zip

@melloware melloware removed the ‼️ needs-triage Issue needs triaging label Dec 26, 2022
melloware added a commit to melloware/primefaces that referenced this issue Dec 26, 2022
@melloware melloware self-assigned this Dec 26, 2022
@melloware melloware added this to the 13.0.0 milestone Dec 26, 2022
@melloware
Copy link
Member

OK it was similar to #9357 but in a different spot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
12.0.3 🐞 defect Bug...Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants