You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@tiles.apache.org by "Mck SembWever (JIRA)" <ji...@apache.org> on 2010/03/10 17:27:27 UTC

[jira] Created: (TILES-502) wildcarding works in put-attribute@value but not in put-attribute@expression

wildcarding works in put-attribute@value but not in  put-attribute@expression
-----------------------------------------------------------------------------

                 Key: TILES-502
                 URL: https://issues.apache.org/jira/browse/TILES-502
             Project: Tiles
          Issue Type: Bug
          Components: tiles-core
    Affects Versions: 2.2.2
            Reporter: Mck SembWever
             Fix For: 2.2.2



This works:
    <definition name="REGEXP:([^.]+)">
        <put-attribute name="something" value="some-{1}.jsp"
    </definition>

but this does not:
    <definition name="REGEXP:([^.]+)">
        <put-attribute name="something" expression="some-{1}-${requestScope.someVariable}.jsp"
    </definition>

Attached is a patch, albeit that 
      st = st.replaceAll("'", "'''").replaceAll("\\Q${\\E", "\\$'{'");
definitely should be improved with something from javax.el that escapes
the el before pushing it through the MessageFormat.
But going down this path it should be made pluggable so that the various
registered attributeEvaluators are called to do the appropriate
escaping.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (TILES-502) wildcarding works in put-attribute@value but not in put-attribute@expression

Posted by "Mck SembWever (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TILES-502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12843672#action_12843672 ] 

Mck SembWever edited comment on TILES-502 at 3/10/10 6:15 PM:
--------------------------------------------------------------

It's not going to be entirely intuitive to users that they're required to escape ${' characters relating to EL expressions.
And it breaks API (existing expressions will break in wildcarded definitions).

The alternative (trying to automatically escape it)  can prove to be tricky though.

One quick-win is that, AFAIK, only EL provides a possible combination of literal string and expressions.

So a more robust solution (but not tested) is to leave the replace method as-is but to change replaceVarsInSimpleAttribute like:

        if (expressionObject != null) {
            String pattern = "\\Q${\\E([^}]+)\\Q}\\E";
            String result = expressionObject.getExpression();
            Matcher m = Pattern.compile(pattern).matcher(result);
            m.find();

            result = result.replaceAll(pattern, "EL_EXPRESSION");
            result = replace(result, vars);
            int group = 0;
            while(result.contains("EL_EXPRESSION")){
                result.replaceFirst("EL_EXPRESSION", m.group(++group));
            }
            nuattr.setExpressionObject(Expression.createExpression(result, expressionObject.getLanguage()));
        }


Either way i'm happy though.

      was (Author: michaelsembwever):
    It's not going to be entirely intuitive to users that they're required to escape ${' characters relating to EL expressions.
And it breaks API (existing expressions will break in wildcarded definitions).

The alternative (trying to automatically escape it)  can prove to be tricky though.

One quick-win is that, AFAIK, only EL provides a possible combination of literal string and expressions.

So a more robust solution (but not tested) is to leave the replace method as-is but to change replaceVarsInSimpleAttribute like:

        if (expressionObject != null) {
            String pattern = "\\Q${\\E([^}]+)\\Q}\\E";
            String result = expressionObject.getExpression();
            Matcher m = Pattern.compile(pattern).matcher(result);
            m.find();

            String result = result.replaceAll(pattern, "EL_EXPRESSION");
            result = replace(result, vars);
            int group = 0;
            while(result.contains("EL_EXPRESSION")){
                result.replaceFirst("EL_EXPRESSION", m.group(++group));
            }
            nuattr.setExpressionObject(Expression.createExpression(result, expressionObject.getLanguage()));
        }


Either way i'm happy though.
  
> wildcarding works in put-attribute@value but not in  put-attribute@expression
> -----------------------------------------------------------------------------
>
>                 Key: TILES-502
>                 URL: https://issues.apache.org/jira/browse/TILES-502
>             Project: Tiles
>          Issue Type: Bug
>          Components: tiles-core
>    Affects Versions: 2.2.2
>            Reporter: Mck SembWever
>             Fix For: 2.2.2
>
>         Attachments: tiles-502.patch
>
>
> This works:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" value="some-{1}.jsp"
>     </definition>
> but this does not:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" expression="some-{1}-${requestScope.someVariable}.jsp"
>     </definition>
> Attached is a patch, albeit that 
>       st = st.replaceAll("'", "'''").replaceAll("\\Q${\\E", "\\$'{'");
> definitely should be improved with something from javax.el that escapes
> the el before pushing it through the MessageFormat.
> But going down this path it should be made pluggable so that the various
> registered attributeEvaluators are called to do the appropriate
> escaping.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TILES-502) wildcarding works in put-attribute@value but not in put-attribute@expression

Posted by "Antonio Petrelli (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TILES-502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12843966#action_12843966 ] 

Antonio Petrelli commented on TILES-502:
----------------------------------------

You convinced me :-)
However, I prefer the first approach, since it is useful to overcome a limit of MessageFormat itself.
In fact, it should be possible to escape the opening curly brackets only if they are not followed by a number.
Since you seem a regexp whiz :-) can you translate it into an expression?
Do you think that this approach might work for all cases?

