Skip to main content

Java Action

Action Naming Convention (JA-001)

Action class (i.e. any class that inherit from IUIAction) should end with "Action", for instance

CreateApplicationDataAction

Such actions should be located in a java package that also ends with .actions, for instance

package com.enactor.coreUI.actions;
public class CreateApplicationDataAction implements IUIAction {

Use UIActionFunctions for Input validation (JA-002)

For mandatory inputs, use UIActionFunctions.getRequiredDataItem()

// Bad
if (inputData.containsNotNullData(LISTED_ITEMS_LIST_DATA_NAME)) {
listedItemsList = (List<IModifiableItem>) inputData
.getData(LISTED_ITEMS_LIST_DATA_NAME);
} else {
throw new UIProcessException(UIProcessException.MISSING_DATA,
"The variable "+LISTED_ITEMS_LIST_DATA_NAME+" is required as an input");
}
// Good
listedItemsList = UIActionFunctions.getRequiredDataItem(inputData, LISTED_ITEMS_LIST_DATA_NAME);

If you need to get an optional parameter, use one the following

// Good
listedItemsList = UIActionFunctions.getOptionalDataItem(inputData, LISTED_ITEMS_LIST_DATA_NAME);
listedItemsList = UIActionFunctions.getOptionalDataItem(inputData, LISTED_ITEMS_LIST_DATA_NAME, defaultValue);

Action should be stateless (JA-003)

Define your variables inside the execute method of an action or inside other private methods and not as class member. The runtime engine can (although it doesn’t at the moment) re-use an instance of an action and we do not want side effect between execution.

public class MyAction implements IUIAction {

// Bad
List<String> MyList = new ArrayList<>();

public IApplicationProcessOutcome execute(...) {
// Good
List<String> MyList = new ArrayList<>();
...
}
}