This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Other Application Frameworks and the fly likes Seam: Injection doesn't work in custom validator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Seam: Injection doesn Watch "Seam: Injection doesn New topic
Author

Seam: Injection doesn't work in custom validator

Dan Duarte
Greenhorn

Joined: Dec 02, 2010
Posts: 2
Hi guys,
I'm new seam development and i'm having littles problems with my app.
I've created a object that encapsulate the message bundle. so I try to inject this object in my custom validator, but at runtime i receive a null value.



anyone could help me?
Andrea Moehrke
Greenhorn

Joined: Dec 09, 2010
Posts: 2
Hi,

try to get the ResourceBundle on this way:

Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
ResourceBundle messages = ResourceBundle.getBundle( "messages", locale, Thread.currentThread().getContextClassLoader());

Dan Duarte
Greenhorn

Joined: Dec 02, 2010
Posts: 2
Andrea Moehrke wrote:Hi,

try to get the ResourceBundle on this way:

Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
ResourceBundle messages = ResourceBundle.getBundle( "messages", locale, Thread.currentThread().getContextClassLoader());



I just instantiate a new object in the validator
Messages mensagens = new Messages();
so, it works.

Another problem that I realize is, if I put the code above in the validator, a exception occur

code


exception
 
 
subject: Seam: Injection doesn't work in custom validator