> wildcarding works in put-attribute@value but not in  put-attribute@expression
> -----------------------------------------------------------------------------
>
>                 Key: TILES-502
>                 URL: https://issues.apache.org/jira/browse/TILES-502
>             Project: Tiles
>          Issue Type: Bug
>          Components: tiles-core
>    Affects Versions: 2.2.2
>            Reporter: Mck SembWever
>             Fix For: 2.2.2
>
>         Attachments: tiles-502.patch
>
>
> This works:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" value="some-{1}.jsp"
>     </definition>
> but this does not:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" expression="some-{1}-${requestScope.someVariable}.jsp"
>     </definition>
> Attached is a patch, albeit that 
>       st = st.replaceAll("'", "'''").replaceAll("\\Q${\\E", "\\$'{'");
> definitely should be improved with something from javax.el that escapes
> the el before pushing it through the MessageFormat.
> But going down this path it should be made pluggable so that the various
> registered attributeEvaluators are called to do the appropriate
> escaping.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TILES-502) wildcarding works in put-attribute@value but not in put-attribute@expression

Posted by "Mck SembWever (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TILES-502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mck SembWever updated TILES-502:
--------------------------------

    Attachment: tiles-502.patch

> wildcarding works in put-attribute@value but not in  put-attribute@expression
> -----------------------------------------------------------------------------
>
>                 Key: TILES-502
>                 URL: https://issues.apache.org/jira/browse/TILES-502
>             Project: Tiles
>          Issue Type: Bug
>          Components: tiles-core
>    Affects Versions: 2.2.2
>            Reporter: Mck SembWever
>             Fix For: 2.2.2
>
>         Attachments: tiles-502.patch
>
>
> This works:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" value="some-{1}.jsp"
>     </definition>
> but this does not:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" expression="some-{1}-${requestScope.someVariable}.jsp"
>     </definition>
> Attached is a patch, albeit that 
>       st = st.replaceAll("'", "'''").replaceAll("\\Q${\\E", "\\$'{'");
> definitely should be improved with something from javax.el that escapes
> the el before pushing it through the MessageFormat.
> But going down this path it should be made pluggable so that the various
> registered attributeEvaluators are called to do the appropriate
> escaping.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TILES-502) wildcarding works in put-attribute@value but not in put-attribute@expression

Posted by "Mck SembWever (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TILES-502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mck SembWever updated TILES-502:
--------------------------------

    Attachment:     (was: tiles-502.patch)

> wildcarding works in put-attribute@value but not in  put-attribute@expression
> -----------------------------------------------------------------------------
>
>                 Key: TILES-502
>                 URL: https://issues.apache.org/jira/browse/TILES-502
>             Project: Tiles
>          Issue Type: Bug
>          Components: tiles-core
>    Affects Versions: 2.2.2
>            Reporter: Mck SembWever
>             Fix For: 2.2.2
>
>         Attachments: tiles-502.patch
>
>
> This works:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" value="some-{1}.jsp"
>     </definition>
> but this does not:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" expression="some-{1}-${requestScope.someVariable}.jsp"
>     </definition>
> Attached is a patch, albeit that 
>       st = st.replaceAll("'", "'''").replaceAll("\\Q${\\E", "\\$'{'");
> definitely should be improved with something from javax.el that escapes
> the el before pushing it through the MessageFormat.
> But going down this path it should be made pluggable so that the various
> registered attributeEvaluators are called to do the appropriate
> escaping.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TILES-502) wildcarding works in put-attribute@value but not in put-attribute@expression

