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

the above is normally the code to get value of Flex attribute when writing a template code. In fact typename is used for specifying Flex Attribute type.

What is the code for Page attribute? Secondly, what should the "typename" value be to get the value of Page attribute?

MikeT
  • 51,415
  • 16
  • 49
  • 68
qaquery
  • 31
  • 1
  • 5

2 Answers2

2

Here is an example of use to get a page attribute "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();
        }
%>

However I don't recommend you to use this method if you are using WCS 12g : it is better to use controllers. The new philosophy is to read all your asset in your groovy controller and then use JSTL to render the values of your asset in your JSP.

Here are some code for the 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)

And here is the code in your 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>

Enjoy the ease of use ...

Christophe
  • 2,131
  • 2
  • 21
  • 35
0
<assetset:getattributevalues name="sachin" attribute="Date_SV" listvarname="date_sv" typename="PageAttribute"

The typename should be "PageAttribute" without any spaces in between.

Nef10
  • 926
  • 2
  • 16
  • 26
qaquery
  • 31
  • 1
  • 5