[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-2133) inline EL in component property value not properly detected

Dan Allen (JIRA) jira-events at lists.jboss.org
Wed Nov 28 19:21:46 EST 2007


    [ http://jira.jboss.com/jira/browse/JBSEAM-2133?page=comments#action_12389718 ] 
            
Dan Allen commented on JBSEAM-2133:
-----------------------------------

I did a thorough analysis and I can verify that this will only affect two of the examples and none of the test suites (meaning the suites will pass). However, it will be important to clarify this in the documentation. Here is why.

Up until now, EL expressions in configuration properties have only been considered if the value of the property started with #{. Since most of the time the property value begins with #{ if it contains an expression at all, it appears as though the value expressions are always evaluated before assignment. You see an example of this used in the wiki example.

<factory name="themePath" scope="APPLICATION"
             value="#{facesContext.externalContext.request.contextPath}/themes/#{wikiPreferences.themeName}"/>

This would not have worked if it was instead written as

<factory name="themePath" scope="APPLICATION"
             value="themes/#{wikiPreferences.themeName}"/>

since it does not begin with #{.

After adding this patch, you have to be aware that EL expressions are going to take affect during property assignment, even if they appear somewhere in the middle of the string. This happens a lot in query restrictions.

    <framework:entity-query name="artists" ejbql="select artist from Artist artist" order="artist.name DESC" max-results="5">
      <framework:restrictions>
        <value>lower(artist.name) like lower(concat(#{exampleArtist.name}, '%'))</value>
      </framework:restrictions>
    </framework:entity-query>

With this patch, it would have to be changed to this:

    <framework:entity-query name="artists" ejbql="select artist from Artist artist" order="artist.name DESC" max-results="5">
      <framework:restrictions>
        <value>lower(artist.name) like lower(concat(\#{exampleArtist.name}, '%'))</value>
      </framework:restrictions>
    </framework:entity-query>

Unfortunately this might cause breakage, but frankly I think the way it is right now is just inconsistent as hell. We need to go one way or the other, evaluate the expression or don't evaluate the expression. Right now we are sitting on the fence.

> inline EL in component property value not properly detected
> -----------------------------------------------------------
>
>                 Key: JBSEAM-2133
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-2133
>             Project: JBoss Seam
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0.CR2
>            Reporter: Dan Allen
>         Assigned To: Dan Allen
>            Priority: Minor
>             Fix For: 2.0.1.GA
>
>         Attachments: JBSEAM-2133-v1.txt
>
>
> Currently, the EL notation in a property is only being evaluated if the property starts with "#{". There are two problems with this assumption.
> 1. Inline EL can only be used if the property starts with an expression (i.e. <property name="message">#{applicationName} is a cool application</property>)
> 2. There is no way to escape EL so that is is evaluated by the property accepting the string (rather than when the value is assigned).
> The correct behavior would be to treat the property value as a value expression if it CONTAINS "#{". The benefits are two fold:
> 1. A property value can use inline EL that is evaluated when the property value is set (see above)
> 2. The resolved value of the property can be EL (delayed EL) that is to be interpreted by the component as needed. This is done by escaping the EL per the unified EL spec (i.e. <property name="created-message">The user \#{user.name} has been created!</property)
> Surprisingly, everything is already in place. All that needs to happen is the check for EL needs to change from "startsWith" to "contains".

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list