Posted by "Antonio Petrelli (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TILES-502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12843621#action_12843621 ] 

Antonio Petrelli commented on TILES-502:
----------------------------------------

I agree on the first part of the patch: the variables need to be substituted.
However, I have some objection about the second part: probably we should do the assumption that the string will go into a MessageFormat object, therefore the escaping should be done when writing the expression itself.

WDYT?

> wildcarding works in put-attribute@value but not in  put-attribute@expression
> -----------------------------------------------------------------------------
>
>                 Key: TILES-502
>                 URL: https://issues.apache.org/jira/browse/TILES-502
>             Project: Tiles
>          Issue Type: Bug
>          Components: tiles-core
>    Affects Versions: 2.2.2
>            Reporter: Mck SembWever
>             Fix For: 2.2.2
>
>         Attachments: tiles-502.patch
>
>
> This works:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" value="some-{1}.jsp"
>     </definition>
> but this does not:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" expression="some-{1}-${requestScope.someVariable}.jsp"
>     </definition>
> Attached is a patch, albeit that 
>       st = st.replaceAll("'", "'''").replaceAll("\\Q${\\E", "\\$'{'");
> definitely should be improved with something from javax.el that escapes
> the el before pushing it through the MessageFormat.
> But going down this path it should be made pluggable so that the various
> registered attributeEvaluators are called to do the appropriate
> escaping.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TILES-502) wildcarding works in put-attribute@value but not in put-attribute@expression

Posted by "Antonio Petrelli (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TILES-502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Antonio Petrelli updated TILES-502:
-----------------------------------

    Remaining Estimate: 0h
     Original Estimate: 0h

I committed the patch from Mck SembWever in the framework trunk. Thanks a lot!
I will port the patch to the Tiles 3 sandbox ASAP. Until then this issue will remain open, however the code is already in place.

> wildcarding works in put-attribute@value but not in  put-attribute@expression
> -----------------------------------------------------------------------------
>
>                 Key: TILES-502
>                 URL: https://issues.apache.org/jira/browse/TILES-502
>             Project: Tiles
>          Issue Type: Bug
>          Components: tiles-core
>    Affects Versions: 2.2.2
>            Reporter: Mck SembWever
>            Assignee: Antonio Petrelli
>             Fix For: 2.2.2
>
>         Attachments: tiles-502.patch
>
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
> This works:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" value="some-{1}.jsp"
>     </definition>
> but this does not:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" expression="some-{1}-${requestScope.someVariable}.jsp"
>     </definition>
> Attached is a patch, albeit that 
>       st = st.replaceAll("'", "'''").replaceAll("\\Q${\\E", "\\$'{'");
> definitely should be improved with something from javax.el that escapes
> the el before pushing it through the MessageFormat.
> But going down this path it should be made pluggable so that the various
> registered attributeEvaluators are called to do the appropriate
> escaping.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (TILES-502) wildcarding works in put-attribute@value but not in put-attribute@expression

Posted by "Mck SembWever (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TILES-502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12843672#action_12843672 ] 

Mck SembWever edited comment on TILES-502 at 3/10/10 6:15 PM:
--------------------------------------------------------------

