Skip to content
CA Spectrum - 10.3
Documentation powered by DocOps

Customizing the OneClick Console Menu

Last update July 27, 2018

Contents

This section describes how to add new menus and new menu items to the OneClick console. You can use new menu items to launch URLs, third-party applications, and scripts, and to pass parameters to them.

The custom-menu-config.xml File

The <$SPECROOT>/tomcat/webapps/spectrum/WEB-INF/console/config/custom-menu-config.xml file contains examples on how to add custom menus and custom menu items to your OneClick console as shown in the images. You need to copy this file in to the <$SPECROOT>/custom/console/config/ directory if the file is not already in this directory.

The following image shows the Connections menu and its two new menu items: Ping Local and Launch Diagnostics:

SPEC--menu_connections

The following image shows that a new menu item called Launch My Web Page, which has been added to the existing Tools menu. This menu item has been created to launch a specified web page.

SPEC--launch_web_page

You create OneClick menus and menu items using the <menu> and <item> XML elements. The <menu> element can enclose one or more <item> elements that define the commands that are available on the menu. The <item> element can enclose several other elements that define how the menu item appears and behaves. See the following table for information about these elements.

Element Parent Element Description
<menu> <root> Defines the menu. The name attribute is used to define the name of the menu.
<separator> <menu> Used just before an <item> element to define a separator line as shown in the first figure in this section.
<item> <menu> Defines an item on a specific menu. The name attribute is used to define the name of the item.
<privilege> <item> Associates a privilege to the menu item. If the user is not given this privilege, the menu item is not displayed for that user.
<toolbar-image> <item> Specifies the image to display for the menu item and its associated toolbar button when the functionality is available to the user.
<toolbar-image-rollover> <item> Specifies the toolbar image that is displayed when a user places the cursor over the toolbar button.
<toolbar-image-disabled> <item> Specifies the toolbar image that is displayed when the functionality is disabled (not available to the user). A typical representation for this state is an image that is 80percent “grayed out.”
<accelerator> <item> Defines a keyboard sequence that executes the menu item.
<action> <item> Defines the action that takes place when the user clicks the menu item.
<hot-key> <item> Underlines the first instance of the indicated letter and enables the user to activate the menu item using this letter as a keyboard shortcut.

The subsequent sections of this chapter describe how to use the <menu> element to create a new menu and how to use the <item> element and its child elements to add menu items to a new or existing menu.

Add a New Menu

The <menu> element is used to create a OneClick console menu.

To add a new menu

  1. Open the existing <$SPECROOT>/custom/console/config/custom-menu-config.xml file.
  2. If the file does not exist, copy the file <$SPECROOT>/tomcat/webapps/spectrum/WEB-INF/console/config/
    custom-menu-config.xml into the <$SPECROOT>/custom/console/config directory, and then open it.
    The <root> element is the root element for this file. Define all new menus inside the <root> element.
  3. Use the <menu> element to create new menus. This element has a single attribute, name, which defines the name of the menu.

    Note: Some of the examples in the custom-menu-config.xml file show a fully qualified menu name that references a Java class created by OneClick engineers. For example, com.aprisma.spectrum.app.swing.window.menu.Tool is used as the value for the name attribute in the <menu> element that defines the Tools menu. You don't have to use a fully qualified name to create a new menu or to refer to an existing menu. Simply use the exact text that you would like to appear as the menu name on the toolbar.
  4. Add items to the new menu by specifying them using the <item> element and its available child elements. If you do not specify menu items for a menu, the menu is not visible in the OneClick console.
  5. Save the changes that you have made to custom-menu-config.xml.
  6. To view and test the new menus, restart the OneClick console.

Example: Creating a New Menu

The following lines of XML create the Connections menu shown in The custom-menu-config.xml File.

<menu name="Connections">
   <item name="Ping Local">
	.
	.
	.
   </item>
   <item name="Launch Diagnostics">
   	.
   	.
   	.
   </item>
</menu>

Add a New Menu Item

To add an item to an existing OneClick console menu or to a new menu that you created, you must create a new <item> element inside the <menu> element that you are customizing. The <item> element uses the <name> attribute to specify the name of the menu item.

Note: The new menu item is also added automatically to the right-click menu.

