aspose file tools*
The moose likes JSF and the fly likes How to access the property file from Java code? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to access the property file from Java code?" Watch "How to access the property file from Java code?" New topic
Author

How to access the property file from Java code?

Fabricio Zelada
Greenhorn

Joined: Dec 28, 2011
Posts: 7

Hi,
Im using JSF+primefaces, and I have a property file regex.property that contain some string I wanna use from the Java code (server side). I know I can open the file and read it; but I also know that those files are already bundled (since they are declared in faces-config file). Does someone can tell me, how can access this resource? or how to find it?

Regards,

FABRICIO
Vladimir Mokrozub
Greenhorn

Joined: Aug 31, 2012
Posts: 12

Also, since ResourceBundle is part of standard JDK, you don't need to bundle your property file in faces-config.xml
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

If I'm not mistaken, when you define a resource bundle in faces-config, you assign a bean name to it.

While its most common use is as an anchor for JSF View resources such as messages and labels, I'm fairly certain that you could also inject this bean as a managed property into a JSF backing bean and do a standard resource lookup on it.

The main advantage of that approach is that since it's done via Inversion of Control, you don't have to hard-code the resource location in your backing bean.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to access the property file from Java code?
 
Similar Threads
How to use the Ant Property file setting?
Policy file question and readme question
Error Reading an xml file from a servlet
Hibernate connection close issue.
Property File Reload problem