Friday, April 15, 2011

Getting WCM data from IBM's seedlist application.

Using Seedlist 1.0 server, we can retrieve WCM data, the following is IBM's document on how to retrieve WCM data using seedlist REST API

Seedlist REST API

If you are using Dojo to call the API you probably will use xhrGet method, and you can handle the result as XML data (setting handleAs: "xml").

The question is how to retrieve the value of a field.

First of all, we need to get the values from each WCM document. This  can be done by:

data.documentElement.children["<number>"].nodeName.   If the nodeName is "atom:entry" then the children is a  document item. Here is the sample  data.documentElement.children["9"].nodeName

Once we already have the document information, we need to get the specific property from the content item, here is how
console.log("data.documentElement.children["<number>"].children["<number>"].nodeName. The value of nodeName should be "wplc:field". This will indicate that the object is a property of the document.

To know the name of the property you need to use the following statement
data.documentElement.children["<number>"].children["<number>"].attributes[0].nodeValue.  The value of nodeValue is the name of the property

Lastly you need to get the real value of the property by

data.documentElement.children["<number>"].children["<number>"].textContent.  The statement will result on the value of the specific property.

Sample (to get "Name" property of a specific content):

If the value of data.documentElement.children["9"].children["17"].nodeName == "wplc:field" then
   if the value of data.documentElement.children["9"].children["17"].attributes[0].nodeValue == "Name" then
        The value of "Name" is data.documentElement.children["9"].children["17"].textContent

If the statement above is not true then we need to loop through to another array element.

This is based on my test on WebSphere Portal 7.





No comments:

Post a Comment