javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-1909

Composite attribute 'default': EL expressions not resolved correctly

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Duplicate
    • Affects Version/s: 2.0.3, 2.1.0
    • Fix Version/s: 2.1.18, 2.2.0-m09
    • Component/s: facelets
    • Labels:
      None
    • Environment:

      Spring Framework 3.0.5 with SpringBeanFacesELResolver

      Description

      In my composite component's attributes, there is an attribute for which I specify a default value using an EL value expression:

      <composite:attribute name="bean" default="#{testBean}" type="test.TestBean"/>

      In the implementation of my composite, I use this attribute to access a property of type String of my TestBean class:

      <h:outputText value="#{cc.attrs.bean.testString}"/>

      Now, I create two instances of my composite component. For the first instance, I explicitly specify the value of the "bean" attribute (and use the same value as the default, namely "#

      {testBean}"). For the second instance, I do not specify the "bean" attribute and rely on the default value:
      
      

      <test:test-component caption="Bean attribute explicitly specified" bean="#{testBean}

      "/><br/>

      <!-- Does not work -->
      <test:test-component caption="Bean attribute by default"/>

      
      

      While the first case works, the second one throws an exception (although the "bean" attribute should have the same value in both cases!). With Mojarra 2.0.3 and 2.1.0-SNAPSHOT, the exception is:

      javax.el.PropertyNotFoundException: /resources/test/test-component.xhtml @24,54 value="#{cc.attrs.bean.testString}": Property 'testString' not found on type com.sun.faces.facelets.el.TagValueExpression

      In Mojarra 2.1.0-b10, the exception is:

      javax.el.PropertyNotFoundException: /resources/test/test-component.xhtml @24,54 value="#{cc.attrs.bean.testString}": Property 'testString' not found on type java.lang.String

        Issue Links

          Activity

          Hide
          tlind added a comment -

          Whoops, seems that the formatting tags don't work here. Sorry for that.

          Show
          tlind added a comment - Whoops, seems that the formatting tags don't work here. Sorry for that.
          Hide
          Ed Burns added a comment -

          Thanks for taking a look at this.

          As shown in the attached grep output, we do not have an automated test that currently exercises your exact case. Therefore, it's possible you do indeed have a bug.

          Before I assign a priority to it, I want you to try this workaround. Our automated tests do have the following case:

          <composite:attribute name="a1" default="#

          {compositeBean.text}

          " />

          The right hand side of the default attribute is a ValueExpression in the form bean.property. Can you please try to make your example be bean.property instead of just bean?

          If that works, then we'll have a better idea of the problem.

          Show
          Ed Burns added a comment - Thanks for taking a look at this. As shown in the attached grep output, we do not have an automated test that currently exercises your exact case. Therefore, it's possible you do indeed have a bug. Before I assign a priority to it, I want you to try this workaround. Our automated tests do have the following case: <composite:attribute name="a1" default="# {compositeBean.text} " /> The right hand side of the default attribute is a ValueExpression in the form bean.property. Can you please try to make your example be bean.property instead of just bean? If that works, then we'll have a better idea of the problem.
          Hide
          Ed Burns added a comment -

          Grep output showing the extend of our "default=" tests.

          Show
          Ed Burns added a comment - Grep output showing the extend of our "default=" tests.
          Hide
          Ed Burns added a comment -

          triage

          Show
          Ed Burns added a comment - triage
          Hide
          tlind added a comment -

          Thanks for looking into this! I tried the workaround you suggested (i.e. default="#

          {bean.property}

          ") and got interesting results:

          Expected output
          ---------------
          Bean property explicitly specified: works!
          Bean property by default: works!

          Actual output with 2.0.2 and 2.0.3
          ----------------------------------
          Bean property explicitly specified: /resources/test/test-component.xhtml @13,94 default="#

          {testBean.testString}"
          Bean property by default: /resources/test/test-component.xhtml @13,94 default="#{testBean.testString}

          "

          Actual output with 2.1.0-SNAPSHOT
          ---------------------------------
          Bean property explicitly specified: works!
          Bean property by default: /resources/test/test-component.xhtml @13,94 default="#

          {testBean.testString}

          "

          Actual output with 2.1.0-b10
          ---------------------------------
          Bean property explicitly specified: works!
          Bean property by default: works!

          So, while your workaround is also broken in 2.0.3, it seems to have been fixed sometime between 2.1.0-SNAPSHOT and 2.1.0-b10. But my original problem as described above, i.e. default="#

          {bean}

          ", still exists in 2.1.0-b10, so this looks like a bug and a test case for this should be added.

          Show
          tlind added a comment - Thanks for looking into this! I tried the workaround you suggested (i.e. default="# {bean.property} ") and got interesting results: Expected output --------------- Bean property explicitly specified: works! Bean property by default: works! Actual output with 2.0.2 and 2.0.3 ---------------------------------- Bean property explicitly specified: /resources/test/test-component.xhtml @13,94 default="# {testBean.testString}" Bean property by default: /resources/test/test-component.xhtml @13,94 default="#{testBean.testString} " Actual output with 2.1.0-SNAPSHOT --------------------------------- Bean property explicitly specified: works! Bean property by default: /resources/test/test-component.xhtml @13,94 default="# {testBean.testString} " Actual output with 2.1.0-b10 --------------------------------- Bean property explicitly specified: works! Bean property by default: works! So, while your workaround is also broken in 2.0.3, it seems to have been fixed sometime between 2.1.0-SNAPSHOT and 2.1.0-b10. But my original problem as described above, i.e. default="# {bean} ", still exists in 2.1.0-b10, so this looks like a bug and a test case for this should be added.
          Hide
          Ed Burns added a comment -

          Because a workaround exists, this is not a blocker for 2.1.0.

          Show
          Ed Burns added a comment - Because a workaround exists, this is not a blocker for 2.1.0.

            People

            • Assignee:
              Unassigned
              Reporter:
              tlind
            • Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: