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: more than one dataTable within p:repeat (or ui:repeat) breaks selection #3812
Comments
Please try MyFaces and it's ui:repeat, if it works there, the p:repeat (copy of ui:repeat of mojarra, with same adjustments) is still buggy. |
I changed p:repeat to ui:repeat and ran the reproducer using both myfaces22 and myfaces23 profiles. |
all right, a deeper anylsis or PR is welcome then. |
Looks like a state saving issue. Selection is not saved at that point. What exactly solved |
can't remember. MyFaces ui:repeat also works without such a if statement and therefore there was never a problem |
Looking at related issue #929, user sheldon901 posted this: https://forum.primefaces.org/viewtopic.php?p=116259&sid=2729695e2c7da3bb130627966bd45034#p116259 In that topic he suggests a fix. I tried his fix by creating a DataTable subclass:
and then I put it on faces-config.xml:
Well, it worked! But the problem is, I don't know why it worked. He just appended this.getClientId() on PropertyKeys.selection. Please, could someone with proper knowledge check if this is a good fix? |
According to @cagataycivici |
That was the reason for introducing p:repeat: https://code.google.com/p/primefaces/issues/detail?id=7190 But if it doesn't work in MyFaces, i think the bug is somewhere in our UIData/TabPanel/something base. |
Due to this, I personally always use the index from the varStatus and use
And also use the same construct for selection. That does seem to work all the time. |
@kukel Thank's for sharing a workaround, but unfortunately it did not work on the reproducer. The result is the same as the original code. I tried this:
It fails in mojarra and myfaces. |
We had the same issue with PrimeFaces 7 and fixed it by setting a unique <p:repeat var="par" value="#{testView.parents}">
<p:dataTable id="parTable" value="#{par.children}" var="rec" rowKey="#{rec.id}"
selection="#{par.childrenSelected}" rowSelectMode="checkbox"
widgetVar="table-#{par.id}">
[...] You can see from the browser console that the AJAX requests already contain the wrong table ids when you don't do that. So, any fixes on the server side won't help here. |
@chovyy I just tried yours with the reproducer and only the 2nd table still gets submitted. Am I doing something different than you? |
I'm sorry, I wasn't able to get your project to run quickly and at the moment I don't have the time to dive further into it. From the code, it looks good. I just can tell, that setting the widgetVar fixed it for us. |
We have run into this issue in an application we are writing. I can confirm @lagar84 patch works with this reproducer: |
I would have picture the fix in |
You might be right there is a better way to fix it but I must admit i can't understand much that is going on in that |
OK i was able to take UI Repeat out of the equation and reproduce the problem with dynamic TabView. UIRepeat: http://localhost:8080/primefaces-test/repeat.xhtml TabView: http://localhost:8080/primefaces-test/tabview.xhtml Shows the same behavior so its not related to UI Repeat the bug is definitely in the Datatable Selection. |
From PrimeTek: "We cannot use such repeating components with *:repeat. This requires massive changes in components. That's why JSTL forEach is the ideal solution for this kind of work" The recommendation for <c:forEach var="par" items="#{testView.parents}">
//datatable
</c:forEach> <p:tabView>
<c:forEach var="par" items="#{testView.parents}">
<p:tab title="Parent - #{par.id}">
//datatable
</p:tab>
</c:forEach>
</p:tabView> |
1) Environment
2) Expected behavior
In a scenario having more than one dataTable inside p:repeat (or ui:repeat), selected itens on dataTable should work for all selected records on all tables.
3) Actual behavior
Only the values from the last table are processed
4) Steps to reproduce
Use this reproducer: https://github.com/lagar84/primefaces-test
In the reproducer:
Check all records on both tables (click on all checkboxes)
Click on Submit ALL button
BUG: Only the last table values are shown
5) Sample XHTML
6) Sample bean
The text was updated successfully, but these errors were encountered: