Defining Individual Actions in an Action Set
Each action data object in a set is a data object of type com.vmware.actionsfw.ActionSpec. You must create an ActionSpec data object for every action to add to the action set.
You create each ActionSpec data object using a <com.vmware.actionsfw.ActionSpec> XML element. In this element, you set the properties for the action. ActionSpec Object Properties lists the properties that you set for each ActionSpec object.
Boolean value. If you set this value to true, the action can be made available when the user selects multiple vSphere objects. This property is optional.
HTML-based extensions do not use the <command> property. Instead they contain a <delegate> object.
Defining the <delegate> Object in HTML-Based Action Extensions
HTML-based extensions use delegated actions instead of the command classes used by Flex-based extensions. The <delegate> object requires a <className> property and an <object> element that contains only an embedded <root> object. Example: Example Action Set for an HTML-Based Extension shows the structure of the <delegate> object for an HTML-based extension.
The <className> property must specify the HtmlActionDelegate class for HTML-based extensions:
<className>com.vmware.vsphere.client.htmlbridge.HtmlActionDelegate</className>
The <root> object specifies the UI dialog box used to initiate the HTML-based action.
Root Object Properties for HTML Action Extension lists the properties that you set in the <root> object.
Identifies the HTML resource to be displayed. Can be an absolute HTTPS URL or a bundle context path. If it is a bundle context path, a relative URL, it must end with the .html extension to enable session authentication. For absolute URLs, the framework does not use session authentication.
Example Action Extension Definitions
You define the client part of your action extension using ActionSpec objects in your plugin.xml file. The properties you use to define an ActionSpec object depend on the type of extension.
Flex-based action extensions specify a command class, implemented in ActionScript. HTML-based extensions specify instead a delegate class, provided by the framework.
There are two types of HTML-based action extensions. One type, known as a UI action, displays a modal dialog box for user input or confirmation before submitting a service request. The other type, known as a headless action, initiates a request to a service without additional user input. An extension definition for a UI action specifies the size and title of the dialog box, while a headless action definition omits the dialog box properties.
Flex-Based Action Extension Definition
Example: Example Action Set for a Flex-Based Extension shows an example extension definition for a Flex-based action set extension. In the example, the extension adds a set of two actions to the vSphere Web Client Actions Framework. The actions are associated with a custom object type called a Chassis.
Example: Example Action Set for a Flex-Based Extension
<extension id="mySolution.myPlugin.myActionSet">
<extendedPoint>vise.actions.sets</extendedPoint>
<object>
<actions>
<!-- first action -->
<com.vmware.actionsfw.ActionSpec>
<uid>com.mySolution.myPlugin.chassis.createChassis</uid>
<label>Create Chassis</label>
<description>Create a Chassis object.</description>
<icon>#{myPluginImages:sample1}</icon>
<acceptsMultipleTargets>false</acceptsMultipleTargets>
<command className="com.mySolution.myPlugin.ChassisCommand"/>
</com.vmware.actionsfw.ActionSpec>
<!-- second action -->
<com.vmware.actionsfw.ActionSpec>
<uid>com.mySolution.myPlugin.chassis.editChassis</uid>
<label>Edit Chassis</label>
<description>Edit a Chassis object.</description>
<icon>#{myPluginImages:sample2}</icon>
<acceptsMultipleTargets>true</acceptsMultipleTargets>
<conditionalProperty>actions.isEditAvailable</conditionalProperty>
<command className="com.mySolution.myPlugin.ChassisCommand"/>
</com.vmware.actionsfw.ActionSpec>
</actions>
</object>
<metadata>
<!-- filters the actions in the set to be visible only for Chassis -->
<objectType>samples:Chassis</objectType>
</metadata>
</extension>
 
HTML-Based UI Action Extension Definition
Example: Example Action Set for an HTML-Based Extension shows an example extension definition for an HTML-based UI action extension. The extension must use a <delegate> object instead of the <command> object used by a Flex-based extension. The action in this definition is associated with a custom object type called a Chassis.
Example: Example Action Set for an HTML-Based Extension
<extension id="com.vmware.samples.chassis.listActionSet">
<extendedPoint>vise.actions.sets</extendedPoint>
<object>
<actions>
<com.vmware.actionsfw.ActionSpec>
<uid>com.vmware.samples.chassis.createChassis</uid>
<label>#{chassis.createAction}</label>
<icon>#{addChassis}</icon>
<delegate>
<className>com.vmware.vsphere.client.htmlbridge.HtmlActionDelegate</className>
<object><root>
<actionUrl>/vsphere-client/chassis/resources/createChassisDialog.html</actionUrl>
<dialogTitle>#{chassis.createAction}</dialogTitle>
<dialogSize>500,400</dialogSize>
</root></object>
</delegate>
<privateAction>true</privateAction>
</com.vmware.actionsfw.ActionSpec>
</actions>
</object>
</extension>
 
When the action is invoked the platform opens a modal dialog containing the HTML document specified in the actionUrl property. The following parameters are added to the URL:
actionUid: the <uid> of the ActionSpec object defined in the plugin.xml file
targets: a comma-separated list of objectIds
By default, the targets parameter takes only one objectId. To specify more than one objectId, set the flag acceptsMultipleTargets to true.
In this example, the full URL takes the following form:
/vsphere-client/chassis/resources/createChassisDialog.html?actionUid=com.vmware.samples.chassis.createChassis&targets=objectId&locale=en
The dialog script uses the REST API to GET or POST data requests. For instance, to get object properties using the Data Access API, you use a request similar to the following:
/vsphere-client/htmltest/rest/data/properties/objectId?properties=properties-list
After the dialog form is submitted or the operation is canceled, the JavaScript code calls WEB_PLATFORM.closeDialog().
HTML-Based Headless Action Extension Definition
Example: Example Action Set for a Headless HTML-Based Extension shows an example extension definition for an HTML-based headless action extension. The extension must use a <delegate> object instead of the <command> object used by a Flex-based extension. The action in this definition is associated with a custom object type called a Chassis.
Example: Example Action Set for a Headless HTML-Based Extension
<extendedPoint>vise.actions.sets</extendedPoint>
<object>
<actions>
<com.vmware.actionsfw.ActionSpec>
<uid>com.vmware.samples.chassis.deleteChassis</uid>
<label>#{chassis.deleteAction}</label>
<icon>#{deleteChassis}</icon>
<delegate>
<className>com.vmware.vsphere.client.htmlbridge.HtmlActionDelegate</className>
<object><root>
<actionUrl>/vsphere-client/chassis/rest/actions.html</actionUrl>
</root></object>
</delegate>
</com.vmware.actionsfw.ActionSpec>
...
 
When the headless action is invoked the HTML bridge makes a POST request to the actions controller on the Virgo server, using the actionUrl property. The following parameters are added to the URL:
actionUid: the <uid> of the ActionSpec object defined in the plugin.xml file
targets: a comma-separated list of objectIds
By default, the targets parameter takes only one objectId. To specify more than one objectId, set the flag acceptsMultipleTargets to true.
In this example, the full URL takes the following form:
/vsphere-client/chassis/rest/actions.html?actionUid=com.vmware.samples.chassis.deleteChassis&targets=objectId