Menu Component in WCM

Menu component fields
This section is used to set menu search parameters, set menu display settings and design the format of the menu.

Matching Content associated Site Areas Any content linked to the site areas you select will appear in the menu.
Include current Site Area If selected, any content linked to current site area will appear in the menu.
Include all Ancestors Any content linked to parent site areas (or parents of parents etcetera) of the site areas selected above will also be included in the search.
Include all Descendants Any content linked to child site areas (or children of children etcetera) of the site areas selected above will also be included in the search.
Matching Authoring Templates Any content based on the templates you select will appear in the menu.
Matching Content associated Categories Any content profiled with the categories you select will appear in the menu.
Note: Search Parameters
You can choose a combination of authoring templates, categories and site areas when profiling a menu.

Web Content Management menu searches are "or" searches, not "and" searches. This means that a menu that searches for two different categories and an authoring template will return content profiled with at least one of each profile type (one category and one template), not just content that matches all of the parameters. Content that matches only one profile type (template only) will not be returned.

Note: Taxonomies
Taxonomies cannot be used in Web Content Management menu searches. If you would like to have a menu return results based on content profiled with any category in a taxonomy, you should create a top-level category.

Matching Content Keywords Any content profiled with the keywords you enter will appear in the menu.
Matching Profile Search Rules Any content that matches the Search rule you select will appear in the menu. See the Search rules chapter for further information.
Results must match All Categories If selected, any results returned by a menu using categories as a search criteria must match all selected categories.
Include current document in results (if applicable) If this is selected, the currently displayed content will be listed in a menu if it matches the search criteria.
Ascending order for results Choose this option if you wish your menu items to be sorted in ascending order.
Results Primary Sort Key
Results Secondary Sort Key

Results Tertiary Sort Key
These fields determine what will be sorted using a combination of the following:
Name of content
Description of content.
Published Date
The date the content was first published. (Same date that is set in the workflow section of content items.)
Last Modified Date
Date the content was last modified.
Results per Page Defines how many links will appear in the menu.
Start Page If you have a menu with 5 elements per page, you can choose to start the menu at page two. This means that the second "page" of your menu (elements 6-10) will comprise the menu.
Debug Mode (Java console only) Sends Web Content Management information to the Web Content Management logs.
Header Design
Component Design for each matching Content

Footer Design

These Sections are used to enter text, tags and code to design the format of the rendered component.
The code entered in the header and footer designs will appear before and after the displayed menu results.

The code entered into the "Component Design for each matching Content" is used to format each menu result.

The code entered into the "Separator" will appear between each displayed menu result.

Here is the solution that works for me.

1. Get the system workspace using WorkspaceManager class
javax.jcr.Workspace jcrWsp = WorkspaceManager.getSystemWorkspace();

2. Login using the system credentials

3. Get the Localised Library

4. Get the Menu component with the obtained JCR Workspace, Localized library and menu name “menuName” using CoreQueries class
Controllable cble = CoreQueries.getByName(jcrWsp,locLib,mcompCont.getClass(), menuName);

5. Type cast the controllable obtained to the type menu component
mcompCont = (MenuCmpnt)cble;

6. Get the Array of Cmpnt containing “Menu Design Properties” section
Cmpnt[] compObjArr= mcompCont.getMicroTemplates();

7. Get the component of type ArrayCmpnt located at index “0” to retrieve the field “Design for each menu search result”
Cmpnt micComp1 = compObjArr[0];
ArrayCmpnt micArrayComp = (ArrayCmpnt)micComp1;

8. Iterate over ArrayCmpnt to retrieve each Object

9. Check for the pattern where last Object is of type you require to edit ex TextCmpnt.

10. You can modify the list condent by using remove, add operation. The object would be of type Cmpnt

11. Get reference to Menu Component Identity mcompIdnty

IdentityControl idntyCtrl =null;
for(Iterator ctrlIter=mcompCont.controlIterator();ctrlIter.hasNext();){
Control ctrl =(Control);
Identity mcompIdnty =(Identity)idntyCtrl;

12. Update the Repository using RepositoryService.update(jcrWsp,mcompIdnty,cble)

13. Save workspace using SaveWorkSpace.execute()

14. Unload the workspace using WorkSpaceManager