It's not going to be entirely intuitive to users that they're required to escape ${' characters relating to EL expressions.
And it breaks API (existing expressions will break in wildcarded definitions).

The alternative (trying to automatically escape it)  can prove to be tricky though.

One quick-win is that, AFAIK, only EL provides a possible combination of literal string and expressions.

So a more robust solution (but not tested) is to leave the replace method as-is but to change replaceVarsInSimpleAttribute like:

        if (expressionObject != null) {
            String pattern = "\\Q${\\E([^}]+)\\Q}\\E";
            String result = expressionObject.getExpression();
            Matcher m = Pattern.compile(pattern).matcher(result);
            m.find();

            result = result.replaceAll(pattern, "EL_EXPRESSION");
            result = replace(result, vars);
            int group = 0;
            while(result.contains("EL_EXPRESSION")){
                result = result.replaceFirst("EL_EXPRESSION", m.group(++group));
            }
            nuattr.setExpressionObject(Expression.createExpression(result, expressionObject.getLanguage()));
        }


Either way i'm happy though.

      was (Author: michaelsembwever):
    It's not going to be entirely intuitive to users that they're required to escape ${' characters relating to EL expressions.
And it breaks API (existing expressions will break in wildcarded definitions).

The alternative (trying to automatically escape it)  can prove to be tricky though.

One quick-win is that, AFAIK, only EL provides a possible combination of literal string and expressions.

So a more robust solution (but not tested) is to leave the replace method as-is but to change replaceVarsInSimpleAttribute like:

        if (expressionObject != null) {
            String pattern = "\\Q${\\E([^}]+)\\Q}\\E";
            String result = expressionObject.getExpression();
            Matcher m = Pattern.compile(pattern).matcher(result);
            m.find();

            result = result.replaceAll(pattern, "EL_EXPRESSION");
            result = replace(result, vars);
            int group = 0;
            while(result.contains("EL_EXPRESSION")){
                result.replaceFirst("EL_EXPRESSION", m.group(++group));
            }
            nuattr.setExpressionObject(Expression.createExpression(result, expressionObject.getLanguage()));
        }


Either way i'm happy though.
  
> wildcarding works in put-attribute@value but not in  put-attribute@expression
> -----------------------------------------------------------------------------
>
>                 Key: TILES-502
>                 URL: https://issues.apache.org/jira/browse/TILES-502
>             Project: Tiles
>          Issue Type: Bug
>          Components: tiles-core
>    Affects Versions: 2.2.2
>            Reporter: Mck SembWever
>             Fix For: 2.2.2
>
>         Attachments: tiles-502.patch
>
>
> This works:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" value="some-{1}.jsp"
>     </definition>
> but this does not:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" expression="some-{1}-${requestScope.someVariable}.jsp"
>     </definition>
> Attached is a patch, albeit that 
>       st = st.replaceAll("'", "'''").replaceAll("\\Q${\\E", "\\$'{'");
> definitely should be improved with something from javax.el that escapes
> the el before pushing it through the MessageFormat.
> But going down this path it should be made pluggable so that the various
> registered attributeEvaluators are called to do the appropriate
> escaping.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TILES-502) wildcarding works in put-attribute@value but not in put-attribute@expression

Posted by "Mck SembWever (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TILES-502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mck SembWever updated TILES-502:
--------------------------------

    Attachment: tiles-502.patch

> Since you seem a regexp whiz :-) can you translate it into an expression?

well that's blackmail and bribery rolled in one :-)
Here's the new patch as requested.

> Do you think that this approach might work for all cases? 

MessageFormat supports more than just {[0-9]+} occurrences, but i doubt Tiles2 cares about such extra MessageFormat functionality. So yes i think the concept and direction fits.

> wildcarding works in put-attribute@value but not in  put-attribute@expression
> -----------------------------------------------------------------------------
>
>                 Key: TILES-502
>                 URL: https://issues.apache.org/jira/browse/TILES-502
>             Project: Tiles
>          Issue Type: Bug
>          Components: tiles-core
>    Affects Versions: 2.2.2
>            Reporter: Mck SembWever
>             Fix For: 2.2.2
>
>         Attachments: tiles-502.patch
>
>
> This works:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" value="some-{1}.jsp"
>     </definition>
> but this does not:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" expression="some-{1}-${requestScope.someVariable}.jsp"
>     </definition>
> Attached is a patch, albeit that 
>       st = st.replaceAll("'", "'''").replaceAll("\\Q${\\E", "\\$'{'");
> definitely should be improved with something from javax.el that escapes
> the el before pushing it through the MessageFormat.
> But going down this path it should be made pluggable so that the various
> registered attributeEvaluators are called to do the appropriate
> escaping.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (TILES-502) wildcarding works in put-attribute@value but not in put-attribute@expression

Posted by "Antonio Petrelli (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TILES-502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Antonio Petrelli closed TILES-502.
----------------------------------

    Resolution: Fixed

