开发者

Accessing FacesContext in Util jar from multiple portlets

We have several JSF portlets running in a websphere portal environment. A developer wants to create a Utility jar which would live in the shared library, so all portlets could access it. In this jar he wants a faces utility class which would have a static method; this method would access the current FacesContext instance and return that context's session map.

We have been having some discussion over whether this is a wise approach, and 开发者_如何学Chow we know for sure that the correct context instance will be returned to each portlet instance. Any experience doing this, for better or for worse?


FacesContext.getCurrentInstance() encapsulates the artefacts associated with a request. The context is thread-local - it is set up at the start of a request and disposed at the end by the portlet acting as the controller. So, so long as you can guarantee that the code is invoked as part of the request, it should be OK; problems will occur if the invocation escapes the request thread.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