This content has been marked as final.
Show 5 replies
-
1. Re: Read Properties File
asookazian Aug 6, 2009 6:47 AM (in response to karboe)use this, it works:
import java.util.Enumeration; import java.util.Properties; import java.util.PropertyResourceBundle; import java.util.ResourceBundle; public class CoxProperties { private static Properties ijwatProps = null; public static Properties getPropertyObject(String configFileName) { if (ijwatProps == null) { ijwatProps = new Properties(); Enumeration<String> enumKeys; ResourceBundle bundle = PropertyResourceBundle .getBundle(configFileName); enumKeys = bundle.getKeys(); while (enumKeys.hasMoreElements()) { String key = (String) enumKeys.nextElement(); ijwatProps.setProperty(key, (String) bundle.getString(key)); } } return ijwatProps; } public static Properties getPropertyObject() { return getPropertyObject(CoxConstants.CONFIG_FILENAME); } public static String getProperty(String key) { if (key == null) return null; return ijwatProps.getProperty(key); } }
-
2. Re: Read Properties File
cash1981 Aug 6, 2009 9:56 AM (in response to karboe)Or much easier, you can define your properties in components*.properties.
myproperty=someValue
Then in your components.xml you can define then in the seam component you are using them.
<component name="mySeamcomponent"> <property name="myproperty">@myproperty@</property> </component>
Then in your mySeamcomponent class
// injected from components.xml private String myproperty; public getMyproperty(); public setMypropert(String ...);
-
3. Re: Read Properties File
jjlang Aug 6, 2009 10:18 AM (in response to karboe)define your properties in components*.properties, if you use them in your page you can use like this " value="#{messages['key']}" " -
4. Re: Read Properties File
sburgula1 Mar 5, 2010 4:18 PM (in response to karboe)Hi
Can you let me know which method you are exposing to the bean, Mr. Arbi Sookazian. That is if I have to instantiate CoxProperties and call the method on it, which method would I be calling.
thanks
Sai -
5. Re: Read Properties File
cash1981 Nov 9, 2010 9:27 AM (in response to karboe)
andrew lee wrote on Aug 06, 2009 10:18:
define your properties in components.properties, if you use them in your page you can use like thisThis is just plain wrong. You cannot use Messages to read the component.properties file. It will read the messages.properties file.