File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to access the property file from Java code?

 
Fabricio Zelada
Greenhorn
Posts: 7
Java Netscape Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 17621
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic