*
The moose likes Java in General and the fly likes Arguments to Properties File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Arguments to Properties File " Watch "Arguments to Properties File " New topic
Author

Arguments to Properties File

Karthik Rajendiran
Ranch Hand

Joined: Aug 13, 2004
Posts: 211
Hello Friends,

I have one requirement with resources or properties file

I have one properties file, with key value pairs like this

error.productid.activation=your {0} is not yet activated.
error.productid.campaignid.disable=your {0} and {1} is not enabled.


I have to pass values dynamically to this key while fetching value. How to pass and how to do this in java program.


SCJP 1.4 SCWCD 1.4 SCDJWS 1.4
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3739
    
  16
I think you need the MessageFormat class


Joanne
Karthik Rajendiran
Ranch Hand

Joined: Aug 13, 2004
Posts: 211
Thanks sir,

One clarification,
I have 3 files like
messagetemplate.properties
messagetempalte_en_GB.properties
messagetemplate_en_ie.properties

Can we make the messageformat to pick the correct file itself. or should i have to pick the file and get the key and send to messageformat?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

Check out ResourceBundle.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Pratap koritala
Ranch Hand

Joined: Sep 27, 2006
Posts: 252



for web applications you can try much simpler format tag


[ July 28, 2008: Message edited by: Pratap koritala ]
Karthik Rajendiran
Ranch Hand

Joined: Aug 13, 2004
Posts: 211
Thanks for the reply. Really Helpful
Ragupathirajan Venkatesan
Ranch Hand

Joined: Aug 18, 2010
Posts: 62
Hi ,

Please advice how to pass the values dynamically to key attribute in the <fmt:message key='">. Thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Arguments to Properties File