2 Replies Latest reply on Aug 8, 2013 9:08 PM by Tony Field

    reading asset and render into HTML


      I have a requirement where I need to use Asset APIs and read an asset and then render all the attributes for that asset onto an HTML

      I am new to WCS (sites) and not sure how should I go about it.

      Any pointers will be highly appreciated.



        • 1. Re: reading asset and render into HTML
          N Varma

          Check out page 837 - Asset API Read in webcenter_sites_11gR1_bp1_developer_guide.pdf.


          It describes how to use Asset API to read attributes step by step. I hope this helps.

          • 2. Re: reading asset and render into HTML
            Tony Field

            The Asset API is very powerful but with that full power comes a certain degree of verbosity.  You can write your own DAOs and facades over the Asset API.  Here's one:


            TemplateAssetAccess (Sites GST: Site Foundation 11.6.0 API)


            that works like this:


                    Query q = new SimpleQuery("Page", "PressRelease", null, null);


                    for(TemplateAsset asset : assetDao.query(q)) {

                        JSONObject response = new JSONObject();

                        Map<String,Object> pr = new HashMap<String, Object>();

                        pr.put("id", asset.asString("id"));

                        pr.put("title", asset.asString("prname"));

                        pr.put("description", asset.asString("metadescription"));




            It's great for taking an asset and actually working with it.  If you want to simply dump the asset onto the page scope so that you can work with it using expression language, use ScatteredAsset:


            ScatteredAssetAccessTemplate (Sites GST: Site Foundation 11.6.0 API)


            It works the same way, but you can take the ScatteredAsset object and dump it on the page context:


            pageContext.put("asset", myScatteredAsset)


            then access the fields like htis: