What is FacesContext used for?

前端 未结 4 965
甜味超标
甜味超标 2021-02-03 20:41

What is FacesContext used for?

And where exactly is it implemented?

4条回答
  •  别那么骄傲
    2021-02-03 21:15

    The Facescontext is the anchor point for connecting to framework-and container- specific services. For example, you can obtain the underlying httprequest and context objects for the page request that's accessing your backing bean by going through the Facescontext. That includes the security context a web page request is running under.

    The general philosophy behind JSF is that the user-provided components should be abstract enough not to depend on such details as to whether they're running in a traditional JSP environment or something more exotic, so if there's a Facescontext reference in the bean, it's a potential sign of bad design, especially since beans are expected to have things injected into them, not go out looking for stuff.

    However, sometimes for one reason or another, it's convenient to reach out of the backing bean and obtain the outlying information, so it's there if you need it.

    Reference: What is the use of Facescontext Context Object

提交回复
热议问题