To add a new menu item

  1. Open <$SPECROOT>/custom/console/config/custom-menu-config.xml.
  2. Find the <menu> element that you created in Add a New Menu that defines the menu to which you want to add items. If the <menu> item does not yet exist, add it using the name attribute to define either an existing or a new menu.

    Note: Some of the examples in custom-menu-config.xml show a fully qualified menu name that references a Java class created by OneClick engineers. For example, com.aprisma.spectrum.app.swing.window.menu.Tool is used as the value for the name attribute in the <menu> element that defines the Tools menu. You do not have to use a fully qualified name to create a new menu or to refer to an existing menu. For example, you can use <menu name=“Tools”> to refer to the Tools menu.
  3. Use the <item> element to create each new menu item. This element has one attribute, name, which defines the name of the menu item.
  4. The <item> element has a series of child elements that enable you to define how the item behaves. These elements are listed in the table in the custom-menu-config.xml File, and they are further defined in the rest of this chapter. Use these elements to define the behavior of the menu item you have added.
  5. Save the changes that you have made to custom-menu-config.xml.
  6. To view the new menu items, restart the OneClick Console.

Example: Creating New Menu Items

The following example adds a menu item that is called Ping Local to a menu called Connections.

<menu name="Connections">
   <item name="Ping Local">
    <accelerator modifiers="2">VK_I</accelerator>
    <action>
    	<filter>
    		<has-attribute>AttributeID.NETWORK_ADDRESS</has-attribute>
    	</filter>
    	<context>com.aprisma.spectrum.app.topo.client.render.ModelContext </context>
    	<context>com.aprisma.spectrum.app.alarm.client.group.AlarmContext</context>
    	<launch-application>
    		<platform>
    			<os-name>Windows 9x</os-name>
    			<command>command.com /c start "Local ping {0}" cmd.exe /c 
			"ping.exe {0} &amp;&amp; pause"</command>
    		</platform>
    		<platform>
    			<os-name>Windows</os-name>
    			<command>cmd.exe /c start "Local ping {0}" cmd.exe /c "ping.exe 
			{0} &amp;&amp; pause"</command>
    		</platform>
    		<platform>
    			<command>/usr/dt/bin/dtterm -e ping -s {0}</command>
    		 </platform>
    			<param>
    			  <attribute>AttributeID.NETWORK_ADDRESS</attribute>
    			</param>
    	</launch-application>
    </action>
   </item>
</menu>

Add Toolbar Images

To have a toolbar image available for each of the three toolbar image states, you must specify them in your menu item definition. The elements for toolbar states are:

  • <toolbar-image>
  • <toolbar-image-rollover>
  • <toolbar-image-disabled>

You can use the following image formats for OneClick toolbar images: .png, .gif, .jpg, and .jpeg.

The recommended toolbar image size is 24 x 24 pixels. Store custom images in the <$SPECROOT>/custom/images directory. When you reference an image that is placed in this directory, specify the path from the images directory, for example, images/myimage.png.

The following line of code specifies a toolbar image using the relative path to the image file.

<toolbar-image>images/hints.gif</toolbar-image>

For a listing of all of the elements that are used in defining OneClick menu items, see the table in Contextually Apply the Action.

Define a Keyboard Accelerator

The <accelerator> element specifies a combination of keyboard input that executes a corresponding menu item.

Specify the code for the accelerator key using the capitalized letter on the keyboard, which is preceded by “VK_”.

The modifiers attribute indicates the modifier key combinations as an integer where:

  • 1 = Shift
  • 2 = Ctrl
  • 3 = Ctrl+Shift
  • 8 = Alt
  • 9 = Alt+Shift
  • 10 = Ctrl+Alt

You are not required to specify a keyboard accelerator for a customized menu item.

<accelerator modifiers="2">VK_L</accelerator>

In the preceding example, the specified action of the menu item is performed if the 'L' key is pressed while holding down the Control key (Ctrl+L).

Perform an Action

The <action> element specifies the action that is performed when the menu item is selected. You can use the child elements that are shown in the table in Contextually Apply the Action to specify a particular action.

The <context> element specifies the context in which the menu item is active so that the action can be executed. This applies to both the standard and the right-click menu.

Contextually Apply the Action

