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.

p:repeat: fix Mojarra ui:repeat does not reset EL var correctly

See original GitHub issue

Describe 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:

  1. Go to the index page on attached primefaces-test application
  2. 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:closed
  • Created 3 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
arjantijmscommented, Mar 26, 2021

I am most dissapointed with Mojarra progress since switching from Oracle to Jakarta.

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.

1reaction
rabitercommented, Feb 9, 2021

the Mojarra UIRepeat issue seems to be at least 8 years old: https://stackoverflow.com/questions/14398960/magic-uirepeat-var

Read more comments on GitHub >

github_iconTop 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 >

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