About Settings for Dynamic ColumnsThe JPO is configured with the tree, or a menu or command in the tree, using the Dynamic Command Program and Dynamic Command Function settings. These settings can only be used on a "static" menu or command; they cannot be used with menus or commands added dynamically. That is, you cannot nest dynamic categories. When a tree is loaded, the system invokes any JPO configured by these settings on the tree or any command in the tree. If defined for a menu in the tree, the JPO is invoked when the user expands that category. The JPO returns a hashMap containing key/value pairs to generate a dynamic category. The hashMap can contain any number of key/value pairs as required by the business logic. The JPO must implement the business logic that determines which dynamic commands/menus should be included. If these settings are defined on the tree menu itself, the returned categories (menus or commands) are included at the top of the category list followed by the static (specifically-defined) categories. If the settings are defined on a command within the tree's structure, the returned categories take that command's place in the tree structure. If the settings are defined on a menu within the tree's structure, the JPO is not invoked until the user expands that category, and the dynamic categories for the menu are added as subcategories for the menu category along with any defined static categories. Structure of the Returned HashMapThe hashMap returned to the application from the JPO must contain key/value pairs that define the categories to add to the tree, either in addition to the existing static categories (when configured on the tree), in place of an existing command (when configured for a command in the tree), or as subcategories for a menu (when configured for a menu in the tree). This table defines the contents of the hashMap:
Sample JPO for Obtaining Dynamic CategoriesThis sample JPO shows how to obtain dynamic categories for a tree. public HashMap getDynamicCategories (Context context, String[] args )throws Exception { HashMap resultMap = new HashMap(); MapList categoryMapList = new MapList(); /* Unpack the Arguments to get the Input param Map */ HashMap inputMap = (HashMap)JPO.unpackArgs(args); /* Input param Map has paramMap and commandMap * paramMap contains objectId, relId, mode, treeMenu, requestMap */ HashMap paramMap = (HashMap) inputMap.get("paramMap"); /* commandMap retrieved form Input param Map * The static command/menu configured with Dynamic Settings */ HashMap commandMap = (HashMap) inputMap.get("commandMap"); /* requestMap is retrieved from paramMap. requestMap contains * request parameters passed to the Tree Component */ HashMap requestMap = (HashMap) paramMap.get("requestMap"); String strObjId = (String) paramMap.get("objectId"); /* Creation of a Dynamic Command Category starts...*/ /* New Dynamic Command categoryMap is created*/ HashMap categoryCommandMap = new HashMap(); /* Dynamic CategoryMap should have value for type, name, settings, * roles, href. Otherwise that particular category is rejected in * the result */ /* type should be command for command * category type should be menu for menu category * */ categoryCommandMap.put("type","command"); /* label can be property entry or a hard coded value */ categoryCommandMap.put("label","emxFramework.DynamicCommand. propertykey"); /* roles should be StringList, not String, and can have multiple * values * Ex: StringList roles = new StringList(); roles.add("Public Add"); roles.add("Product Management"); */ categoryCommandMap.put("roles", new StringList("all")); /* name should not be null and it should be unique in the current * tree (i.e.: should not match any existing category name in the * view) */ categoryCommandMap.put("name","DynamicCommand"); /* href which is executed when this category is click by the user * can be blank for menu category (i.e.: type = menu) */ categoryCommandMap.put("href","${COMMON_DIR}/ emxDynamicAttributes.jsp?objectId="+strObjId); /* settings for the category item All the setting which are * applicable to static * category can be used. It should be a separate HashMap */ HashMap settings = new HashMap(); settings.put("Registered Suite","Framework"); settings.put("Target Location","content"); settings.put("Access Expression","context.user.name==\"Test Everything\""); /* settings is added to the category Map settings can be null */ categoryCommandMap.put("settings",settings); /* Creation of a Dynamic Command Category ends...*/ /* Creation of a Dynamic Menu Category starts...*/ HashMap categoryMenuMap = new HashMap(); categoryMenuMap.put("type","menu"); categoryMenuMap.put("label","emxFramework.DynamicMenu. propertykey"); categoryMenuMap.put("description","dynamic menu"); categoryMenuMap.put("roles", new StringList("all")); categoryMenuMap.put("name","DynamicMenu"); categoryMenuMap.put("href",""); categoryMenuMap.put("settings",null); HashMap grandChild = (HashMap)categoryCommandMap.clone(); grandChild.put("name","DynamicGrandCommand"); grandChild.put("label","Dynamic Grand Command"); MapList menusSubCategories = new MapList(); menusSubCategories.add(grandChild); /* Note: when the category is menu it should have all its Sub * Categories in a MapList and the key should be Children if the key * Children is not there Menu Category is rejected */ categoryMenuMap.put("Children",menusSubCategories); /* Creation of a Dynamic Menu Category ends...*/ /* categories are added to the categoryMapList */ categoryMapList.add(categoryCommandMap); categoryMapList.add(categoryMenuMap); /* resultMap should have a key Children and value should be a * MapList containing CategoryMaps(s). */ resultMap.put("Children",categoryMapList); return resultMap; } |