I've been thinking about this for a bit.

I think I would rather see component default revamped more flexibly.

For instance, if we had a sort of "ComponentDefaultProvider" service.  This 
would be used by ParameterWorker to find a default binding for parameters.
It would likely be a chain of command, using the first non-null binding 
returned from within the chain, or perhaps a "Strategy" service, using the 
component class as a lookup key.  The current rule(s) for "defaultXXX" as well 
as the @Component's value could be encapsulated this way (with 
@Component(value="binding") taking precedence over defaultXXX).  Then it would 
be a simple matter to contribute a new "DefaultProvider" to the 
ComponentDefaultProvider.  I'd have to play with it more to know exactly what 
the interface would look like, but it would probably take the name of the 
parameter and maybe the plastic class? as well as the parameter annotation (at 
least the "value" portion of the annotation).

If you had something like that, you could easily specify overrides in a variety 
of ways, including much more complicated/dynamic ways than specifying a symbol.

My $0.02.

Robert

On Oct 6, 2011, at 10/65:16 AM , Massimo Lusetti wrote:

> BTW this is relative to TAP5-1677
> 
> On Thu, Oct 6, 2011 at 12:06 PM, Massimo Lusetti <mluse...@gmail.com> wrote:
> 
>> What do you think about changing the implementation of
>> SymbolBindingFactory to let it check if the resulted symbol value is a
>> "binding expression" and if true let it resolve the binding and return
>> the actual binding instead of the symbol value ?
>> 
>> This will let you declare a symbol which is a binding expression and
>> have the binding resolved when the symbol is evaluated, for ex this
>> will let you specify the Block for the empty Grid in a Symbol like
>> "block:empty" and the Block binding will be resolved at runtime.
>> 
>> Is this something wanted ? ... I think it could be useful at least for
>> components writers.
>> 
>> Let me know what you think, here is the diff:
>> 
>> diff --git 
>> a/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/SymbolBindingFactory.java
>> b/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/SymbolBindingFactory.java
>> index dce5a6b..b30786c 100644
>> --- 
>> a/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/SymbolBindingFactory.java
>> +++ 
>> b/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/SymbolBindingFactory.java
>> @@ -18,22 +18,32 @@ import org.apache.tapestry5.ComponentResources;
>>  import org.apache.tapestry5.ioc.Location;
>>  import org.apache.tapestry5.ioc.services.SymbolSource;
>>  import org.apache.tapestry5.services.BindingFactory;
>> +import org.apache.tapestry5.services.BindingSource;
>> 
>>  public class SymbolBindingFactory implements BindingFactory
>>  {
>> +    private BindingSource bindingSource;
>>     private SymbolSource symbolSource;
>> 
>> -    public SymbolBindingFactory(SymbolSource symbolSource)
>> +    public SymbolBindingFactory(SymbolSource symbolSource,
>> BindingSource bindingSource)
>>     {
>> +        this.bindingSource = bindingSource;
>>         this.symbolSource = symbolSource;
>>     }
>> 
>>     public Binding newBinding(String description, ComponentResources 
>> container,
>>             ComponentResources component, String expression, Location 
>> location)
>>     {
>> -
>>         String value = symbolSource.valueForSymbol(expression);
>> -
>> +
>> +        int colon = value.indexOf(":");
>> +
>> +        if (colon > 0)
>> +        {
>> +            return bindingSource.newBinding(description, container, 
>> component,
>> +                    value.substring(0, colon), value.substring(colon
>> + 1), location);
>> +        }
>> +
>>         return new LiteralBinding(location, description, value);
>>     }
>> 
>> Cheers
>> --
>> Massimo
>> http://meridio.blogspot.com
>> 
> 
> 
> 
> -- 
> Massimo
> http://meridio.blogspot.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: dev-h...@tapestry.apache.org
> 


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

Reply via email to