When writing a controller for a Lightning Component, it is convenient to add the data transfer object classes as inner classes of the controller. This works fine for sending data to the client but I get a gack that includes a java.lang.UnsupportedOperationException when sending from client to server:
An internal server error has occurred\nError ID: 2066801247-4851 (-1600101374)\n\norg.auraframework.throwable.AuraExecutionException: apex://LifePaymentsController: java.lang.UnsupportedOperationException\n\tat .(apex://LifePaymentsController)\n\tat ui.services.facades.CoreLightningComponentFacadeImpl.runApexAction(CoreLightningComponentFacadeImpl.java:233) ...
Here is what the server-side looks like (the save1 method fails):
public class SaveRequest {
@AuraEnabled public Payee[] newPayees;
@AuraEnabled public Payment[] payments;
}
...
// Fails
@AuraEnabled
public static void save1(SaveRequest saveRequest) {
System.debug(JSON.serializePretty(saveRequest));
}
// Works
@AuraEnabled
public static void save2(String jsonString) {
SaveRequest r = (SaveRequest) JSON.deserializeStrict(jsonString, SaveRequest.class);
System.debug(JSON.serializePretty(r));
}
and the client-side:
// Fails
var action = servicesComponent.get("c.save1")
action.setParams({
"saveRequest": saveRequest
});
// Works
var action = servicesComponent.get("c.save2");
action.setParams({
"jsonString": JSON.stringify(saveRequest)
});
The save2 alternative method (where deserialization is explicitly coded) works.
I interpret these results to mean that inner classes are still (April 2017) not fully supported in @AuraEnabled methods. Is that the case?