从多个Portlet访问Util jar中的FacesContext [英] Accessing FacesContext in Util jar from multiple portlets

查看:79
本文介绍了从多个Portlet访问Util jar中的FacesContext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有几个在Websphere门户环境中运行的JSF Portlet.开发人员想要创建一个可以保存在共享库中的实用程序jar,以便所有portlet都可以访问它.在这个罐子里,他想要一个可以使用静态方法的faces实用程序类.此方法将访问当前的FacesContext实例并返回该上下文的会话映射.

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.

我们一直在讨论这是否是一种明智的方法,以及如何确定如何将正确的上下文实例返回给每个Portlet实例.有这样做的经验,是好是坏?

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?

推荐答案

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.

这篇关于从多个Portlet访问Util jar中的FacesContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