command Command

Use this command to define your own commands. Commands can be used in any kind of menu in a JSP application. Commands might or might not contain code, but they always indicate how to generate another Web page. 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.

This page discusses:

User Level

Business Administrator with Menu administrative access

Add Command

To define a command from within MQL use the Add Command command.

Syntax

add command NAME [ADD_ITEM {ADD_ITEM}];
  • NAME is the name of the command you are defining. Command names cannot include asterisks. The name you choose is the name that will be referenced to include this command within a menu. You cannot have both a command and a menu with the same name.
  • ADD_ITEM is an Add Command clause that provides additional information about the command. The Add Command clauses are:
    description VALUE
    icon FILENAME
    label VALUE
    href VALUE
    alt VALUE
    code VALUE
    file FILENAME
    user [NAME {,NAME} | all]
    setting NAME [STRING]
    property NAME [to ADMINTYPE NAME] [value STRING]

Label Clause

This clause specifies the label to appear in the menu in which the command is assigned. For example, many desktop applications have a File menu with options labeled “Open” and “Save.”

Href Clause

This clause is used to provide link data to the href HTML commands on the Web page that references the command. This field is optional, but generally an href value is included.

The syntax is:

href VALUE;

  • VALUE is the link data.

    For example:

    href "emxForm.jsp?header=Basic Info";

Assigning an href to a link can create problems if a user clicks the same link twice when initiating such actions as changing an object’s state or submitting a form. The reason for this is that an href assigned to a link is considered a server request, even if it is a JavaScript command. Whenever the browser detects a server request, the browser stops processing the current request and sends the new request. Therefore, when a user first clicks on an href link, the request is processed, and typically, a JSP page starts executing. If, during this time, a user clicks the same link again, the first request is interrupted before completion and the new request is processed instead.

To avoid this scenario, you can set the href to “#” and use the onclick event instead. The generic code for this is:

<a href="#" onclick="submitForm()">

Alt Clause

This clause is used to define text that is displayed until any image associated with the command 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 command:

    alt “Tools”;

Code Clause

This clause is used to add JavaScript code to the command.

The syntax is:

code VALUE;

  • VALUE is the JavaScript code.

When commands are accessed from a JSP page, the href link is evaluated to bring up the next page. Commands only require code if the href link references JavaScript that is not provided on the JSP. The JSP must provide logic to extract the code from this field in order for it to be used. None of the commands provided by the applications or Framework use the code field.

You can add the code in the Code clause or it can be written in an external editor. If you use an external editor, use the File clause instead.

File Clause

This clause is used to specify the file that contains the code for the command when the code is written in an external editor.

The syntax is:

file FILENAME;

  • FILENAME is the name of the file that contains the code for the command.

User Clause

This clause is used to define the users allowed to see the command.

Any number of roles, groups, persons, and associations can be added to the command (role-based in this case includes all types of users and is not limited to only roles).

The syntax is:

user NAME {,NAME};

  • NAME is the name of the user(s) who have access to see the command.

Or:

user all;
  • If the User clause is not included, all users are given access to the command.

Setting Clause

This clauseprovides any name/value pairs that the menu needs. They can be used by JSP code, but not by hrefs on the Link tab.

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 command 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 Command

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

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

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

History Clause

The history keyword adds a history record marked “custom” to the command 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 Command

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

modify command NAME [MOD_ITEM {MOD_ITEM}];
  • NAME is the name of the command you want to modify.
  • MOD_ITEM is the type of modification you want to make. Each is specified in a Modify Command clause, as listed in the following command. You only need to specify the fields to be modified.
    Modify Command Clause Specifies
    name NEW_NAME The current command 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 is changed to the new value specified .
    alt VALUE The alternate text is changed to the new value specified.
    code VALUE The code associated with the command is replaced by the new code specified.
    file FILENAME The file that contains the command code is changed to the file specified.
    add user NAME The named user is granted access to the command.
    add user all All users are granted access to the command.
    add setting NAME [STRING] The named setting and STRING are added to the command.
    remove user NAME The named user access is revoked.
    remove user all Access to the command is revoked for all users.
    remove setting NAME [STRING] The named setting and STRING are removed from the command.
    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 command 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 command. 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 command, 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 Command command.

Delete Command

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

delete command NAME;
  • NAME is the name of the command to be deleted.
  • When this command is processed, 3DSpace searches the list of defined commands. If the name is found, that command is deleted. If the name is not found, an error message is displayed.

For example, to delete the command named “Convert,” enter the following:

delete command "Convert";

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