Get Content Item using Query Componen from VCM

AJSP渲染器使用详解
本文介绍了AJSP渲染器如何通过RequestContext获取被渲染的Managed Object,并展示了如何处理返回的对象来生成所需的输出内容。此外,还提供了一个示例,演示了如何遍历并显示由查询组件返回的Managed Object列表。

A JSP renderer uses RequestContext.getRenderedManagedObject() to access the content instance or content component being rendered. The JSP renderer can then process the returned object to produce any desired rendered output:

<%

RequestContext rc = PageUtil.getCurrentRequestContext(pageContext);

ManagedObject mo = rc.getRenderedManagedObject();

%>

The preceding gets a managed object and its request context. You can then manipulate the results however you like. A simple example (which iterates through and displays a list of managed objects returned by a query component) follows:

<%

RequestContext rc = PageUtil.getCurrentRequestContext(pageContext);

QueryContentComponent qc = (QueryContentComponent)

rc.getRenderedManagedObject();

List results = qc.getResults(rc);

Iterator it = results.iterator();

while (it.hasNext()) {

ManagedObject result = (ManagedObject) it.next();

out.println("This result is " + result.getName() + "<br>");

}

%>

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值