loading ...
loading...

2007-04-10 | 直接用OpenCms的API而不是标签来得到资源信息

分享
标签: OpenCms  API  标签 
我们可以直接用OpenCms的API,而不是用标签来得到OpenCms中一个Resource的所有信息.
相关代码如下:
Code:
<%@ page session= " false " buffer= " none " isELIgnored= " true "

import= " java.util.*,
org.opencms.frontend.templateone.* " %>
<%@ page import= " org.opencms.jsp.CmsJspXmlContentBean " %>
<%@ page import= " org.opencms.jsp. I_CmsXmlContentContainer " %>
<%@ page import= " java.util. List " %>
<%@ page import= " org.opencms.xml. I_CmsXmlDocument " %>
<%@ page import= " org.opencms.file.CmsResource " %>
<%@ page import= " org.opencms.file.CmsFile " %>
<%@ page import= " org.opencms.file.CmsObject " %>
<%@ page import= " org.opencms.file.CmsProperty " %>
<%@ page import= " org.opencms.xml.content.CmsXmlContentFactory " %>
<%@ page import= " org.opencms.xml.content.CmsXmlContent " %>
<%
CmsJspXmlContentBean cjxc =
new CmsJspXmlContentBean (pageContext, request, response);
CmsObject obj_cms = cjxc.getCmsObject ();
String pageName = cjxc.info (“opencms.request.uri”);
I_CmsXmlContentContainer icms=
cjxc.contentload (“singleFile”, pageName, false);
Iterator it = icms.getCollectorResult () .iterator ();
while (it.hasNext ()) {
CmsResource resource = (CmsResource) it.next ();
CmsXmlContent content =
CmsXmlContentFactory.unmarshal (obj_cms, resource, request);
Locale loc = null;
List locales=content.getLocales ();
Itlocal=locales.iterator Iterator ();
while (itlocal.hasNext ()){
loc= (Locale) itlocal.next ();
}
out.println (“</p><p> RECUPERARNDO ELEMENTS </p>”);
List listaElementos=content.getNames (loc);
itrelementos=listaElementos.iterator Iterator ();
while (itrelementos.hasNext ()){
String nome = (String) itrelementos.next ();
String value = content.getValue (nome, loc) .toString ();
out.println (“<p> nome do element: “+nome+
“value: “+valor+ " </p>”);
}
out.println (“</p><p> RECOVERING PROPERTIES </p></p>”);
List propiedades=obj_cms.readPropertyObjects (resource, false);
int count = propiedades.size ();
for (int i=0; i<count; i++) {
CmsProperty currProperty = (CmsProperty) propiedades.get (i);
String propertyName = currProperty.getName ();
String propertyValue = currProperty.getValue ();
out.println (“Propiedade: “+propertyName+” value: “+
propertyValue+ " <p></p> ");
}
}
%>
分享 分享 |  评论 (0) |  阅读 (?)  |  固定链接 |  类别 (工作笔记) |  发表于 03:13
搜狐博客温馨提示:警惕博客留言诈骗, 搜狐博客管理员的正确地址为http://admin.blog.sohu.com, 其他都是冒牌。搜狐博客官方不会要求参加活动的各位博友缴纳任何的手续费用。请勿轻信留言、评论中的中奖信息,更不要拨打陌生电话及向陌生帐户汇款,谨防受骗!识别更多网络骗术,请 点击查看详情
您还未登录,只能匿名发表评论。或者您可以 登录 后发表。
 
  与您共话财富健康,让您的财富增值更多!
表  情:
加载中...
回复通知: 同时用小纸条通知对方该回复