You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Lorenzo Bolzani <l....@gmail.com> on 2008/06/30 12:49:33 UTC

Adding custom resource properties files

Hi,
we have two pages sharing the same set of user messages so we would
like to be able to share the same file.
The two pages are different and cannot subclass a same parent.
We cannot extract a common component because we have two different
views on the same data.

Maybe we could define an empty panel and share that only for the user
massages but I do not like this idea.

Is there a way to add/override a new resource file at the page level?
So that key are looked up in this way:

component
form
page
custom page file    <----- this is new
application

and at the class level too. In other words I just want to insert e new file.

We looked at IResourceLoader and this looks like an option
(registering a custom Loader in the application init()). We tried and
this works.

The problem is how to integrate this new Loader with the standard
ComponentStringResourceLoader so that the key is looked up also in the
standard way.

We had a look at PropertiesFactory trying to register a new file, but
the list of resources is determined by a ResourceNameIterator in the
method loadStringResources and is not easy to modify the behaviour of
this method.
So the only options seems to be to extend
ComponentStringResourceLoader overriding loadStringResource(Class,
String, Locale, String) with a big cut and paste.

Is there any other option?


Thanks, bye


Lorenzo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Adding custom resource properties files

Posted by Lorenzo Bolzani <l....@gmail.com>.
2008/6/30 Scott Swank <sc...@gmail.com>:
> The ComponentStringResourceLoader uses an Iterator named something
> like (no code in front of me) "ResourceNameIterator".  This iterator
> is used to find resources and markup.  You can't just set it on the
> Application.getResourceSettings (though I should create a jira & patch
> for that...), so you have to subclass the main string and markup
> loaders to use your own iterator.  Then you put those loaders on
> Application.getResouceSettings.

Yes, it would be useful to be able to replace/configure the
ResourceNameIterator with a custom one (even be able to override a
createResourceNameIterator method could be a useful quick fix).
In the meantime I think I'll override the whole loadStringResources in
Component*Loader.

Igor, your suggestion is correct, but we are just moving away the
messages from the application file because there are too many.
For each "entity" we have two pages (the search/list and the
detail/edit) sharing the same column headers/field labels.
So this situation is recurring in our application and the file is
growing too much.

Thanks, bye

Lorenzo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Adding custom resource properties files

Posted by Scott Swank <sc...@gmail.com>.
The ComponentStringResourceLoader uses an Iterator named something
like (no code in front of me) "ResourceNameIterator".  This iterator
is used to find resources and markup.  You can't just set it on the
Application.getResourceSettings (though I should create a jira & patch
for that...), so you have to subclass the main string and markup
loaders to use your own iterator.  Then you put those loaders on
Application.getResouceSettings.

I'll fill in more details after I'm at work if that above is unclear.

- Scott


On Mon, Jun 30, 2008 at 3:49 AM, Lorenzo Bolzani <l....@gmail.com> wrote:
> Hi,
> we have two pages sharing the same set of user messages so we would
> like to be able to share the same file.
> The two pages are different and cannot subclass a same parent.
> We cannot extract a common component because we have two different
> views on the same data.
>
> Maybe we could define an empty panel and share that only for the user
> massages but I do not like this idea.
>
> Is there a way to add/override a new resource file at the page level?
> So that key are looked up in this way:
>
> component
> form
> page
> custom page file    <----- this is new
> application
>
> and at the class level too. In other words I just want to insert e new file.
>
> We looked at IResourceLoader and this looks like an option
> (registering a custom Loader in the application init()). We tried and
> this works.
>
> The problem is how to integrate this new Loader with the standard
> ComponentStringResourceLoader so that the key is looked up also in the
> standard way.
>
> We had a look at PropertiesFactory trying to register a new file, but
> the list of resources is determined by a ResourceNameIterator in the
> method loadStringResources and is not easy to modify the behaviour of
> this method.
> So the only options seems to be to extend
> ComponentStringResourceLoader overriding loadStringResource(Class,
> String, Locale, String) with a big cut and paste.
>
> Is there any other option?
>
>
> Thanks, bye
>
>
> Lorenzo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Adding custom resource properties files

Posted by Igor Vaynberg <ig...@gmail.com>.
why not put these common messages into yourapplication.properties ?

-igor

On Mon, Jun 30, 2008 at 3:49 AM, Lorenzo Bolzani <l....@gmail.com> wrote:
> Hi,
> we have two pages sharing the same set of user messages so we would
> like to be able to share the same file.
> The two pages are different and cannot subclass a same parent.
> We cannot extract a common component because we have two different
> views on the same data.
>
> Maybe we could define an empty panel and share that only for the user
> massages but I do not like this idea.
>
> Is there a way to add/override a new resource file at the page level?
> So that key are looked up in this way:
>
> component
> form
> page
> custom page file    <----- this is new
> application
>
> and at the class level too. In other words I just want to insert e new file.
>
> We looked at IResourceLoader and this looks like an option
> (registering a custom Loader in the application init()). We tried and
> this works.
>
> The problem is how to integrate this new Loader with the standard
> ComponentStringResourceLoader so that the key is looked up also in the
> standard way.
>
> We had a look at PropertiesFactory trying to register a new file, but
> the list of resources is determined by a ResourceNameIterator in the
> method loadStringResources and is not easy to modify the behaviour of
> this method.
> So the only options seems to be to extend
> ComponentStringResourceLoader overriding loadStringResource(Class,
> String, Locale, String) with a big cut and paste.
>
> Is there any other option?
>
>
> Thanks, bye
>
>
> Lorenzo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org