Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-4583

cc.getValueExpression not evaluated correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 4.0.0-RC5
    • None
    • General
    • 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!

      Attachments

        Activity

          People

            Unassigned Unassigned
            mkomko Manuel K
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: