webcenter - 在 Webcenter Sites 中如何使用模板代码检索页面属性的值

标签 webcenter webcenter-sites

<assetset:getattributevalues name="sachin" attribute="Date_SV" listvarname="date_sv" typename="Content_Att" />

上面通常是编写模板代码时获取Flex属性值的代码。事实上typename用于指定Flex属性类型。

Page 属性的代码是什么?其次,“typename”值应该是多少才能获取Page属性的值?

最佳答案

以下是使用获取页面属性“article”的示例:

<%
        Session ses = SessionFactory.getSession();
        AssetDataManager mgr =(AssetDataManager) ses.getManager( AssetDataManager.class.getName() );
        AssetId id = new AssetIdImpl( "Page",new Long(ics.GetVar("cid")));
        List attrNames = new ArrayList();
        attrNames.add( "articles" );
        AssetData data = mgr.readAttributes( id, attrNames );
        AttributeData articlesData = data.getAttributeData( "articles" );
        List<AssetId> relatedArticles = null ;
        if (articlesData != null) {
            relatedArticles=(List<AssetId>) articlesData.getData();
        }
%>

但是,如果您使用 WCS 12g,我不建议您使用此方法:最好使用 Controller 。新的理念是读取 groovy Controller 中的所有 Assets ,然后使用 JSTL 在 JSP 中呈现 Assets 的值。

以下是 groovy Controller 的一些代码:

public Map readAsset(String type, String name) {
    Map assetMap = newAssetReader()
    .forAssetName(type, name)
    .selectAll(true)
    .selectImmediateOnlyParents(true)
    .includeLinks(true)
    .includeLinksForBlobs(true)
    .read();
}
Map myPage = readAsset("Page","Home")
models.put("homePage",myPage)

这是 JSP 中的代码:

<%@ taglib prefix="cs" uri="futuretense_cs/ftcs1_0.tld"%>
<%@ taglib prefix="ics" uri="futuretense_cs/ics.tld"%>
<%@ taglib prefix="fragment" uri="futuretense_cs/fragment.tld"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<cs:ftcs>
     Here is the full page asset : ${homePage} <br/>
     Here is just the page name : ${homePage.name} <br/>
</cs:ftcs>

享受易用性...

关于webcenter - 在 Webcenter Sites 中如何使用模板代码检索页面属性的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39235759/

相关文章:

java - Oracle Webcenter 内容中的管理 java 小程序 WCC 无法打开

content-management-system - Oracle UCM - ridc - 获取文档的所有版本

javascript - WebCenter 站点样式表

java - EDIT_SCHEMA_VIEW_VALUES RIDC 网络中心内容

html - 单击一个框架中的链接并在另一个框架中显示 JSP

java - 示例应用程序 "Articles"无法在带有 Tomcat 的 Oracle WebCenter Sites Jump Start Kit 上启动

java - 如何使用 Oracle Web Center 站点 11g 创建示例 "helloworld site"?

java - 如何识别和写入具有 .xls 扩展名且内容为 .xlsx 的 Excel 文件