WebSphere Portal 6平台porlet skin中获取portletID和porletTitle的方法
来源:互联网 发布:嵌入式系统编程 编辑:程序博客网 时间:2024/06/06 14:10
在portlet skin的Control.jsp中:
通过如下方式可获得portletID和portletTitle并输出到HTML中:
导入以下taglib
<%@ taglib uri = "http://www.ibm.com/xmlns/prod/websphere/portal/v6.0/portal-skin" prefix="portal-skin" %>
//获取portletID
<portal-skin:portletID />
//获取当前语言区域的portletTitle
<portal-skin:portletTitle>
<portal-fmt:problem bundle="nls.problem" />
</portal-skin:portletTitle>
通过如下方式可获得portletID和portletTitle并将他们赋值给某个Java变量:
//获取portletID并赋值
<portal-skin:portletID var="myPortletID"/>
<jsp:useBean id="myPortletID" class="java.lang.String" scope="page"/>
<%
//赋值后便可以使用了
String s = myPortletID;
%>
//获取默认语言区域(EN)的portletTitle并赋值
<portal-skin:portletTitle id="myPortletTitle"/>
次标签将编译成:
String myPortletTitle = doSomeThingAndGetCurrentPortletTitle();
通过如下方法可以编程获得porletTitle:
<%!
private static com.ibm.portal.identification.Identification identification;
public void jspInit(){
try{
/* only perform this JNDI lookup once as this is an expensive call performance wise */
javax.naming.Context ctx=new javax.naming.InitialContext();
identification=(com.ibm.portal.identification.Identification) ctx.lookup("portal:service/Identification");
} catch (javax.naming.NamingException ne){
ne.printStackTrace();
}
}
%>
<%
//Fetch currentLayoutNode
String currentLayoutNodeStr = "";
LayoutNode currLayoutNode = null;
if (pageContext.getAttribute("currentLayoutNode", pageContext.REQUEST_SCOPE) != null) {
currLayoutNode=(LayoutNode)pageContext.getAttribute("currentLayoutNode", pageContext.REQUEST_SCOPE);
currentLayoutNodeStr=identification.serialize(currLayoutNode.getObjectID());
} else {
currLayoutNode=(LayoutNode)pageContext.getRequest().getAttribute("com.ibm.wps.composition.element");
currentLayoutNodeStr=identification.serialize(currLayoutNode.getObjectID());
}
// Fetch Portlet Title
String currentNodeTitle = "";
com.ibm.portal.content.LayoutControl lControl =
(com.ibm.portal.content.LayoutControl) currLayoutNode;
com.ibm.portal.ObjectID portletDefOID = null;
try {
javax.naming.Context ctx2 = new javax.naming.InitialContext();
com.ibm.portal.model.LocalizedStringResolver localizedStringResolver =
(com.ibm.portal.model.LocalizedStringResolver) ctx2.lookup("portal:service/model/LocalizedStringResolver");
currentNodeTitle = localizedStringResolver.getTitle(lControl, request.getLocales());
} catch (javax.naming.NamingException ne){}
%>
private static com.ibm.portal.identification.Identification identification;
public void jspInit(){
try{
/* only perform this JNDI lookup once as this is an expensive call performance wise */
javax.naming.Context ctx=new javax.naming.InitialContext();
identification=(com.ibm.portal.identification.Identification) ctx.lookup("portal:service/Identification");
} catch (javax.naming.NamingException ne){
ne.printStackTrace();
}
}
%>
<%
//Fetch currentLayoutNode
String currentLayoutNodeStr = "";
LayoutNode currLayoutNode = null;
if (pageContext.getAttribute("currentLayoutNode", pageContext.REQUEST_SCOPE) != null) {
currLayoutNode=(LayoutNode)pageContext.getAttribute("currentLayoutNode", pageContext.REQUEST_SCOPE);
currentLayoutNodeStr=identification.serialize(currLayoutNode.getObjectID());
} else {
currLayoutNode=(LayoutNode)pageContext.getRequest().getAttribute("com.ibm.wps.composition.element");
currentLayoutNodeStr=identification.serialize(currLayoutNode.getObjectID());
}
// Fetch Portlet Title
String currentNodeTitle = "";
com.ibm.portal.content.LayoutControl lControl =
(com.ibm.portal.content.LayoutControl) currLayoutNode;
com.ibm.portal.ObjectID portletDefOID = null;
try {
javax.naming.Context ctx2 = new javax.naming.InitialContext();
com.ibm.portal.model.LocalizedStringResolver localizedStringResolver =
(com.ibm.portal.model.LocalizedStringResolver) ctx2.lookup("portal:service/model/LocalizedStringResolver");
currentNodeTitle = localizedStringResolver.getTitle(lControl, request.getLocales());
} catch (javax.naming.NamingException ne){}
%>
- WebSphere Portal 6平台porlet skin中获取portletID和porletTitle的方法
- Portal & Porlet
- 研究:Liferay研究(六)Liferay中如何获取相应的portlet实例Id和portletId
- websphere portal菜单结构的获取
- WebSphere和Portal的部署方案的选择
- WebSphere Portal中多层Placebar主题的开发(一)
- WebSphere Portal中多层Placebar主题的开发(二)
- 在WebSphere Portal Server中使用Hibernate的一点心得
- Websphere portal和Domino配置 Web SSO后的测试
- websphere portal 的几个版本
- WebSphere Portal V6.1 获取登录用户信息
- 整合 WebSphere Portal 和 WebSphere Personalization─ 第 1 部分︰建置個性化的 portlet
- 整合 WebSphere Portal 和 WebSphere Personalization─ 第 1 部分︰建置個性化的 portlet
- Websphere Everyplace Mobile Portal - 支持各种移动设备的门户平台
- websphere portal
- Strust2 Action设置的session如何在porlet获取
- Portal新特性实战 - 使用 Ajax 和 WebSphere Portal
- porlet 的相关概念
- 启动控制面板命令大全
- struts和hibernate和spring的优缺点
- 局域网网上邻居无法访问问题的解决
- [J2ME] 根据行宽和字体大小给指定字符串分行
- VC 操作 XML 类
- WebSphere Portal 6平台porlet skin中获取portletID和porletTitle的方法
- Windows XP 开始菜单的策略设置
- 经典正则表达式 (作者:阿赖)
- DOTNET技术文章收藏
- IP域名详解
- 什么是MXF?
- 诚招网站制作和作者
- 内联接外联接全联接join的用法
- 到不了的都叫做远方,回不去的地方是故乡.