从 Faces 操作和组件访问 portlet API 对象

当创建 Faces portlet 时,就会在 /WEB-INF/faces-config.xml 中定义 portlet 变量解析器。Portlet 变量解析器使得能够将值绑定用于下列配置对象:
Portlet API 类型 配置对象 值绑定
JSR 168 API PortletPreferences #{portletPreferences.attribute name}
IBM® portlet API PortletApplicationSettings #{portletApplicationSettings.attribute name}
PortletSettings #{portletSettings.attribute name}
PortletData #{portletData.attribute name}

使用 portlet JSP 文件的“页数据”视图来定义属性并将它们绑定至 Faces 组件,如在从 JSP 文件访问 portlet API 对象中描述的那样。

PortletRequest、PortletResponse 和 PortletContext 可通过 facesContext 的 ExternalContext 方法获取,如下所示:
PortletRequest request = (PortletRequest)facesContext.getExternalContext().getRequest();
PortletResponse response = (PortletResponse)facesContext.getExternalContext().getResponse();
PortletContext context = (PortletContext)facesContext.getExternalContext().getContext();

如果想要访问 Faces 操作的 IBM portlet API 中的 ActionEvent 类(org.apache.jetspeed.portlet.event.ActionEvent),可通过请求属性获取它:

ActionEvent event = (ActionEvent)facesContext.getExternalContext().getRequestMap().get("com.ibm.faces.portlet.ACTION_EVENT");
相关概念
“页数据”视图
相关任务
从 JSP 文件访问 portlet API 对象

(C) Copyright IBM Corporation 2002, 2005. All Rights Reserved.