Actions do not always apply in all situations, such as an action that is applicable only when the user selects a model. Therefore, you can specify one of the following contexts for your actions:

  • ModelContext
    Indicates that the action should be available when the user selects a model. The format for this context is as follows:

    <context>com.aprisma.spectrum.app.topo.client.render.ModelContext</context>
    
  • AlarmContext
    Indicates that the action should be available when the user selects an alarm. The format for this context is as follows:

    <context>com.aprisma.spectrum.app.alarm.client.group.AlarmContext</context>
    
  • TableContext
    Indicates that the action should be available when the user selects any table. The format for this context is as follows:

    <context>com.aprisma.spectrum.app.util.table.TableContext</context>
    

    If no tablename is specified, context is limited to any table. However, you can also limit context to a single table using the following format:

    <context>com.aprisma.spectrum.app.util.table.TableContext</context>
        <table-name>TableName</table-name>
    

You can specify one or a combination of contexts. If no specified context matches the current window context, the menu item is disabled. If no contexts are specified, the menu item is displayed in all contexts.

The following table describes the elements that are used to implement an action.

Element Parent Element Description
<context> <action> Limits the context in which the menu item is enabled and can perform the action.
<table-name> <action> Used with <context>, specifies the tablename when limiting the action to a single table. Works with TableContext only.
<column-name> <param> Used with <context> and <command>, specifies which values in a table column to pass into a script from a selected row in the table. Works with TableContext only.
<filter> <action> Limits the availability of menu items.
<has-attribute> <filter> Specifies the attribute on which to filter.
<and>, <or>, <value>, <equals> <filter> Creates an expression that can be used with a filter.
<launch-browser> <action> Launches a browser.
<launch-sso-browser> <action> Launches a browser and, if single sign-on is enabled in OneClick, includes a single sign-on token associated with the current session in the URL. This token can be used to reauthenticate the session across integrated web applications instead of prompting the user repeatedly for a username and password.
Note: For information about how to set up single sign-on in OneClick using CA SiteMinder® or CA Embedded Entitlements Manager, see the Integration section for that application.
<url> <launch-browser> Specifies the URL to launch in the browser.
<launch-application> <action> Launches an application.
<launch-web-server-script> <action> Launches a script available on the web server.
<display-output> <launch-application>,
<launch-web-server-script>
Displays the output from the launched script.
<display-exit-status> <launch-application>,
<launch-web-server-script>
Displays the exit status of a launched script.
<command> <launch-application>,
<launch-web-server-script>,
<platform>
Specifies the application or script that the menu item launches.
<run-for-multiple-alarms> <launch-web-server-script>

Runs a script on web browser for selected multiple alarms.

Note: Applicable for alarms only.

Starting from CA Spectrum 10.3, CA Spectrum users are allowed to add the following tag, which runs a script for multiple alarms in combined mode.

<multiple-contexts-enabled mode= "combined-execution"  delimiter= ";"/>

You can configure with the following modes:

combined-execution - multiple alarms single execution
separate-execution (default value) - multiple alarms multiple executions (one execution per an alarm)

For more information, see the Launch a Web Server Script For Multiple Alarms At The Same Time section in this page.

Note: If you do not mention any mode or the mode name is incorrect or if the <multiple-contexts-enabled mode= /> tag is completely removed, then the default mode (separate-execution) is applied.


<platform> <launch-application> Used with <os-name>, specifies the application to launch based on the operating system of the OneClick client.
<validate> <launch-application> Used with the <command> element, specifies that the menu item should only be added to the menu if the command exists on the OneClick client and has execute permissions. If either condition is found to be false during OneClick startup, the menu item is not added to the menu.
If the <validate> element is not used, the menu item is always added to the menu, but its state is determined by the value of other elements.
<os-name> <platform> Used with <platform>, specifies the application to be launched specific to the operating system of the OneClick client.
<param> <url>, <command> Specifies a parameter that is passed to a browser, executable, or script.
<attribute> <param> Specifies an attribute used as a parameter.

Limit the Availability of Menu Items

The <filter> element specifies a filter that further restricts the enabled state of the menu item. You can filter on any attribute of the selected context.

<filter>
   <has-attribute>AttributeID.NETWORK_ADDRESS</has-attribute>
