IBM Portal开发遇到两个问题, Portlet隐藏 和 动态Title处理。
Portlet隐藏: 显示一个portlet就会调用一次skin里面的control.jsp,所以想办法隐藏control.jsp的内容就可以了。可以用一个Div标签包掉整个control.jsp,需要隐藏时使用javascript隐藏整个div即可。
动态Title处理: 在Portal6.1 server中GenericPortlet.getTitle(RenderRequest request)虽然还是会被动态调用,页面title值却不更新,幸好可以通过 request.getAttribute(com.ibm.portal.portlet.Constants.DYNAMIC_TITLE)%>拿到title,同样通过js动态改变。具体请看下面代码。同时附上了Control.jsp。
Control.jsp
Portlet隐藏: 显示一个portlet就会调用一次skin里面的control.jsp,所以想办法隐藏control.jsp的内容就可以了。可以用一个Div标签包掉整个control.jsp,需要隐藏时使用javascript隐藏整个div即可。
动态Title处理: 在Portal6.1 server中GenericPortlet.getTitle(RenderRequest request)虽然还是会被动态调用,页面title值却不更新,幸好可以通过 request.getAttribute(com.ibm.portal.portlet.Constants.DYNAMIC_TITLE)%>拿到title,同样通过js动态改变。具体请看下面代码。同时附上了Control.jsp。
Control.jsp
<%@ page session="false" buffer="none" %>
<% /* @copyright jsp */ %>
<%@ taglib uri="http://www.ibm.com/xmlns/prod/websphere/portal/v6.0/portal-navigation" prefix="portal-navigation" %>
...
<div id="portlet.<portal-skin:portletID/>">
...
<span id="title.<portal-skin:portletID/>">
<portal-skin:portletTitle>
<portal-fmt:problem bundle="nls.problem"/>
</portal-skin:portletTitle>
...
<!-- portlet body -->
<portal-logic:if portletState="Normal,Maximized,Minimized,Solo">
...
<script type="text/javascript">
var dynaTitle = "<%=request.getAttribute(com.ibm.portal.portlet.
Constants.DYNAMIC_TITLE)%>";
var portletElem = document.getElementById("portlet.<portal-skin:portletID/>");
var titleElem = document.getElementById("title.<portal-skin:portletID/>");
if (portletElem && titleElem)
{
if (dynaTitle == "DPAHide")
{
portletElem.style.display = 'none';
}
else if (dynaTitle != "" && dynaTitle != "null")
{
titleElem.innerHTML = dynaTitle;
}
}
</script>
...
</portal-logic:if>
</div>