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

cc.attrs cannot be passed to nested composite (OWB) #5515

Open
aleshi opened this issue Oct 15, 2024 · 0 comments
Open

cc.attrs cannot be passed to nested composite (OWB) #5515

aleshi opened this issue Oct 15, 2024 · 0 comments

Comments

@aleshi
Copy link

aleshi commented Oct 15, 2024

Describe the bug

This issue was originally discovered in Tomee10, but I was able to isolate it to mojarra+openwebbeans combination.
I have parent CompositeTest.xhtml that has showSomeText attribute. And I have nested component NestedCompositeTest.xhtml with showSomeText2 attribute. I need to pass showSomeText from parent to showSomeText2 of nested component.

CompositeTest.xhtml

<ui:component
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:cc="jakarta.faces.composite"
        xmlns:ui="jakarta.faces.facelets"
        xmlns:search="jakarta.faces.composite/components" >

    <cc:interface>
        <cc:attribute name="showSomeText" default="#{true}" type="boolean" />
    </cc:interface>

    <cc:implementation>
        <p>
            CompositeTest.xhtml: showSomeText is #{cc.attrs.showSomeText}
        </p>
        <search:NestedCompositeTest showSomeText2="#{cc.attrs.showSomeText}">
        </search:NestedCompositeTest>
    </cc:implementation>
</ui:component>

NestedCompositeTest.xhtml

<ui:component
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:c="jakarta.tags.core"
        xmlns:cc="jakarta.faces.composite"
        xmlns:ui="jakarta.faces.facelets">

    <cc:interface>
        <cc:attribute name="showSomeText2" default="#{true}" type="boolean" />
    </cc:interface>
    <cc:implementation>
        <div>
            <p>
                NestedCompositeTest.xhtml: showSomeText2 is #{cc.attrs.showSomeText2}
            </p>
            <p>
                <c:if test="#{cc.attrs.showSomeText2}">
                    some text
                </c:if>
            </p>
        </div>
    </cc:implementation>
</ui:component>

The issue is that the value of showSomeText2 is always false. This assignment doesn't work: showSomeText2="#{cc.attrs.showSomeText}".

It gets even more interesting when I use the same attribute name in parent and nested components. Then I get StackOverflowError.

I was able to debug it to the point when https://github.com/apache/openwebbeans/blob/openwebbeans-4.0.2/webbeans-el22/src/main/java/org/apache/webbeans/el22/WebBeansELResolver.java is trying to get value for cc bean and instead of CompositeTest.xhtml, it takes the one that belongs to nested NestedCompositeTest.xhtml.

The same example works fine with Weld.

To Reproduce

Build war file from this repo and deploy it to tomcat: https://github.com/aleshi/mojarra_openwebbeans_issue
Open: http://localhost:8080/jsf_cdi_and_ejb_war/test.jsf
The page prints:

CompositeTest.xhtml: showSomeText is true

NestedCompositeTest.xhtml: showSomeText2 is false

Expected behavior

CompositeTest.xhtml: showSomeText is true

NestedCompositeTest.xhtml: showSomeText2 is true

Additional context
Mojarra version: 4.0.8
Openwebbeans version: 4.0.2
Tomcat version: 10.1.31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant