向 Websphere Portal 中的所有 portlet 添加额外的行为

Add additional behavior to all portlets in Websphere Portal

我需要向我的所有 portlet 添加一些行为。
它必须是一些 ajax 查询来检查某些条件,如果它是真的 - 显示消息。
起初我决定为我的应用程序添加一些 html 到我的门户皮肤。在此 html 中,我添加了 js 脚本以进行 ajax 查询。但是我不知道发送查询的上下文,因为我们使用 WSRP 来访问我们的 portlet。这就是为什么我无法获取 WSRP 上下文并进行查询的原因。
第二个想法是在所有 portlet 中添加公共 jsp,并在此 jsp 中创建逻辑(从 jsp 我可以获得上下文)。但是,如果我将更改所有 portlet jsp(使用标记 "include"),这并不好。
那么接下来我的问题是:

  1. 如何向所有 portlet 添加行为?
  2. 如何在JS中获取WSRP上下文?
  3. 如何在不更改 portlet jsp 的情况下将 jsp 添加到所有 portlet?

P.S。反正我不能碰门户网站的主题。

您应该能够使用 global portlet filter for this in WebSphere Portal. You create a WAR module with the filter class in it, and deploy it to the application server on which WPS is running. It must have a file called plugin.xml in WEB-INF which describes your global filter(s) via eclipse plug point mechanisms within Portal. Your class must implement any of the sub-types of javax.portlet.filter.PortletFilter 标准接口,这意味着您编写的代码是基于标准的。

如果您实施全局 portlet 过滤器,您必须了解它会被门户上调用的每个 portlet 调用 - 包括管理性的。为避免 运行 您不希望出现的预期逻辑,请检查每个请求的上下文路径。

来自 WPS 知识中心article

Because global portlet filters affect all portlets running in the given portlet container, the console modules that are contained in the Integrated Solutions Console are also filtered. It is important to test your filter implementation for undesired side effects on console modules or portlets. One approach is to test by checking the context path of the request in your filter logic.

我不知道 WSRP portlet 的上下文路径,但一些 SystemOut 日志记录应该可以帮助您确定这个值是什么并为您指明正确的方向。

最后,an article with sample code 在门户 wiki 上描述了该技术。