[ https://issues.apache.org/jira/browse/MYFACES-4583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17696993#comment-17696993 ]
Manuel K commented on MYFACES-4583: ----------------------------------- Thank you very much for looking into it. That is actually a way better solution and seems to work fine for us. It still throws an exception on Mojarra, but that is more a fault on their part I guess. This is how it should work anyway. You can close the issue as far as I'm concerned, thank you! > 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 > Priority: Major > 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)