wcf:getData tag demystified

Commerce BOD interface is a powerful tool if you know how to use it.

Using wcf:getData tag is an easy way to exploit the power of BOD.

Madisons uses it on category and product pages. On the product page,  <WCDE_Home>\workspace\Stores\WebContent\Madisons\Snippets\Catalog\CatalogEntryDisplay\CachedProductOnlyDisplay.jsp

For example

<wcf:getData type="com.ibm.commerce.catalog.facade.datatypes.CatalogEntryType[]" var="catalogEntriesForAttributes" 
expressionBuilder="getCatalogEntryByParentCatalogEntryId" varShowVerb="showVerb">
<wcf:contextData name="storeId" data="${param.storeId}"/>
<wcf:param name="catEntryId" value="${product.productID}"/>
<wcf:param name="dataLanguageIds" value="${WCParam.langId}"/>
<wcf:param name="accessProfile" value="IBM_Store_CatalogEntryAttributes"/>

we are using it to get the attribute’s list for a product.

But wcf:getdata tag can do a lot more.

Suppose I want to put in a variable in my JSP all the products that are beyond a specific category using wcf:getdata.

First of all I have to look for in WC Infocenter if IBM already implemented this query for me.

The table on Noun CatalogEntry help us to find the values I have to put on wcf:getdata attributes to get such a resultset.

In the table I find what I was looking for: “Get child catalog entries of a catalog group”.

I write down the fields I need:

  • Expression Builder = getCatalogEntryByParentCatalogGroupId
  • Corrispondent XPath = /CatalogEntry[ParentCatalogGroupIdentifier[(UniqueID=$uniqueId$)]]
  • Access profile = “All access profiles listed in the ‘Access Profile’ section can be applied to this expression”

As access profile I choose “IBM_Admin_Summary” (at the bottom of the table).

To know which are the contextData, I check the xml Request example


Now compose the corrispondent wcf:getdata tag is very easy.

I found the Expression Builder on the table (“getCatalogEntryByParentCatalogGroupId”), the contextData on the xml request example (storeId and catalogId), the parameter on the XPath expression (the catalog group id) and the access profile I choosed (“IBM_Admin_Summary”)

<wcf:getData type="com.ibm.commerce.catalog.facade.datatypes.CatalogEntryType[]" var="catalogEntriesInCategory" 
expressionBuilder="getCatalogEntryByParentCatalogGroupId" varShowVerb="showVerb">
	<wcf:contextData name="storeId" data="${param.storeId}"/>
	<wcf:contextData name="catalogId" data="${param.catalogId}"/>
	<wcf:param name="catGroupId" value="${WCParam.categoryId}"/>
	<wcf:param name="accessProfile" value="IBM_Admin_Summary"/>

Before putting this tag in a JSP, I can test what is returning using the Query Template File Syntax Validator included on WCDE

If you use “10004” as category group id (“Lounge Chairs” on Madisons) and submit the query

you’ll see the 4 products included on “Lounge Chairs” category and the queries executed by BOD under the covers.

Unfortunately the default dsl.jsp is only an example and it needs a little customization to add the catalogId parameter.

You can find the working version on my Box.net space. Enjoy.

Websphere Commerce and Portal Architect ✔ Motivated IT professional with more than ten years of experience, combining Java and JEE developer skills with systems and IBM products installation knowledge. ✔ Strong experience and skills on planning, architecting and implementing complex commerce and portal solutions based on IBM middleware products. ✔ Reliable with a strong network attitude, experience on leading developer's teams and manage international relationships. Specialties ✔ Pleasant manner, reliable. ✔ Ability to consider issues from different point of views. ✔ End-oriented work capacity and problem-solving attitude. ✔ Ability to work with deadlines and under pressure. ✔ Ability to prioritise tasks and manage people. ✔ Ability to increase the whole team skills. ✔ Ability to generate commercial leads

Posted in websphere commerce
7 comments on “wcf:getData tag demystified
  1. Jon Mitchell says:

    This seems about straight forward as coding with IBM can be. I’m trying to get an attribute based on the identifier field. Here is what I am trying but it does not return anything. Can you point me in the right direction, please?


    Also if I try the OOTB dsl.jsp or yours no matter what I enter I always get NullPointerException.

  2. Jon Mitchell says:

    Bummer, it doesn’t look like it took my code snippets. How do I post code?

  3. George Koprinkov says:

    Hi Jon,
    I had the same problem with dsl.jsp throwing NullPointer.

    You need to set the componentid on SelectionCriteria.

    Search Expression:
    List sqlProcessors = QueryTemplateValidationHelper.getSQLProcessors(sc, componentId);

  4. Francesco says:

    Hi Marco.
    Can I test member component subsystem with this jsp? I don’t find the component in the select options
    Thank you in advance.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: