Ok, thanks a lot for you help.
 
Can you handle different languages with your own properties file?, which
is what I want to be able to do as well.
 
Best regards
 
Lasse

        -----Original Message----- 
        From: Sasha Borodin 
        Sent: to 2003-08-28 17:24 
        To: Struts Users Mailing List 
        Cc: 
        Subject: Re: Accessing MessageResources
        
        

        Lars,
        
        Struts loads the property files you declared in struts-config
into a class
        called PropertyMessageResources, then binds that object to the
        ServletContext; that's where <bean:message> tags get their data
from.
        
        The functionality you're looking for (retrieving a collection of
keys) is
        not part of the PropertyMessgeResources class, and there is no
tag support
        for it (struts or JSTL).  What I've done is load two copies of a
properties
        file at startup:
            1.  Since it's declared in struts-config, one copy gets
loaded by Struts
        into PropertyMessageResources, which can then be used by
<bean:message>
        tags.
            2.  I also have a plug-in (which gets executed at startup)
where I load
        my own copy of the properties file into a custom data structure
(but you can
        use a simple HashMap), and bind it to ServletContext.  I use the
        ResourceBundle.getBundle() mechanism to find and load the file.
        
        The first copy supports struts message tags.  The second copy
(my custom
        data structure) I can use to extract all or a range of
keys/values, sort
        keys/values, and other more complex tasks.  I've also written
methods to
        return a Collection of Map.Entry's to feed to
<html:optionsCollection>, and
        other goodies for the html tag lib.
        
        
        -Sasha
        
        On 8/28/03 8:52, "Lars Bergström" <[EMAIL PROTECTED]>
wrote:
        
        > Hi,
        >
        > I would like to retrieve all message resource keys held by
Struts read
        > from my application.properties file. Not only for one
proprety. What I
        > am looking for is something like the method propertyNames in
        > java.util.Properties.
        >
        > BR Lasse
        >
        >
---------------------------------------------------------------------
        > To unsubscribe, e-mail:
[EMAIL PROTECTED]
        > For additional commands, e-mail:
[EMAIL PROTECTED]
        
        
        
---------------------------------------------------------------------
        To unsubscribe, e-mail:
[EMAIL PROTECTED]
        For additional commands, e-mail:
[EMAIL PROTECTED]
        
        


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to