> wildcarding works in put-attribute@value but not in  put-attribute@expression
> -----------------------------------------------------------------------------
>
>                 Key: TILES-502
>                 URL: https://issues.apache.org/jira/browse/TILES-502
>             Project: Tiles
>          Issue Type: Bug
>          Components: tiles-core
>    Affects Versions: 2.2.2
>            Reporter: Mck SembWever
>            Assignee: Antonio Petrelli
>             Fix For: 2.2.2
>
>         Attachments: tiles-502.patch
>
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
> This works:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" value="some-{1}.jsp"
>     </definition>
> but this does not:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" expression="some-{1}-${requestScope.someVariable}.jsp"
>     </definition>
> Attached is a patch, albeit that 
>       st = st.replaceAll("'", "'''").replaceAll("\\Q${\\E", "\\$'{'");
> definitely should be improved with something from javax.el that escapes
> the el before pushing it through the MessageFormat.
> But going down this path it should be made pluggable so that the various
> registered attributeEvaluators are called to do the appropriate
> escaping.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TILES-502) wildcarding works in put-attribute@value but not in put-attribute@expression

Posted by "Antonio Petrelli (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TILES-502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12844070#action_12844070 ] 

Antonio Petrelli commented on TILES-502:
----------------------------------------

It seems good, thanks! I will apply it this evening (CET), along with a test case.

> wildcarding works in put-attribute@value but not in  put-attribute@expression
> -----------------------------------------------------------------------------
>
>                 Key: TILES-502
>                 URL: https://issues.apache.org/jira/browse/TILES-502
>             Project: Tiles
>          Issue Type: Bug
>          Components: tiles-core
>    Affects Versions: 2.2.2
>            Reporter: Mck SembWever
>             Fix For: 2.2.2
>
>         Attachments: tiles-502.patch
>
>
> This works:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" value="some-{1}.jsp"
>     </definition>
> but this does not:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" expression="some-{1}-${requestScope.someVariable}.jsp"
>     </definition>
> Attached is a patch, albeit that 
>       st = st.replaceAll("'", "'''").replaceAll("\\Q${\\E", "\\$'{'");
> definitely should be improved with something from javax.el that escapes
> the el before pushing it through the MessageFormat.
> But going down this path it should be made pluggable so that the various
> registered attributeEvaluators are called to do the appropriate
> escaping.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (TILES-502) wildcarding works in put-attribute@value but not in put-attribute@expression

Posted by "Antonio Petrelli (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TILES-502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Antonio Petrelli reassigned TILES-502:
--------------------------------------

    Assignee: Antonio Petrelli

> wildcarding works in put-attribute@value but not in  put-attribute@expression
> -----------------------------------------------------------------------------
>
>                 Key: TILES-502
>                 URL: https://issues.apache.org/jira/browse/TILES-502
>             Project: Tiles
>          Issue Type: Bug
>          Components: tiles-core
>    Affects Versions: 2.2.2
>            Reporter: Mck SembWever
>            Assignee: Antonio Petrelli
>             Fix For: 2.2.2
>
>         Attachments: tiles-502.patch
>
>
> This works:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" value="some-{1}.jsp"
>     </definition>
> but this does not:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" expression="some-{1}-${requestScope.someVariable}.jsp"
>     </definition>
> Attached is a patch, albeit that 
>       st = st.replaceAll("'", "'''").replaceAll("\\Q${\\E", "\\$'{'");
> definitely should be improved with something from javax.el that escapes
> the el before pushing it through the MessageFormat.
> But going down this path it should be made pluggable so that the various
> registered attributeEvaluators are called to do the appropriate
> escaping.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TILES-502) wildcarding works in put-attribute@value but not in put-attribute@expression

Posted by "Mck SembWever (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TILES-502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mck SembWever updated TILES-502:
--------------------------------

    Attachment:     (was: tiles-502.patch)

> wildcarding works in put-attribute@value but not in  put-attribute@expression
> -----------------------------------------------------------------------------
>
>                 Key: TILES-502
>                 URL: https://issues.apache.org/jira/browse/TILES-502
>             Project: Tiles
>          Issue Type: Bug
>          Components: tiles-core
>    Affects Versions: 2.2.2
>            Reporter: Mck SembWever
>             Fix For: 2.2.2
>
>         Attachments: tiles-502.patch
>
>
> This works:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" value="some-{1}.jsp"
>     </definition>
> but this does not:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" expression="some-{1}-${requestScope.someVariable}.jsp"
>     </definition>
> Attached is a patch, albeit that 
>       st = st.replaceAll("'", "'''").replaceAll("\\Q${\\E", "\\$'{'");
> definitely should be improved with something from javax.el that escapes
> the el before pushing it through the MessageFormat.
> But going down this path it should be made pluggable so that the various
> registered attributeEvaluators are called to do the appropriate
> escaping.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TILES-502) wildcarding works in put-attribute@value but not in put-attribute@expression