</filter>

In the preceding example, the action needs the IP address of the alarmed model. Therefore, it should only be enabled if the alarmed model has the Network_Address (ID 0x12d7f) attribute.

You can specify complex attribute filters with any combination of nested “and” and “or” filters.

Example: Nesting Filters

The following example enables the item if the selected model has the Network_Address attribute and the Condition (ID 0x1000a) attribute is RED.

<filter>
   <and>
    <has-attribute>AttributeID.NETWORK_ADDRESS</has-attribute>
    <equals>
    	<attribute id="AttributeID.CONDITION">
    		<value>3</value> <!--red-->
    	</attribute>
    </equals>
   </and>
</filter>

The file <$SPECROOT>/tomcat/webapps/spectrum/WEB-INF/common/schema/
attribute-filter.xsd contains the complete syntax for attribute filters.

The following table defines commonly used attributes where an attribute ID is expected.

Constant Attribute
AttributeID.NETWORK_ADDRESS Network Address (ID 0x12d7f)
AttributeID.MTYPE_ID Model Type Handle (ID 0x129ab)
AttributeID.MTYPE_NAME Model Type Name (ID 0x10000)
AttributeID.MODEL_OBJECT Model Handle (ID 0x11f53)
AttributeID.MODEL_NAME Model Name (ID 0x1006e)
AttributeID.MODEL_CLASS Model Class (ID 0x11ee8)
AttributeID.CONDITION Condition (ID 0x1000a)
AttributeID.DOMAIN_ID Landscape Handle (ID 0x129ac)
AttributeID.DOMAIN_NAME Landscape Name (ID 0x11d42)
AttributeID.MAC_ADDRESS MAC Address (ID 0x110df)
AttributeID.DEVICE_TYPE Device Type (ID 0x23000e)

You can use the constants defined in the following table for alarm attributes:

