下面是本人在使用WLP8.1内容管理模块过程中的一些经验总结. 与CMS有关的JSP TAG主要有: CMS API 可通过:http://edocs.beasys.com/wlp/docs81/javadoc/overview-summary.html 查到。 在采用WLP的CMS来管理站点的内容时,经常要处理包含图片的HTML文件,因为HTML中的图片一般都是超连接方法,不同于WORD等文件是直接包含。为了使HTML文件以加载到WLP的CMS Repository中,仍然可以正确显示。可采用以下两种方法。 显示内容的方法一般有以下两种: 直接显示:直接把内容所对应的文件的内容显示出来 下面分别说明相应的方法: 直接显示HTML等内容 可采用下面的代码,在SP3中正常,在SP4中THROW EXCEPTION:Error getting bytes from property: file caused by: : java.lang.NullPointerException 注意:在SP3中,如果该NODE PATH 中包含汉字,没有LOGIN,显示不出来,LOGIN之后可以正确显示。不知道为怎么,所以如果要这样显示图片,最好NODE PATH不要有中文。
间接显示内容 一般通过超连接方式: 可以给不同的部门或分公司建不同的目录,然后通过WLP的委派授权功能,使不同的部门或分公司只能对自己部门或分公司的目录进行内容的增加,删除,修改等管理工作 通常做法
<pz:contentSelector>
<es:forEachInArray>
<cm:getProperty>
<cm:getNode>
<cm:search>
HTML中图片的处理方法
<table cellSpacing="0" cellPadding="10" border="0">
<tbody>
<tr>
<td><a href="http://www.bea.com"><img src="/essWeb/images/logo_bea.gif" border="0" width="95" height="57"></a></td>
</tr>
<tr>
<td><a href="http://www.flyinglogo.com"><img src="/essWeb/images/logo_fls.gif" border="0" width="95" height="83"></a></td>
</tr>
</tbody>
</table>
在Portlet 中显示CMS Repository中内容
间接显示:通过点击内容的标题等,以超连接的方式内容所对应的文件的内容显示出来 <body>
<pz:contentSelector rule="my" id="nodes"/>
<% if ( nodes == null || nodes.length == 0 )
{
%>
No content found
<%
}
else
{
%>
<utility:forEachInArray array="<%=nodes%>" id="node" type="com.bea.content.Node">
<cm:getProperty id="node" name="file" failOnError="true" />
</utility:forEachInArray>
<%
}
%>
</body>
直接显示图片的内容
<body>
<pz:contentSelector rule="Untitled" id="nodes"/>
<% if ( nodes == null || nodes.length == 0 )
{
%> No content found
<%
}
else
{
%>
<utility:forEachInArray array="<%=nodes%>" id="node" type="com.bea.content.Node">
<%
String simg = "<img src= ' " + "/sampleportal/ShowBinary" + node.getPath() + "'>";
out.println(simg);
%>
</utility:forEachInArray>
<%
}
%>
</body>
一般通过超连接方式:
<netui:html>
<body>
<pz:contentSelector rule="my" id="nodes"/>
<% if ( nodes == null || nodes.length == 0 )
{
%> No content found
<%
}
else
{
String myurl = "http://" + request.getServerName() + ":" + request.getServerPort()+ request.getContextPath();
System.out.println("myurl="+myurl);
%>
<utility:forEachInArray array="<%=nodes%>" id="node" type="com.bea.content.Node">
<a href="<%=myurl%>/ShowBinary<%=node.getPath()%>" ><cm:getProperty name="title" node="<%=node%>" /></a>
</utility:forEachInArray>
<%
}
%>
</body>
</netui:html>
对内容管理进行委派授权
作者简介
dev2dev ID: xcjing,BEA 资深技术顾问,加入BEA中国多年,在门户技术、RFID解决方案上有着丰富的经验。