You can only override a key that has been added, and only provide a
single override for any key.  Processing goes in two steps:  first the
adds are applied, then the overrides.  In any case, I'm very confident
about the code and tests for this logic, so if you open a JIRA, be
sure to include a test case demonstrating the failure.

Tapestry has evolved over time; the override logic came later: in
earlier code, similar effects were accomplished by having multiple
services; this is how SymbolSource works to this day: there's the
"ApplicationDefaults" SymbolProvider, and the "FactoryDefaults"
SymbolProvider; most likely (without looking at your code) the issue
is that you are mixing and matching between these two services, just
causing your confusion.  For an example, an override inside
FactoryDefaults will be ignored in favor of an add to
ApplicationDefaults.

On Wed, Jan 25, 2012 at 1:15 AM, Sigbjørn Tvedt <[email protected]> wrote:
> Hi.
>
> I am trying to integrate tapestry5-ckeditor(1) in the quickstart examples,
> but I have a problem figuring out how tapestry is adding/updating the
> application_version key.
>
> In the AppModule, application_version is added by using override(x,y).
> In the DevelopmentModule, application_version is added bye using add(x,y).
>
>
> I am writing the values to the console before they are assigned, and this
> is what I get:
> -----
> DevelopmentModule: SymbolConstants.APPLICATION_VERSION=1.0-SNAPSHOT-DEV
> AppModule:SymbolConstants.APPLICATION_VERSION=1.0-SNAPSHOT
> -----
>
>
> According to the printline, DevelopmentModule is added before AppModule
> overrides the application_version.
> The part where I have a problem understanding is that the application is
> using the value from  developmentModule where I am adding the value instead
> of using the value that was overridden in AppModule. I have also noticed
> that if I try to move the line that adds the  from DevelopmentModule into
> AppModule, I will get and exception saying that the value already exists,
> and no key if I try the opposite.
>
>
>
> Also, I think I found a bug in the override code (
> org.apache.tapestry5.ioc.MappedConfiguration). The comment on the method is:
>
> /**
> * Overrides an existing contribution by its key.
> *
> * @param key
> * unique id of value to override
> * @param value
> * new value, or null to remove the key entirely
> * @since 5.1.0.0
> */
> void override(K key, V value);
>
> This looks good, but in the ValidatingMappedConfigurationWrapper, an
> exception is thrown if the key exists (even if you try to insert a "null")
>
>
> To sum up:
> Why is the value inserted by a call to add used instead of the value
> inserted by using override
> Why should you use override in AppModule and add in other modules
> How is it possible to replace a key?
> Is the comment wrong at the override code or should I file a jira?
>
>
>
> Regards.
> Sigbjørn Tvedt
>
>
> 1: https://github.com/plannowtech/tapestry5-ckeditor



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to