• Post Reply Bookmark Topic Watch Topic
  • New Topic

Access ManagedBean from Validator

 
Dominik Müller
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 18417
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!