question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DataScroller with SelectBooleanCheckbox: Initial checked value is overwritten for loaded chunks during first decode

See original GitHub issue

Describe the defect If I create a datascroller with a list of items, that have a boolean value that is initially true and bound to a p:selectBooleanCheckbox within the datascroller, the checkbox is checked for entries that are initially dispayed (ok) but for additionally loaded elements due to scrolling the checkbox is not checked anymore.

Reproducer primefaces-test.zip

Environment:

  • PF Version: 10.0.0.RC1
  • JSF + version: Mojarra 2.2.8
  • Affected browsers: ALL

To Reproduce Steps to reproduce the behavior:

  1. Go to test page in attached primefaces-test
  2. Scroll down until additional entries are loaded
  3. See error (additional entry index>5 have an unchecked checkbox)

Expected behavior All checkboxes should be checked according to data in Model.

Possible Reason for that: The problem is related to the fact that in SelectBooleanCheckboxRenderer.decode and submittedValue of null is interpreted as “false” and set on the underlying model. For lazy loaded chunk this seems to be executed during the ajax loadChunks call and since the new elements were just yet added their is not value in the requestparameter map for them. Other Input Forms (e.g inputtext) for fine because their just skip the updatemodel phase if submited value == null.

Example XHTML

<h:form id="frmTest">
   	<p:dataScroller var="_item" value="#{testView.model}" chunkSize="5" >
   		<div style="height:300px">
   			<p:inputText value="#{_item.text}" />
   			<p:selectBooleanCheckbox value="#{_item.check}"/> This checkbox should always be checked, but as soon as new chunk is loaded it is not.
   		</div>
   	</p:dataScroller>
</h:form>

Example Bean

@Data
@Named
@ViewScoped
public class TestView implements Serializable {

	private static final long serialVersionUID = 1L;

	private ListDataModel<Item> model = new ListDataModel<>();

	@Data
	public static class Item implements Serializable {

		private static final long serialVersionUID = 1L;
		private String text;
		private boolean check=true;

		public Item(String text) {
			super();
			this.text = text;
		}
	}

	@PostConstruct
	public void init() {
		List<Item> list = new ArrayList<>();
		for (int i =0; i<50; i++) {
			list.add(new Item("Text "+i));
		}
		model = new ListDataModel<>(list);
	}

	public ListDataModel<Item> getModel() {
		return model;
	}

}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
gakocommented, Feb 18, 2021

I working on a fix, to skip the update phases for newly loaded children in these load reqeust, but not sure whether I’m on the right track, we will see…

0reactions
gakocommented, Feb 18, 2021

still struggeling with github PRs 😉 but there should be one now at https://github.com/primefaces/primefaces/pull/7010

Read more comments on GitHub >

github_iconTop Results From Across the Web

(PDF) USER GUIDE 6.2 Author Çağatay Çivici - Academia.edu
If the value is "true", the overlay is not rendered on page load to improve ... 101 PrimeFaces User Guide 3.17 Checkbox Checkbox...
Read more >
New Answers to Old Questions Headquarters - 2017-08-16 (page 6 ...
[ Natty ] sharepoint How can I set a User field to a default value of a user currently logged in through XML...
Read more >
User Guide 6.0: Author | PDF | Java Server Faces - Scribd
initiate the load for the new chunk. Value is defined in integer and default is 10 meaning load would happen after 90% of...
Read more >
JavaServer Faces Training - The J4Fry OpenSource Community
HTTP 200 Response with Set-Cookie Header and chunked encoding . ... Apply Request Values Phase. ... You can see that the first chunk...
Read more >
stackoverflow.txt | searchcode
... 459random;814 460null;812 461checkbox;811 462comparison;811 463activex;807 ... 1724self-learning;173 1725code;173 1726charting;172 1727default-value;172 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found