Show TOC

Categorizing Modules in the Module GalleryLocate this document in the navigation structure

Use

To facilitate searching for modules in a custom implementation of the Module Gallery, you can organize module templates using the predefined set of Module Gallery categories. In addition to the default first-level categories supplied by enterprise workspaces, you can configure custom nested categories.

In a custom implementation of the Module Gallery, you can display the module templates according to nested categories. To retrieve these categories, use the APIs ( ModuleCategory, ContentDescriptor ) contained in the com.sap.workspaces.content package.

Prerequisites
  1. Module Gallery categories are configured.

    For more information, see Configuring Module Gallery Categories.

  2. Module Gallery categories are assigned to the module templates.

    For more information, see Configuring General Properties for a Module Template.

Procedure

The following example shows how to retrieve the list of all nested categories of a module template and package this list in XML format. This list can be used to display the module template under the relevant categories in the Module Gallery.

AbstractContentProvider workspaceContentProvider = getContentProvider(ContentProviders.WORKSPACE);

ContentDescriptor contentDescriptor = workspaceContentProvider.getContentDescriptor(moduleTemplateID, user, locale);

ModuleCategory[] moduleCategoryArray = contentDescriptor.getModuleCategories();

StringBuffer sb = new StringBuffer();

for (int i = 0; i < categories.length; i++) 
{		
ModuleCategory moduleCategory =(ModuleCategory) categories[i];
String name = moduleCategory.getName();
sb.append("<module_category name=\"").append(name);

ModuleCategory[] subCategories = moduleCategory.getSubcategories();

if ((subCategories != null) && (subCategories.length > 0)) 
{
		sb.append("\">");
		buildCategoriesXML(subCategories, sb);
		sb.append("</module_category>");
} else {
		sb.append("\"/>");
}
}