Manuel K created MYFACES-4583:
---------------------------------

             Summary: cc.getValueExpression not evaluated correctly
                 Key: MYFACES-4583
                 URL: https://issues.apache.org/jira/browse/MYFACES-4583
             Project: MyFaces Core
          Issue Type: Bug
          Components: General
    Affects Versions: 4.0.0-RC5
         Environment: primefaces-test project, jakarta branch
            Reporter: Manuel K
         Attachments: image-2023-03-06-10-38-02-649.png

When having a composite component where _cc:getValueExpression_ is used in a 
_c:if_ to check if a value has been passed as an attribute, the call does not 
return the desired result.

This methodology has been suggest by BalusC here: 
https://stackoverflow.com/a/11368475/10157328

The composite component looks as follows (simplified):
{code:java}
<?xml version="1.0" encoding="UTF-8"?>

<ui:component xmlns="http://www.w3.org/1999/xhtml";
              xmlns:h="http://xmlns.jcp.org/jsf/html";
              xmlns:cc="http://xmlns.jcp.org/jsf/composite";
              xmlns:ui="http://xmlns.jcp.org/jsf/facelets";
              xmlns:f="http://xmlns.jcp.org/jsf/core";
              xmlns:c="http://xmlns.jcp.org/jsp/jstl/core";
              xmlns:p="http://primefaces.org/ui";>
    <cc:interface>
        <!-- Edit Menu Item -->
        <cc:attribute name="editValue"
                      default="Edit"/>
        <cc:attribute name="editAction"
                      method-signature="java.lang.String 
action(java.lang.Object)"/>
    </cc:interface>

    <cc:implementation>

        <p:menuButton id="menubutton"
                      value="Menu">

            <c:if test="#{not empty cc.getValueExpression('editAction')}">
                <p:menuitem id="edit"
                            value="#{cc.attrs.editValue}"
                            action="#{cc.attrs.editAction}"/>
            </c:if>

        </p:menuButton>

    </cc:implementation>
</ui:component>
 {code}
On Mojarra, the if works correctly, while on MyFaces the p:menuitem is never 
rendered. When debugging, the following expression in the method 
_UIComponent#getValueExpression_ returns null:
{code:java}
(Map)this.getStateHelper().get(UIComponent.PropertyKeys.bindings);{code}
I have created a reproducer here:

[https://github.com/mkomko/primefaces-test/tree/composite-component-get-value-expression]

The menu should render a MenuItem like so:
!image-2023-03-06-10-38-02-649.png!

It works using 
{code:java}
mvn clean jetty:run -Pmojarra40{code}
 but not using 
{code:java}
mvn clean jetty:run -Pmyfaces40{code}
Thank you very much in advance for taking a look!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to