Feature Overview
This feature converts a static method into an Action.
This feature converts a static method into an Action.
You need to include Action.apex if you want to enable this feature.
public class ActionDemo {
/**
* Some descriptions
*
* @param a The first number
* @param b The second number
* */
@AuraEnabled
@action
public static Integer add(Integer a, Integer b) {
return a + b;
}
}
public class ActionDemo {
private static Action.Registry registry = new Action.Registry();
static {
registry.action(new AddAction());
}
@AuraEnabled
public static Object invoke(String name, Map args) {
return registry.invoke(name, args);
}
@AuraEnabled
public static Map apiDescriptorForLightning() {
return registry.actions;
}
/**
* Some descriptions
*
* @param a The first number
* @param b The second number
* */
private class AddAction extends Action {
public AddAction() {
super('add');
param('a', Integer.class, 'The first number');
param('b', Integer.class, 'The second number');
}
public override Object execAction(Object arg0, Object arg1) {
Integer a = (Integer)arg0;
Integer b = (Integer)arg1;
return a + b;
}
}
}
@action
can only be used on public/global static methods with @AuraEnabled
.
Some variations are:
Example | Description |
---|---|
@action | Convert this method to Action |
@action(true) | Convert this method to Action and set returnRaw(true) |
@action(returnRaw=true) | Convert this method to Action and set returnRaw(true) |
Contribute on Github! Edit this section.