0

Is it a good idea to use FacesContext object with its methods in the application controllers? I mean, in opinion the FacesContext helps us mostly to manage the components and elements from GUI so I think it is not a very good idea to use it to much in the application controllers. So, I use the FacesContext methods to get the necessary information in the Beans and after that a just send the data to the controllers.

Is my approach right?

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
John R.
  • 420
  • 4
  • 14
  • 1
    It depends on what you mean when saying `controller`. ([see this QA](https://stackoverflow.com/questions/5104094/what-components-are-mvc-in-jsf-mvc-framework)) Your question is quite vague so far. Generally FacesContext is usable in CDI managed beans of JSF applications or @ManagedBeans in older JSF applications. Additionally it's used in JSF Converters, Validators, Components, Listeners etc. – Selaron Mar 09 '20 at 07:33
  • From the duplicate: *"Note that the service layer should by itself not have any JSF dependencies. So any (in)direct imports of `javax.faces.*` in the service layer code indicates bad design."* – BalusC Mar 09 '20 at 11:05

0 Answers0