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

上記は、通常、テンプレート コードを記述するときにFlex属性の値を取得するためのコードです。実際typenameには、フレックス属性タイプを指定するために使用されます。

ページ属性のコードは何ですか? 次に、Page 属性の値を取得するには、「typename」の値は何にする必要がありますか?

4

2 に答える 2

2

ページ属性 "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 を使用している場合は、この方法を使用することはお勧めしません。コントローラーを使用することをお勧めします。新しい考え方は、groovy コントローラーですべてのアセットを読み取り、JSTL を使用して JSP でアセットの値をレンダリングすることです。

groovy コントローラーのコードを次に示します。

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>

使いやすさをお楽しみください...

于 2016-09-02T13:45:20.790 に答える