p:repeat: fix Mojarra ui:repeat does not reset EL var correctly
See original GitHub issueDescribe the defect The “resetValues=true” attribute + UIRepeat behave not as expected (please check the attached application and the code snippet below)
Reproducer primefaces-test application is attached primefaces-test-master.zip
Environment:
- PF Version: 10.0.0
- JSF + version: Mojarra (all versions)
- Affected browsers: ALL_
To Reproduce Steps to reproduce the behavior:
- Go to the index page on attached primefaces-test application
- Click on ‘Reproduce bug’ link
Expected behavior I expect the variable #{value} stay empty
Example XHTML
<h:form>
Expected to stay empty: #{value}
</h:form>
<h:form>
<ui:repeat value="#{testView.strings}" var="value">
<p:outputLabel value="#{value} "/>
</ui:repeat>
</h:form>
<h:form>
<!-- this link will update the variable value in the first form with value from the UIRepeat -->
<p:commandLink value="Reproduce bug" process="@this" update="@(form)" resetValues="true"/>
<!-- and this link works fine -->
<p:commandLink value="Not reproduce bug" process="@this" update="@(form)" resetValues="false"/>
</h:form>
Example Bean
@Data
@Named
@ViewScoped
public class TestView implements Serializable {
private final List<String> strings = new ArrayList<>();
@PostConstruct
public void init() {
strings.addAll(Arrays.asList("Winona Lindsey", "Pandora Peay", "Honey Dean"));
}
public List<String> getStrings() {
return strings;
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Does not reset EL var · Issue #4830 · eclipse-ee4j/mojarra
Describe the defect. The "resetValues=true" attribute + UIRepeat behave not as expected (please check the attached application and the code snippet below).
Read more >ui:repeat not working inside h:dataTable - Stack Overflow
Solution is to handle this while getting the value of the ui:repeat . For instance, if you have something like : <h:dataTable value="#{someBean....
Read more >Mojarra JavaServer Faces - Java EE
This wrapper can be state-saved, but since the CDI bean is stored in a transient field it won't save&restore that. Instead, it will...
Read more >USER GUIDE 6.2 - PrimeFaces
PrimeFaces is an open source JSF component suite with various extensions. • Rich set of components (HtmlEditor, Dialog, AutoComplete, Charts and many more)....
Read more >jsf - JSTL in JSF2 Facelets... makes sense? - Stack Overflow
I would like to output a bit of Facelets code conditionally. For that purpose, the JSTL tags seem to work fine: <c:if test="${lpc.verbose}">...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am actually somewhat disappointed myself too 😦 From being one of the many contributors to Mojarra, I’m suddenly pretty much the only one. If you want I can nominate you though to become committer, so it’s not essentially me who’s the bottleneck. Let me know if interested.
Btw, on the issue of resetting EL vars in general, almost a decade ago I also created issues for this, but with Mojarra and with PrimeFaces. If I remember correctly Cagatay responded that he would mediate over it. The idea I proposed was creating a kind of internal “scope” (not a true scope), which would clear out EL variables local to a component automatically.
the Mojarra UIRepeat issue seems to be at least 8 years old: https://stackoverflow.com/questions/14398960/magic-uirepeat-var