Martijn Dashorst wrote:
>
> # Panel.properties
> foo3=Foo3 from panel.properties
>
> # Page.properties
> panel.foo1=panel.foo1 from page.properties
> panel.foo2=panel.foo2 from page.properties
> foo2=foo2 from page.properties
> foo3=foo3 from page.properties
>
Juergen Donnerstag wrote:
>
> I would have expected
>
> <table>
> <tr><td>Foo1</td><td>panel.foo1 from page.properties</td></tr>
> <tr><td>Foo2</td><td>panel.foo2 from page.properties</td></tr>
> <tr><td>Foo3</td><td>foo3 from page.properties</td></tr>
> </table>
>
> a) panel.fooX is more specific than fooX and should take precendence
> b) assume you purchase (no source code) a ready made set of wicket
> components with pre-configured properties which you can not change.
> But since it is a component you will add it to a page, panel whatever.
> Hence adding a property to page should overwrite what is
> pre-configured by the vendor. Which however is a little bit dangerous
> since if you add another component with the same id to the page (no
> path), they may end up using the same property.
>
I agree with a) but think for foo3 the more local string in panel.properties
should take precedence over the more general one defined in page.properties.
If one wants to override a string defined in a subcomponent's resource file,
the notation using the component id as a prefix is sufficient and very clear
to the reader but currently there is no way to NOT override a subcomponent
if the parent uses the same key for some reason.
Example:
I have many panels and ALL of them define a "title" in their own properties
files. Now I want to create a more complex panel of some of the smaller
ones. To stick to my rule of defining a title property for each panel, the
complex panel's title overrides the titles of the subpanels.
complexpanel.properties:
title=Complex Title
panel1.properties:
title=Panel 1 Title
panel2.properties:
title=Panel 2 Title
If complexpanel contains panel1 and panel2 they both display "Complex Title"
as their title.
Looking at the Javadoc of ComponentStringResourceLoader, this seems to be
intentional but I think the behaviour is not the optimal solution.
Overriding is still possible using e.g. "panel1.title" in
complexpanel.properties, but NOT overriding is not possible.
Suggestion:
Add a setting which might default to the current behaviour that allows to
turn off the lookup of the non-prefixed key in the parents resource files.
ComponentStringResourceLoader.loadStringResource(final Component component,
final String key)
would need to check this settings flag:
// If not found, than check if a property with the
'key' provided by
// the user can be found.
if (string == null) && CHECK SETTING HERE
{
string = loadStringResource(clazz, key, locale,
style);
}
What do you think?
--
View this message in context:
http://www.nabble.com/On-resource-bundles-and-component-path%27s-tf4693318.html#a13451135
Sent from the Wicket - Dev mailing list archive at Nabble.com.