menu Command

Menus can be used in custom Java applications. Menus can be designed to be toolbars, action bars, or drop-down lists of commands.

Before creating a menu, you must define the commands that it will contain, since commands are child objects of menus — commands are created first and then added to menu definitions, similar to the association between types and attributes. Changes made in any definition are instantly available to the applications that use it.

For conceptual information on this command, see MQL Concepts: Menus.

This page discusses:

User Level

Business Administrator with Menu administrative access

Add Menu

To define a menu from within MQL use the Add Menu command.

Syntax

add menu NAME [ADD_ITEM {ADD_ITEM}];
  • NAME is the name of the menu you are defining. Menu names cannot include asterisks.

You cannot have both a command and a menu with the same name.

  • ADD_ITEM provides additional information about the menu. The Add Menu clauses are:
description VALUE
icon FILENAME
label VALUE
href VALUE
alt VALUE
menu NAME {,NAME}
command NAME {,NAME}
setting NAME [STRING]
[!|not] hidden
property NAME [to ADMINTYPE NAME] [value STRING]

Label Clause

This clause specifies the label to appear in the application in which the menu is assigned. For example, many desktop applications have a File menu.

Href Clause

This clause is used to provide link data to the JSP. The Href link is evaluated to bring up another page. Many menus will not have an Href value at all. However, menus designed for the “tree” menus require an Href because the root node of the tree causes a new page to be displayed when clicked. The Href string generally includes a fully-qualified JSP filename and parameters, which can contain embedded macros and expressions for mapping to database schema. For more information, see MQL Concepts: Using Macros and Expressions in Configurable Components.

The syntax is:

href VALUE;

  • VALUE is the link data.

Alt Clause

This clause is used to define text that is displayed until any image associated with the menu is displayed and also as “mouse over text.”

The syntax is:

alt VALUE;

  • VALUE is the text that is displayed.

For example, you could use the following for a Tools menu:

alt “Tools”;

Menu Clause

This clause is used to specify existing menus to be added to the menu you are creating. The menus will be displayed in the order in which they are added. Separate items with a comma.

The syntax is:

menu NAME {,NAME};

  • NAME is the name of the menu you are adding.

Command Clause

This clause is used to specify existing commands to be added to the menu you are creating. The commands will be displayed in the order in which they are added. Separate items with a comma.

The syntax is:

command NAME {,NAME};

  • NAME is the name of the command you are adding.

For more information, see Add Command.

Setting Clause

This clause is used to provide any name/value pairs that the menu needs. They can be used by JSP code, but not by hrefs on the Link tab. For more information, see MQL Concepts: Using Macros and Expressions in Configurable Components.

The syntax is:

setting NAME [STRING];

For example, an image setting with the image name can be specified to display when the menu is used in a toolbar:

setting Image iconSmallMechanicalPart.gif;

History Clause

The history keyword adds a history record marked “custom” to the menu that is being added. The STRING argument is a free-text string that allows you to enter some information describing the nature of the addition. For more information, see Adding History to Administrative Objects.

Copy Menu

After a menu is defined, you can clone the definition with the Copy Menu command. Cloning a menu definition requires Business Administrator privileges, except that you can copy a menu definition to your own context from a group, role or association in which you are defined.

Syntax

This command lets you duplicate defining clauses with the option to change the value of clause arguments:

copy menu SRC_NAME DST_NAME [MOD_ITEM {MOD_ITEM}];
  • SRC_NAME is the name of the menu definition (source) to be copied.
  • DST_NAME is the name of the new definition (destination).
  • MOD_ITEMs are modifications that you can make to the new definition. For more information, see Modify Menu.

History Clause

The history keyword adds a history record marked “custom” to the menu that is being copied. The STRING argument is a free-text string that allows you to enter some information describing the nature of the copy operation. For more information, see Adding History to Administrative Objects.

Modify Menu

Use the Modify Menu command to add or remove defining clauses and change the value of clause arguments.

Syntax

 modify menu NAME [MOD_ITEM {MOD_ITEM}];
  • NAME is the name of the menu you want to modify.
  • MOD_ITEM is the type of modification you want to make. Each is specified in a Modify Menu clause, as listed in the following table. You need specify only the fields to be modified.
    Modify Menu Clause Specifies
    name NEW_NAME The current menu name is changed to the new name entered.
    description VALUE The current description value, if any, is set to the value entered.
    icon FILENAME The image is changed to the new image in the file specified.
    label VALUE The label is changed to the new value specified.
    href VALUE The link data information is changed to the new value specified.
    alt VALUE The alternate text is changed to the new value specified.
    order menu NAME NUMBER The order of the named menu item included in the menu is changed to the NUMBER specified. For more information, Order Clause.
    order command NAME NUMBER The order of the named command item included in the menu is changed to the NUMBER specified. For more information, Order Clause.
    add menu NAME The named menu is added to the menu.
    add command NAME The named command is added to the menu.
    add setting NAME [STRING] The named setting and STRING are added to the menu.
    remove menu NAME The named menu is removed from the menu.
    remove command NAME The named command is removed from the menu.
    remove setting NAME [STRING] The named setting and STRING are removed from the menu.
    property NAME [to ADMINTYPE NAME] [value STRING] The named property is modified.
    add property NAME [to ADMINTYPE NAME] [value STRING] The named property is added.
    remove property NAME [to ADMINTYPE NAME] [value STRING] The named property is removed.
    history STRING Adds a history record marked "custom" to the menu that is being modified. The STRING argument is a free-text string that allows you to enter some information describing the nature of the modification. For more information, see Adding History to Administrative Objects.

Each modification clause is related to the arguments that define the menu. To change the value of one of the defining clauses or add a new one, use the Modify clause that corresponds to the desired change.

When modifying a menu, you can make the changes from a script or while working interactively with MQL.

  • If you are working interactively, perform one or two changes at a time to avoid the possibility of one invalid clause invalidating the entire command.
  • If you are working from a script, group the changes together in a single Modify Menu command.

Order Clause

The order clause on the modify menu command is used to re-order menu items. For example, to place a new command (C3) in the third spot of an existing menu (MyMenu) that already has five items, you would issue the command:

modify menu MyMenu add command C3 order command C3 3;

Another example is given below showing the before and after effect of ordering.

Before ReorderingAfter Reordering
menu MyMenu
  command C1
  menu M1
  menu M2
  command C2
menu myMenu
  menu M1
  command C1
  command C2
  menu M2

To make this change you would have to issue the following command:

modify menu MyMenu order command C1 2 order command C2 3;

Delete Menu

If a menu is no longer required, you can delete it using the Delete Menu command.

delete menu NAME;
  • NAME is the name of the menu to be deleted.

Searches the list of defined menus. If the name is found, that menu is deleted. If the name is not found, an error message is displayed. For example, to delete the menu named “Toolbar” enter the following:

delete menu "Toolbar";

After this command is processed, the menu is deleted and you receive an MQL prompt for another command.