I have the simple app which multiplies Decimal
number a
on Integer
number b
.
The simple app has the following code:
<aura:application controller="ReproduceIssueController" >
<aura:attribute name="aa" type="Decimal" default="0.15" description="Decimal number a"/>
<aura:attribute name="bb" type="Integer" default="10" description="Integer number b"/>
<aura:attribute name="cc" type="Decimal" description="Decimal number a"/>
<lightning:input type="number" step="0.01" label="Decimal Number A" value="{!v.aa}"/>
<lightning:input type="number" step="1" label="Integer number B" value="{!v.bb}"/>
<lightning:button variant="brand" label="Multiply" onclick="{! c.m }" />
<br/>
Multiplication result <ui:outputText value="{!v.cc}" />
</aura:application>
The app has the following Javascript controller
({
m : function(component, event, helper) {
var action = component.get("c.mu");
action.setParams( {
a : component.get("v.aa"),
b : component.get("v.bb")
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
component.set('v.cc', response.getReturnValue() );
alert("From server: " + response.getReturnValue());
}
else if (state === "INCOMPLETE") {
// do something
}
else if (state === "ERROR") {
var errors = response.getError();
if (errors) {
if (errors[0] && errors[0].message) {
console.log("Error message: " +
errors[0].message);
}
} else {
console.log("Unknown error");
}
}
});
$A.enqueueAction(action);
}
})
and the following Apex Server-side controller
public class ReproduceIssueController {
@auraEnabled
public static Decimal mu(Decimal a, Integer b){
return a * b;
}
}
When I try to execute it I see the following error messages in Javascript
Error message: An internal server error has occurred Error ID: 109932382-3746 (119852647) and the following error in Developer Console logs
System.UnexpectedException: Illegal arguments
Class.ReproduceIssueController.mu: line 4, column 1
Apparently it fails on multiplication line but it is not clear why.
Cannot Lightning handle and pass numbers correctly? Do we have to pass only strings between the Lightning front end application and Apex Server-side controller?