You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Adam Lipscombe <ad...@expensys.com> on 2005/09/07 15:53:38 UTC

Overlaying a propery definition with > 1 ApplicationResources.properties file

Folks,


We have a standard ApplicationResources.properties file. If customers want
customised labels I want to be able to include a 2nd
ApplicationResources.properties file that contains only those labels that
have been customised. The 2nd label definition should override the 1st (i.e.
standard) definition.
If no customisations have been specified the 2nd file would be empty.


E.g. 

ApplicationResources.properties

global.greeting=Hello World
global.message=how are you?


CustomApplicationResources.properties

global.greeting=Hi There!



In the above case using global.greeting would result in "Hi There!" and
global.message "how are you?"


Looking at the Struts documentation it seems that if > 1  properties files
are used one must give them a key in the struts-config file. This key must
then be used by the bean:message tags. This wont work in this context 'cos
the bean:message tags will not be aware of which file the definition
resides.


Is it possible to overlay properties definitions in a second file like this
without changing the bean:message tags?


TIA -Adam




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Overlaying a propery definition with > 1 ApplicationResources.properties file

Posted by Gareth Evans <ga...@msoft.co.uk>.
Hi Adam,

You can do this by extending the default MessageResourceFactory to load these files.  I use this 
approach in my application to load the messages in from a database.

Use the following in your struts-config

<message-resources parameter="ApplicationResources" null="true" 
factory="com.your.MessageResourceFactory" />

Regards,

Gareth

Adam Lipscombe wrote:

> Folks,
> 
> 
> We have a standard ApplicationResources.properties file. If customers want
> customised labels I want to be able to include a 2nd
> ApplicationResources.properties file that contains only those labels that
> have been customised. The 2nd label definition should override the 1st (i.e.
> standard) definition.
> If no customisations have been specified the 2nd file would be empty.
> 
> 
> E.g. 
> 
> ApplicationResources.properties
> 
> global.greeting=Hello World
> global.message=how are you?
> 
> 
> CustomApplicationResources.properties
> 
> global.greeting=Hi There!
> 
> 
> 
> In the above case using global.greeting would result in "Hi There!" and
> global.message "how are you?"
> 
> 
> Looking at the Struts documentation it seems that if > 1  properties files
> are used one must give them a key in the struts-config file. This key must
> then be used by the bean:message tags. This wont work in this context 'cos
> the bean:message tags will not be aware of which file the definition
> resides.
> 
> 
> Is it possible to overlay properties definitions in a second file like this
> without changing the bean:message tags?
> 
> 
> TIA -Adam
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 

-- 
Gareth Evans

MSoft eSolutions Limited
Technology Centre
Inward Way
Rossmore Business Park
Ellesmere Port
Cheshire
CH65 3EN

-- 
Tel:    +44 (0)870 0100 704
Fax:    +44 (0)870 9010 705
E-Mail: gareth@msoft.co.uk
Web:    www.msoft.co.uk

----------------------------------------------
Terms:
Please note that any prices quoted within this e-mail are subject to VAT.
All program details and code described in this e-mail are subject to
copyright © of MSoft eSolutions Limited and remain the intellectual
property of MSoft eSolutions Limited.
Any proposal or pricing information contained within this e-mail are
subject to MSoft eSolutions' Terms and Conditions
----------------------------------------------
Disclaimer:
This message is intended only for use of the addressee. If this message
was sent to you in error, please notify the sender and delete this
message. MSoft eSolutions Limited cannot accept responsibility for viruses,
so please scan attachments. Views expressed in this message do not
necessarily reflect those of MSoft eSolutions Limited who will not
necessarily be bound by its contents.



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org