The js-action element

The js-action element defines the JavaScript implementation of the custom action.

The js-action element contains the following elements in the specified order.
js-include
The js-include element defines a JavaScript file to include in the page. It is optional and can occur zero or more times
object-name
The object-name element specifies the name of the JavaScript object which defines the custom action. This JavaScript object must be contained in the JavaScript code specified, either in the js-file or js-content elements. The object-name element is required and occurs once.
js-file
The js-file element defines the URL of the JavaScript file which contains a definition for the JavaScript custom action object. The specified file is included in the page. The js-file element is optional and occurs zero or once. One of js-file or js-content must be specified.
Example:
<js-file>/MyWebApp/scripts/detailviewer.js</js-file>
js-content
The js-content element defines the JavaScript code which contains a definition for the JavaScript custom action object. The specified definition is included in the page. The js-content element is optional and occurs zero or once. One of js-file or js-content must be specified.
Example:
<js-content><![CDATA[
function MyCustomAction() {
	this.init = function(initParameters, context) {
		return true;
	}
	this.execute = function(context) {
	}
}
]]&gt;
</js-content>
js-messages
The js-messages element defines the messages which are to be made available to the JavaScript custom action. Such messages are accessed using the function serviceregistry.formatMessage(). The js-messages element contains the following element.
js-message-bundle
The js-message-bundle defines a message bundle. It can occur one or more times. The js-message-bundle element contains the following elements in the specified order.
  • js-message-bundle-name
  • The js-message-bundle-name element defines the fully qualified name of the message bundle which contains the required messages. It must occur once.
  • js-message-key
  • The js-message-key element defines the key of a message which is required. It is optional and can occur zero or more times. The message key must exist in the message bundle given.
  • If there are no js-message-key elements defined in a given js-message-bundle element, then all messages from the specified bundle are available to the custom action. If any message keys are specified, only those keys are available to the custom action.
The following is an example of a js-messages element.
<js-messages>
<js-message-bundle>
<js-message-bundle-name>com.ibm.serviceregistry.customaction.examples.LabelsResourceBundle</js-message-bundle-name>
		<js-message-key>customaction.name</js-message-key>
		<js-message-key>customaction.error</js-message-key>
</js-message-bundle>
</js-messages>