tags:

views:

156

answers:

1

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 how 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?

+1  A: 

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.

McDowell