Custom action examples

Please refer to basic code examples document for naming conventions and logging strategies.

Server-side custom action

A server-side action corresponds to an action with a value in the method field.

This method field contains the name of a server-side Rhino script function or a Java method (depending on the language you are using).

For instance if you set myCustomAction as action method and if you grant this action to the MyObject business object, the platform will look for the server-side Rhino script function or Java method called MyObject.myCustomAction() and will run it.

Rhino

MyObject.myCustomAction = function() {
    var rowId = this.getRowId();
    return Message.formatSimpleInfo("Using instance " + this.getInstanceName() + (!Tool.isEmpty(rowId) ? " and row ID " + rowId : ""));
}

Java

public String myCustomAction() {
    String rowId = getRowId();
    return Message.formatSimpleInfo("Using instance " + getInstanceName() + (!Tool.isEmpty(rowId) ? " and row ID " + rowId : ""));
}

On responsive UI (using ajax services) the action can return:

Examples:

Note: These server-side custom actions are available thru the webservices APIs.

Client-side custom action

A client-side action corresponds to an action with a value in the URL field.

Plain URL

When URL contains a plain URL (that can be either absolute or relative), the platform UI will call this URL appending the object, inst and row_id URL parameters.

JavaScript statement pseudo-URL

When URL contains a client-side JavaScript statement pseudo-URL (starting with javascript:), the platform will run this JavaScript statement after having substituted the [object], [inst] and [row_id] tags.

For instance, let's say you have created the default client JavaScript resources SCRIPT resource for your MyObject business object like this:

MyObject = (function MyObject($) {
    function test(inst, row_id) {
        return Simplicite.UI.popup({ content: "Using instance " + inst + (row_id ? " and row ID " + row_id : "") });
    }

    return { myCustomAction: test };
})(jQuery);

Then you can configure a custom action for MyObject to call this myCustomAction function with this value in the URL field:

javascript:return [object].myCustomAction('[inst]', [row_id])

Attention, due to the way the UI runs the JavaScript statement, you must only use simple quotes ' in it (this limitation does not apply to the content of the SCRIPT resource).

Note: These client-side custom actions are not available thru the webservices APIs.