• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to access the property file from Java code?

 
Greenhorn
Posts: 7
Netscape Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic