You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Howard M. Lewis Ship (JIRA)" <ta...@jakarta.apache.org> on 2005/09/09 22:37:30 UTC

[jira] Commented: (TAPESTRY-535) When binding prefix not found, binding is treated as literal regardless of default prefix

    [ http://issues.apache.org/jira/browse/TAPESTRY-535?page=comments#action_12323080 ] 

Howard M. Lewis Ship commented on TAPESTRY-535:
-----------------------------------------------

Seems like the correct way to fix this is to only recognize the prefix if it is a well known prefix (one defined in the configuration).

If so, the prefix is used.

If not, the default prefix (literal: for templates, ognl: elsewhere) is used.

In you example, getCapitalized('a:  will not be recognized as a binding prefix, but since it occurs in an XML specification, the implicit ognl; prefix will be used, and the entire thing will be interpreted properly.

In a template, you would have provided a proper ognl: prefix anyway.

> When binding prefix not found, binding is treated as literal regardless of default prefix
> -----------------------------------------------------------------------------------------
>
>          Key: TAPESTRY-535
>          URL: http://issues.apache.org/jira/browse/TAPESTRY-535
>      Project: Tapestry
>         Type: Bug
>   Components: Framework
>     Versions: 4.0
>  Environment: Windows XP
>     Reporter: Kent Tong
>     Assignee: Howard M. Lewis Ship

>
> For a binding like this:
> <component id="foo" type="Insert">
>   <binding name="value" value="ognl:getCapitalized('a:b')"/>
> </component>
> works and will output "A:B". But if the ognl prefix is not specified (it is the default):
> <component id="foo" type="Insert">
>   <binding name="value" value="getCapitalized('a:b')"/>
> </component>
> Then it will output "getCapitalized('a:b')". That is, it is treating it as a literal, not an ognl.
> This is because the BindingSource is misled by the colon in 'a:b' to believe that
> the binding prefix "getCapitalized('a". So the prefix is unknown. Then it is treating
> unknown prefix as literal:
> public class BindingSourceImpl implements BindingSource
> {
>     public IBinding createBinding(IComponent component, String bindingDescription,
>             String reference, String defaultPrefix, Location location)
>     {
>         String prefix = defaultPrefix;
>         String path = reference;
>         int colonx = reference.indexOf(':');
>         if (colonx > 1) //Step1: blindingly looking for a colon
>         {
>             prefix = reference.substring(0, colonx);
>             if (_factoryMap.containsKey(prefix))
>                 path = reference.substring(colonx + 1);
>         }
>         BindingFactory factory = (BindingFactory) _factoryMap.get(prefix); //Step2: unknown prefix
>         if (factory == null)
>             factory = _literalBindingFactory; //Step3: treat unknown prefix as literal
>         return factory.createBinding(component, bindingDescription, path, location);
>     }
> }
> I'd suggest that the prefix should be checked to see if it contains alphabet chars only. If yes, go
> ahead with the existing logic. If not, it should be treated as no prefix is provided (so the default 
> prefix should be used). For an unknown prefix, the existing logic can still be applied (or should
> throw an exception?).

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


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org