WebCenter Sites Template Attribute Helper Code

WebCenter Sites provides powerful data modeling capabilities to define what information is available to be accessed within various site templates. To expedite template development it helps to highlight the attributes that are exposed for use within a template based on the assets are associated with the template. This is especially relevant when starting to work with more complex models where it is especially nice to have a quick on-screen reference for them.

The following code snippet can be added to a page to see the attributes of an asset of a collection of assets (if the snippet is added within a looping structure within a page).

Code Snippet by Itself

     // Get all of the available name value pairs
     Enumeration eParameters = ics.GetVars();

     // Transfer the above list into an array
     ArrayList arList = Collections.list(eParameters);

     // Itterate through the list and print out the various name value pairs
     for(String key : arList) {
     out.print(String.valueOf(key) + ": " + ics.GetVar(key) + "
"); } %>

Code Snippet in a Sample Loop


Make sure to import “java.util.*” into your page template if you have not already as follows

<%@ page import="java.util.*" %>

If your snippet is properly setup you will see the following returned in your browser

This highlights what items are currently available via the GetVar method of the ICS Object (Interface to Content Server). You can then use the corresponding name to get the value for use in your template.

<%= ics.GetVar("MyGreatAttributeName") %>

Over the following weeks I will be sharing more code snippets and tips around WebCenter Sites. Hopefully these tricks can help people to get up and running with their development quickly. Happy coding!

Leave a comment