Constant Alarm Attribute
AlarmAttrID.ACKNOWLEDGED Acknowledged (ID 0x11f4d)
AlarmAttrID.ALARM_FILTER_MH Alarm Filter (ID 0x12a56)
AlarmAttrID.ALARM_ID Full Alarm ID (ID 0x11f9c)
AlarmAttrID.INT_ALARM_ID Integer Alarm ID (ID 0x4820067)
AlarmAttrID.ALARM_SOURCE Alarm Source (ID 0x11fc4)
AlarmAttrID.ALARM_STATUS Alarm Status (ID 0x11f4f)
AlarmAttrID.CAUSE_CODE Cause Code (ID 0x11f50)
AlarmAttrID.CAUSE_LIST Cause List (ID 0x12a05)
AlarmAttrID.CAUSE_TITLE Cause Title (ID 0x4820020)
AlarmAttrID.CREATION_DATE Creation Date (ID 0x11f4e)
AlarmAttrID.CLEARED_BY_USER_NAME Cleared By User Name (ID 0x11f51)
AlarmAttrID.IMPACT_SEVERITY Impact Severity (ID 0x1290d)
AlarmAttrID.OCCURRENCES Occurrences (ID 0x11fc5)
AlarmAttrID.ORIGINATING_EVENT Originating Event (ID 0x1296e)
AlarmAttrID.PERSISTENT Persistent (ID 0x12942)
AlarmAttrID.PRIMARY_ALARM Primary Alarm (ID 0x11f54
AlarmAttrID.SEVERITY Severity (ID 0x11f56)
AlarmAttrID.TROUBLESHOOTER Troubleshooter (ID 0x11f57)
AlarmAttrID.TROUBLE_TICKET_ID Trouble Ticket ID (ID 0x12022)
AlarmAttrID.USER_CLEARABLE User Clearable (ID 0x11f9b)

If you need to use an attribute other than one of the attributes listed in the 2 preceding tables, specify the attribute using its hexadecimal attribute ID.

Launch a Browser

The <launch-browser> element lets you launch a specified URL in a browser and pass parameters to the URL. These parameters can be hard-coded values or values from model attributes.

Example: <launch-browser> Code

The following example launches the default browser on the client machine. The <url> element specifies the URL pattern. You can specify parameters to substitute in the URL pattern by enclosing the parameter number (starting at 0) in curly braces {}. You then specify <param> elements for each parameter.

<launch-browser>
   <url>http://{0}</url>
   <param>
    <attribute>AttributeID.NETWORK_ADDRESS</attribute>
   </param>
</launch-browser>

CA Spectrum processes the <param> elements in order so the first one corresponds to the 0th parameter in the URL pattern. A <param> element has a specific syntax. The most commonly used is the <attribute> element. This element substitutes the value of the specified attribute for the selected context. In the preceding example, the value of the Network Address attribute is substituted in the URL pattern. For more complex parameters, see the definition of <param-type> in the file.

<$SPECROOT>/tomcat/webapps/spectrum/WEB-INF/common/schema/basic-config.xsd

Important Information About Specifying URLs

Provide the following information when specifying URLs.

Use Standard Characters

Whenever a URL is specified in XML customization code for OneClick, the URL formatting must adhere to the standards published in the Internet Engineering Task Force (IETF) RFC 1738. Use of non-standard characters in URLs results in unreliable browser performance including the browser not locating the specified web page.

URL Encoding of Spaces and Commas

If you are using spaces or commas, or other "reserved" or "unsafe" characters in URLs (see the tables later in this section), convert them to their ASCII equivalent value with the proper URL encoding. URL encoding of a character consists of a "%" symbol, followed by the two-digit hexadecimal representation (case-insensitive) of the ISO-Latin code point for the character. Examples for "space" and "comma" are:

  • For spaces, use %20
  • For commas, use %2C
Note: Some browsers may encounter problems processing URLs even when using this encoding.

Use of Ampersands

If you are using an ampersand in a URL or in XML customization code, you must convert it to &amp.

Use CDATA in XML

You can place URLs inside a CDATA section so that they are not parsed. This avoids possible problems with URLs and the XML parser.

Be sure to follow the requirements for CDATA, including:

  • A CDATA section cannot contain the string "]]>", therefore, nested CDATA sections are not allowed.
  • Also ensure there are no spaces or line breaks inside the "]]>" string.

URL Unsafe Characters

Some characters can be misunderstood within URLs for various reasons. These characters should also always be encoded. Unsafe characters and their hexadecimal encoding are provided in the following table.

Character Code Points (Hex)
Space 20
Quotation marks (") 22
'Less Than' symbol ("<") 3C
'Greater Than' symbol (">") 3E
Pound' character ("#") 23
Percent symbol ("%") 25
Left Curly Brace ("{") 7B
Right Curly Brace ("}") 7D
Vertical Bar/Pipe ("|") 7C
Backslash ("\") 5C
Caret ("^") 5E
Tilde ("~") 7E
Left Square Bracket ("[") 5B
Right Square Bracket ("]") 5D
Grave Accent ("`") 60

URL Reserved Characters

URLs use some characters for special use in defining their syntax. When these characters are not used in their special role inside a URL, they need to be encoded. These characters and their hexadecimal encoding are provided in the following table.

Character Code Points (Hex)
Dollar ("$") 24
Ampersand ("&") 26
Plus ("+") 2B
Comma (",") 2C
Forward slash/Virgule ("/") 2F
Colon (":") 3A
Semi-colon (";") 3B
Equals ("=") 3D
Question mark ("?") 3F
'At' symbol ("@") 40

Specify a Username

You can pass the OneClick username of the current user to an application, Web browser, or executable requiring a username. Use the following expression to specify the logged-in username of the user:

<param>
   <expression>
    com.aprisma.spectrum.app.util.context.DefaultApplicationContext.getGlobal
Parameter(com.aprisma.spectrum.app.util.context.ApplicationContext.
USER_PARAMETER_NAME)
   </expression>
</param>

Example: Pass Username to Browser

The following example launches a browser to a specified URL and passes the username to the browser.

<launch-browser>
   <url> http://acme.com?user={0}</url>
   <param>
    <expression> com.aprisma.spectrum.app.util.context.DefaultApplicationContext.getGlobalParameter(com.aprisma.spectrum.app.util.context.ApplicationContext.USER_PARAMETER_NAME)
    </expression>
   </param>
</launch-browser>

Launch an Application From OneClick

The <launch-application> element enables you to launch a specified command or executable.

Example 1: <launch-application>

The following example launches an application called myapp on the client machine and passes in the IP address of the selected model. As with the <launch-browser> action, you can substitute any number of parameters.

<launch-application>
   <command>myapp {0}</command>
   <param>
    <attribute>AttributeID.NETWORK_ADDRESS</attribute>
   </param>
</launch-application>

The <command> element specifies the command or executable to execute. You can provide the path to the command or executable in one of two ways:

  • You can specify the path on each client via an environment variable. To create an environment variable in the Windows environment, select My Computer,Properties,Advanced, and then select the Environment Variables button.
  • You can specify an absolute path to the command or executable. If you do this, keep in mind that the path must be the same on each OneClick client. Path statements in the Windows environment should use a double backslash instead of a single backslash, for example:

    C:\\Windows\\system32\\cmd.exe
    
Note: You can use the <validate> element to verify that the command or executable exists on the OneClick client and has execute permissions. If either of these conditions is found to be false during OneClick startup, the associated menu item is not added to the OneClick menu. (If the <validate> element is not used, the menu item is always added to the menu, but its state is determined by the value of other elements.)

If you use the <validate> element, you must specify an absolute path in the <command> element, as shown in the following example:

<launch-application>
   <command>c:\\windows\\system32\\notepad.exe</command>
   <validate/>
</launch-application>

The <command> element must conform to the following syntax rules:

  • The command arguments are delimited by only spaces. If you would like to have a space within an argument, you must either place quotes around the argument or use the escape character '\' prior to the internal space(s).
  • If you would like to embed quotes within an argument, you must place the escape character '\' prior to the quote.
  • If any of your command arguments contain commas, CA Spectrum automatically places the argument within quotes. This is important to know in case that you are going to parse an argument that is a numeric value that contains commas.
  • CA Spectrum replaces arguments that return null or have a string length of zero with empty quotes (“ ” ).

Example 2: <launch-application>

The following example uses the <platform> element to specify different commands for different platforms. The <os-name> element specifies the operating system name and the <command> element specifies the command to execute on that operating system. The <os-name> element is optional. If you do not specify the <os-name>, the associated command is the default such that if no other platforms match, the default command is executed.

<launch-application>
   <platform>
    <os-name>Windows</os-name>
    <command>cmd.exe /c start "ping {0}" cmd /c "ping.exe {0}
    &amp;&amp;pause"</command>
   </platform>
   <platform>
    <os-name>SunOS</os-name>
    <command>>/usr/dt/bin/dtterm -e ping {0}</command>
   </platform>
   <param>
    <attribute>AttributeID.NETWORK_ADDRESS</attribute>
   </param>
</launch-application>

At runtime, CA Spectrum compares the specified OS names to the OS name returned by the “os.name” Java property. CA Spectrum uses a best-match algorithm so only a prefix of the OS name need be specified. You may specify any of the following OS names:

  • Windows for all Windows platforms
  • Windows XP for Windows XP
  • Windows 7 for Windows 7
  • Linux for the Linux platform
  • Mac for the Macintosh platform

If no specified platforms match, the associated menu item is disabled.

Launch a Web Server Script

The <launch-web-server-script> element launches a script on the web server machine. The <command> element specifies the script to execute. As with the <launch-browser> action, any number of parameters can be substituted. Since the script resides on the web server, which is restricted to a Windows machine, you do not use a <platform> element to denote the platform on which the script is running.

Note: This action can only be used to launch a script; it cannot be used to launch a user interface.

Example: <launch-web-server-script> Code

The following example launches “myscript” on the web server, passing it the model name and model type name of the selected model. Note that the path that is shown in the <command> element is a path for a Windows web server.

<launch-web-server-script>
   	<command>c:/scripts/myscript {0} {1}</command>
   	<param>
    	<attribute>AttributeID.MODEL_NAME</attribute>
   	</param>
   	<param>
    	<attribute>AttributeID.MTYPE_NAME</attribute>
   	</param>
</launch-web-server-script>

Use the <platform> tag with the <launch-web-server-script> as described in Launch an Application From OneClick.

Launch a Web Server Script For Multiple Alarms in Combined Mode

Till CA Spectrum 10.2.3, when you use the <run-for-multiple-alarms> tag with <launch-web-server-script>, it runs a script for selected multiple alarms in the OneClick console. Selected alarm attributes are passed as command line arguments to script for each selected alarm. The same script is run multiple times, once per selected alarm. 

Starting from CA Spectrum 10.3, you can use the following sub-element/tag to run a combined script in combined mode for multiple alarms. You can configure the<multiple-contexts-enabled mode= />  tag to run a script for several alarms at the same time in the alarm console. 

<multiple-contexts-enabled mode= "combined-execution"  delimiter= ";"/>

By default a space is considered as the 'delimiter' value. You can specify the delimiter value according to your requirement.

If you do not provide mode then the default value is applied as 'separate-execution' (<multiple-contexts-enabled mode=” separate-execution” />). 

In combined execution mode, CA Spectrum creates a temporary file in $SPECROOT/tmp folder, which contains details of specified attributes of all alarms selected separated by delimiter. This file is passed as an argument to the combined execution script.

The temporary file contains the list of alarm attributes separated by a delimiter in a single line. Each line specifies a single alarm.

Note: After the script is complete for combined execution, you need to manually delete the temporary file which was created in the $SPECROOT/tmp folder.

Pass Table Values to a Script

Used with the <context> and <command> elements, the <column-name> element lets you add menu items in OneClick that execute a command using data from a selected row in a table. With this feature, CA Spectrum eliminates the need to look up attributes separately to build the logic. Instead, you can build the logic from selected column headings within a table and can pass the values from any row in the table to the script. This ability to pass values directly from a table is helpful when you need to use the data in an external script. For example, you can build an interface between CA Spectrum and an issue-tracking system. Then, you can create a menu item that creates trouble tickets from table data in OneClick.

Note: The <column-name> element works with TableContext only in the <context> element.

Example: <command> and <column-name> Commands

The following example passes values from three columns (Condition, Status, and Type) to the "NewTicket" command. The <command> element specifies the command pattern. You specify parameters to substitute in the command by enclosing the parameter number (starting at 0) in curly braces {}. You then specify <param> elements for each column that passes values to the command.

<context>com.aprisma.spectrum.app.util.table.TableContext</context>
<command>$SCRIPT_PATH/NewTicket.exe {0} {1} {2} {3}</command>
   <param>
    <column-name>Condition</column-name>
   </param>
   <param>
    <column-name>Status</column-name>
   </param>
   <param>
    <column-name>Type</column-name>
   </param>

CA Spectrum processes the <param> elements in order so the first one corresponds to the 0th parameter in the command pattern. By default, CA Spectrum passes the raw value to the command. To preserve the formatting information from the table, use the <formatted/> option, as follows:

<param>
   <column-name>Condition
    <formatted/>
   </column-name>
</param>
Note: The formatted option attempts to render the specified column as seen in the table. However, CA Spectrum cannot pass images as arguments to commands and, therefore, passes the raw value only.

Display the Status of a Launched Application or Script

Use the <display-exit-status> and <display-output> elements with <launch-web-server-script> and <launch-application> to display the exit status and the output from the script or application.

By default <display-exit-status> displays “Success” if the exit code is 0 and “Failed with error code #” otherwise. You can change the default behavior by specifying <status> child tags that map an exit code to a custom message to display.

Example: <display-exit-status> Code

Examine the following example using <display-exit-status>:

<display-exit-status>
   <status code="1">Could not open file</status>
   <status code="2">Bad parameter</status>
   <status code="3">Could not connect to the server</status>
   <status default="true">Unknown error code {0}</status>
</display-exit-status>

This example maps status codes 1, 2, and 3 to specific message strings. The last status code specifies default=“true”, mapping all other error codes except 0, which by default maps to “Success”. If exit code 0 does not indicate success, you can override it with a <status> tag. The {0} in the message string substitutes the exit code.

By default, <display-output> displays both the standard output and standard error output from the process. You can display only the standard output by specifying:

<display-output stdout="t"/>

or only the standard error output by specifying:

<display-output stderr="t"/>
Note: The <display-exit-status> and <display-output> elements can only be used for command line applications or scripts and not GUI applications. OneClick waits for the script to complete before being available to the user again.
Was this helpful?

Please log in to post comments.