ExecuteAction exit

You use the ExecuteAction exit to perform custom operations at the push of a button. The range of operations goes from performing a custom control on an Interplay entity to automatically creating and saving a number of objects.

public interface ExecuteActionExit{

public ExecuteActionResult execute(

Object currentEditedObject,

List<Object> selectedObjects,

SourceDatabaseExternal sourceDatabaseExternal,

Map<String, Object> functionArguments)

throws InterplayException;

}

Argument Contents
currentEditedObject Currently selected object in the GUI.
selectedObjects List of selected Objects/Elements if custom action is meant to run on a list.
sourceDatabaseExternal Utility that enables access to the content of the Collection.
functionArguments

Function arguments

The method throws an InterplayException if something goes wrong during exit execution.

Passing ExecuteAction results

If you call several ExecuteAction exits in a row, you can pass over the results of each execution to the next one. This avoids the need to reload the elements and allows to merge the errors and results.

Example:

// get the common context

Map<String, Object> context = (Map<String, Object>)functionArguments.get(FunctionRunner.COMMON_CONTEXT);

 

// pass a custom object to common context from an exit

context.put("myObjKey ", new MyObject());

 

// retrieve object from common context from other exit

MyObject myObj = (MyObject)context.get("myObjKey");

ExecuteActionResult message supports HTML

The message property of an ExecuteActionResult object can contain HTML formatted text and it will be rendered as HTML content in the result panel of the action.

Example:

// create instance of ExecuteActionResult

ExecuteActionResult ear = new ExecuteActionResult();

 

// set the message with HTML formatted content

String msg = “You can download report <a href=\"http://www.google.ro\" target=\"_blank> here </a>";

ear.setMessage(msg);

 

// set the content type of message to HTML

ear.setHtmlContentType(true);

Request user confirmation

If the exit needs user confirmation, it can return with a request containing a message and labels for 2 buttons (Ok/Cancel, Yes/No, etc.). The user interface displays the message and the two buttons.

When the user clicks one of the buttons, the same exit is executed again, containing in the request the actual user input. The exit logic follows different execution paths depending on the user input and it returns as usual or with another request for confirmation.

Example

ExecuteActionResult result = new ExecuteActionResult();

int code = 1;

String question = “Do you want to update the account?”;

UserInputRequest userInputRequest = new UserInputRequest(code, question, "Yes", "No");

result.setRequestUserInput(true);

result.setUserInputRequest(userInputRequest);

result.setTitle("Account update");

Each input request is identified by a code. The code is unique, it is used in the exit to identify the user response. A complete exit logic looks like this:

UserInputResponse userInputResponse = (UserInputResponse)functionArguments.get(FunctionRunner.USER_INPUT_RESPONSE);

if (userInputResponse == null)

{

// ask the first question

}

else

{

switch (userInputResponse.getCode())

{

case 1:

if (userInputResponse.getUserInput() == true)

{

// handle “yes” answer for question 1

// (optional) ask the second question

}

else

{

// handle “no” answer for question 1

// (optional) ask the second question

}

break;

case 2:

// handle the second question

break;

...

}

}

When the user provides an answer for the input request, the server executes the whole exit again. If there are several exits that are executed for a custom action and one of them requires user input, after the user provides the answer, the server executes all the exits again.

Related Links