CAF.Command.Model
UI command controls extend the CAF.Link.Model with the CAF.Command.Model. The value of a CAF.Command.Model is the ID of the control. The raise() method is also available in the CAF.Command.Model. The raise() method makes the link active and simulates clicking the link. The CAF.Command.Model has a go(params) method that enables you to invoke the command directly, without simulating a user click action on the command button or link with the specified request parameters. For example, create a HiddenCommand with a server-side ID of myCommandId, and set a simple output button, and set its onclick property to the following:
When the user clicks the button, it submits the containing form using the HiddenCommand, with myParam1 and myParam2 as request parameters.
CAF.model('#{activePageBean.clientIds['myCommandId']}').go({
myParam1: "My Value One",
myParam2: "My Second Value"
});
The CAF.Command.Model enables registering the client-side action-listeners, which are invoked when the command is initiated after the form has been validated but before it is submitted. A client-side action-listener is a method that accepts one argument, the client-side ID of the command control. If the action-listener returns false, the command aborts and the form is not submitted. For example, the following JavaScript code adds an action-listener to the command with a server-side ID of myCommandId, and aborts the processing of the command until the command has been invoked five times:
var g_myCount = 0;
CAF.model('#{activePageBean.clientIds['myCommandId']}').addActionListener(function(id) {
return (g_myCount++ > 5);
});
For more information about CAF controls, see webMethods CAF Tag Library Reference.
Related Topics