<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/