Posted by "Mck SembWever (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TILES-502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mck SembWever updated TILES-502:
--------------------------------

    Attachment: tiles-502.patch

> wildcarding works in put-attribute@value but not in  put-attribute@expression
> -----------------------------------------------------------------------------
>
>                 Key: TILES-502
>                 URL: https://issues.apache.org/jira/browse/TILES-502
>             Project: Tiles
>          Issue Type: Bug
>          Components: tiles-core
>    Affects Versions: 2.2.2
>            Reporter: Mck SembWever
>             Fix For: 2.2.2
>
>         Attachments: tiles-502.patch
>
>
> This works:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" value="some-{1}.jsp"
>     </definition>
> but this does not:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" expression="some-{1}-${requestScope.someVariable}.jsp"
>     </definition>
> Attached is a patch, albeit that 
>       st = st.replaceAll("'", "'''").replaceAll("\\Q${\\E", "\\$'{'");
> definitely should be improved with something from javax.el that escapes
> the el before pushing it through the MessageFormat.
> But going down this path it should be made pluggable so that the various
> registered attributeEvaluators are called to do the appropriate
> escaping.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TILES-502) wildcarding works in put-attribute@value but not in put-attribute@expression

Posted by "Mck SembWever (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TILES-502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12843672#action_12843672 ] 

Mck SembWever commented on TILES-502:
-------------------------------------

