Blogs
We can trigger our custom action while performing operations in Objects by implementing ObjectActionExecutor interface.
Step 1: Create a class anywhere or create a module with
service template.
Below code for reference:
@Component
(
immediate = true,
service =
ObjectActionExecutor.class
)
public class
CustomActionExecutor implements ObjectActionExecutor {
@Override
public void execute(long companyId,
UnicodeProperties parametersUnicodeProperties, JSONObject
payloadJSONObject,
long userId) throws Exception {
logger.info("UnicodeProperties: " +
parametersUnicodeProperties);
logger.info("Payload
json: " + payloadJSONObject);
}
@Override
public String getKey() {
return "myCustomObjectAction";
}
private static final Log logger =
LogFactoryUtil.getLog(CustomActionExecutor.class);
}
Step 2: Now Go to Control Panel > Objects > Any object > Actions > New Action > Action Builder as shown below, Select your action name (myCustomObjectAction in my case).
Step 3: Now you can perform POST/GET or read/write operations on the Object as you will get all the entries in payloadJSONObject. Now, you can perform an action using the payloadJSON object as you will get the entry in it.
Basically, Objects is a dynamic entity and a new feature
which is available in both EE and CE since Liferay 7.4.