This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSF and the fly likes Access ManagedBean from Validator Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Access ManagedBean from Validator" Watch "Access ManagedBean from Validator" New topic
Author

Access ManagedBean from Validator

Dominik Müller
Ranch Hand

Joined: Apr 28, 2009
Posts: 36
Hi Together,

in some Tutorials is explained how to access a attributes of managedbean in source code:



My Problem is, that eclipse throw an Error when trying to insert it into an Validator-Class



Some Ideas?

thanks a lot
Dom
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14487
    
    7

Yes. That's doing it the hard way. You'd do that if you needed access to stuff at the EL level.

The easier way is to take advantage of the fact that managed beans are scoped POJOs and access them as session or request attributes. You still need the FacesContext, but instead of looking for the EL Resolved, dig into the FaceContext's J2EE objects.

I normally provide a set of utility classes for that kind of work so I can keep the actual FacesContext references out of my backing beans, It insulates me from possible future changes and makes the backing beans more portable.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Access ManagedBean from Validator
 
Similar Threads
Re-Render Problem after ValidationException
EJBs in helper classes - can't figure out how to do it
JSF annotations on interface or abstract class
@ManagedBean Annotation JSF2
JSF Managed Bean Injection