Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Not A Problem
-
4.0.0-RC5
-
None
-
None
-
primefaces-test project, jakarta branch
Description
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):
<?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>
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:
(Map)this.getStateHelper().get(UIComponent.PropertyKeys.bindings);
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:
It works using
mvn clean jetty:run -Pmojarra40
but not using
mvn clean jetty:run -Pmyfaces40
Thank you very much in advance for taking a look!