0

Possible Duplicate:
FacesContext == null

I have an abstract class AbsClass in a API and Bean ViewBean. AbsClass abstract class is implemented with a name AbsClassImpl and abstract methods are declared. For arthiecturel aim, AbsClass is used in ViewBeans. But how I can reach ViewBean from AbsClassImpl. it is required because if some changed occured in API say raise an event, it has to notify ViewBean and then user on interface via AbsClassImpl->eventHandler() method.

FacesContext.getCurrentInstance() returns null since I think AbsClassImpl class is not in Context or somewhere else.

Could you give me an advice how to handle this situation? I am using JSF 2.0

Community
  • 1
  • 1
Ahmet Karakaya
  • 9,899
  • 23
  • 86
  • 141
  • The `FacesContext` is a thread-local request-scoped artifact created and released by the JSF container for each request. Trying to access it under non-JSF servlets or other threads is not a supported scenario. – McDowell Dec 22 '12 at 11:25
  • I agree with the description of the route cause of the problem. So how I can access the data of ViewBean from absClassImpl? – Ahmet Karakaya Dec 22 '12 at 11:47
  • 2
    What scope is ViewBean defined in? What context is AbsClassImpl's metod invoked? Servlet? Web service? EJB? Some timer API? I suspect your design may be flawed. The name implies the bean is scoped to a view; trying to access it outside that view - nothing good will come of it. – McDowell Dec 22 '12 at 12:07

0 Answers0