It's not going to be entirely intuitive to users that they're required to escape ${' characters relating to EL expressions.
And it breaks API (existing expressions will break in wildcarded definitions).

The alternative (trying to automatically escape it)  can prove to be tricky though.

One quick-win is that, AFAIK, only EL provides a possible combination of literal string and expressions.

So a more robust solution (but not tested) is to leave the replace method as-is but to change replaceVarsInSimpleAttribute like:

        if (expressionObject != null) {
            String pattern = "\\Q${\\E([^}]+)\\Q}\\E";
            String result = expressionObject.getExpression();
            Matcher m = Pattern.compile(pattern).matcher(result);
            m.find();

            String result = result.replaceAll(pattern, "EL_EXPRESSION");
            result = replace(result, vars);
            int group = 0;
            while(result.contains("EL_EXPRESSION")){
                result.replaceFirst("EL_EXPRESSION", m.group(++group));
            }
            nuattr.setExpressionObject(Expression.createExpression(result, expressionObject.getLanguage()));
        }


Either way i'm happy though.

> wildcarding works in put-attribute@value but not in  put-attribute@expression
> -----------------------------------------------------------------------------
>
>                 Key: TILES-502
>                 URL: https://issues.apache.org/jira/browse/TILES-502
>             Project: Tiles
>          Issue Type: Bug
>          Components: tiles-core
>    Affects Versions: 2.2.2
>            Reporter: Mck SembWever
>             Fix For: 2.2.2
>
>         Attachments: tiles-502.patch
>
>
> This works:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" value="some-{1}.jsp"
>     </definition>
> but this does not:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" expression="some-{1}-${requestScope.someVariable}.jsp"
>     </definition>
> Attached is a patch, albeit that 
>       st = st.replaceAll("'", "'''").replaceAll("\\Q${\\E", "\\$'{'");
> definitely should be improved with something from javax.el that escapes
> the el before pushing it through the MessageFormat.
> But going down this path it should be made pluggable so that the various
> registered attributeEvaluators are called to do the appropriate
> escaping.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (TILES-502) wildcarding works in put-attribute@value but not in put-attribute@expression

Posted by "Mck SembWever (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TILES-502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12843672#action_12843672 ] 

Mck SembWever edited comment on TILES-502 at 3/10/10 7:16 PM:
--------------------------------------------------------------

It's not going to be entirely intuitive to users that they're required to escape ${' characters relating to EL expressions.
And it breaks API (existing expressions will break in wildcarded definitions).

The alternative (trying to automatically escape it)  can prove to be tricky though.

One quick-win is that, AFAIK, only EL provides a possible combination of literal string and expressions.

So a more robust solution (now tested) is to leave the replace method as-is but to change replaceVarsInSimpleAttribute like:

        if (expressionObject != null) {
            Pattern elExpression = Pattern.compile("\\Q${\\E([^}]+)\\Q}\\E"); //@todo make static final constant
            String result = expressionObject.getExpression();
            Matcher m = elExpression.matcher(result);

            result = replace(elExpression.matcher(result).replaceAll("EL_EXPRESSION"), vars);
            while(m.find()){
                result = result.replaceFirst("EL_EXPRESSION", "\\${" + m.group(1) + "}");
            }
            nuattr.setExpressionObject(Expression.createExpression(result, expressionObject.getLanguage()));
        }


Either way i'm happy though.

      was (Author: michaelsembwever):
    It's not going to be entirely intuitive to users that they're required to escape ${' characters relating to EL expressions.
And it breaks API (existing expressions will break in wildcarded definitions).

The alternative (trying to automatically escape it)  can prove to be tricky though.

One quick-win is that, AFAIK, only EL provides a possible combination of literal string and expressions.

So a more robust solution (but not tested) is to leave the replace method as-is but to change replaceVarsInSimpleAttribute like:

        if (expressionObject != null) {
            String pattern = "\\Q${\\E([^}]+)\\Q}\\E";
            String result = expressionObject.getExpression();
            Matcher m = Pattern.compile(pattern).matcher(result);
            m.find();

            result = result.replaceAll(pattern, "EL_EXPRESSION");
            result = replace(result, vars);
            int group = 0;
            while(result.contains("EL_EXPRESSION")){
                result = result.replaceFirst("EL_EXPRESSION", m.group(++group));
            }
            nuattr.setExpressionObject(Expression.createExpression(result, expressionObject.getLanguage()));
        }


Either way i'm happy though.
  
> wildcarding works in put-attribute@value but not in  put-attribute@expression
> -----------------------------------------------------------------------------
>
>                 Key: TILES-502
>                 URL: https://issues.apache.org/jira/browse/TILES-502
>             Project: Tiles
>          Issue Type: Bug
>          Components: tiles-core
>    Affects Versions: 2.2.2
>            Reporter: Mck SembWever
>             Fix For: 2.2.2
>
>         Attachments: tiles-502.patch
>
>
> This works:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" value="some-{1}.jsp"
>     </definition>
> but this does not:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" expression="some-{1}-${requestScope.someVariable}.jsp"
>     </definition>
> Attached is a patch, albeit that 
>       st = st.replaceAll("'", "'''").replaceAll("\\Q${\\E", "\\$'{'");
> definitely should be improved with something from javax.el that escapes
> the el before pushing it through the MessageFormat.
> But going down this path it should be made pluggable so that the various
> registered attributeEvaluators are called to do the appropriate
> escaping.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TILES-502) wildcarding works in put-attribute@value but not in put-attribute@expression

Posted by "Antonio Petrelli (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TILES-502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Antonio Petrelli updated TILES-502:
-----------------------------------


Patch ported to tiles3 sandbox. I can close the issue now.

> wildcarding works in put-attribute@value but not in  put-attribute@expression
> -----------------------------------------------------------------------------
>
>                 Key: TILES-502
>                 URL: https://issues.apache.org/jira/browse/TILES-502
>             Project: Tiles
>          Issue Type: Bug
>          Components: tiles-core
>    Affects Versions: 2.2.2
>            Reporter: Mck SembWever
>            Assignee: Antonio Petrelli
>             Fix For: 2.2.2
>
>         Attachments: tiles-502.patch
>
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
> This works:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" value="some-{1}.jsp"
>     </definition>
> but this does not:
>     <definition name="REGEXP:([^.]+)">
>         <put-attribute name="something" expression="some-{1}-${requestScope.someVariable}.jsp"
>     </definition>
> Attached is a patch, albeit that 
>       st = st.replaceAll("'", "'''").replaceAll("\\Q${\\E", "\\$'{'");
> definitely should be improved with something from javax.el that escapes
> the el before pushing it through the MessageFormat.
> But going down this path it should be made pluggable so that the various
> registered attributeEvaluators are called to do the appropriate
> escaping.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.