You need to sign in to do that
Don't have an account?
Trailhead: Apex components
I am having issues saving the following Lightning component as part of the Using Apex in Components:
-Given an existing Apex class that can be found here, create a component that displays the case's subject, description and status.The component must be named 'DisplayCase'.
-The component must refer to the 'DisplayCaseController' Apex class. Copy and paste that class into your Developer Edition using the Developer Console.
-The component must have an attribute named 'record' to hold the Case record.
-The component must display the Subject, Description, and Status values of the 'record' attribute.
-The client-side controller for the component must bind to the 'getCaseFromId' method of the Apex controller to fetch the value of a Case record.
-Note that while the Apex class accepts a null and returns a default case, there are various ways to hand the ID to the controller.
FIELD_INTEGRITY_EXCEPTION
Failed to save undefined: No ATTRIBUTE named label found: Source
Component:
I'm not sure what the issue is. Help...
Controller:
-Given an existing Apex class that can be found here, create a component that displays the case's subject, description and status.The component must be named 'DisplayCase'.
-The component must refer to the 'DisplayCaseController' Apex class. Copy and paste that class into your Developer Edition using the Developer Console.
-The component must have an attribute named 'record' to hold the Case record.
-The component must display the Subject, Description, and Status values of the 'record' attribute.
-The client-side controller for the component must bind to the 'getCaseFromId' method of the Apex controller to fetch the value of a Case record.
-Note that while the Apex class accepts a null and returns a default case, there are various ways to hand the ID to the controller.
FIELD_INTEGRITY_EXCEPTION
Failed to save undefined: No ATTRIBUTE named label found: Source
Component:
<aura:component Controller="DisplayCaseController"> <aura:attribute name="record" type="Case[]"/> <ui:button label="Get Cases" press="{!c.getCaseFromId}"/> <ui:outputText Label="Case Subject:" value="{!case.Subject}"/><br/> <ui:outputText Label="Case Description:" value="{!case.Description}"/><br/> <ui:outputText Label="Case Status:" value="{!case.Status}"/><br/> </aura:component>
I'm not sure what the issue is. Help...
Controller:
({ getCaseFromId: function(component){ var action = component.get("c.getCases"); action.setCallback(this, function(a){ component.set("v.record", a.getReturnValue()); }); $A.enqueueAction(action); } })
Sandeep Bhanot
Salesforce.com
Try <ui:outputText value="{!case.Subject}"/><br/>
As I experienced label is recognised in inputText but not in outputText.
Furthermore the Apex Controller is getCaseFromId and not getCase and it returns a case and not a list of cases so you would had better results with :
<aura:attribute name="record" type="Case"/>
and with : var action = component.get("c.getCaseFromId");
You need also an another attribute to pass an Id as a parameter which is expected by the apex server side controller.
If this answers your question, please be sure to mark this as the correct answer. Thank you.
I am also facing same issue .Is there any solution for this.
- Associate the component to some othere APEX controller that had been used for other component
ex) controller="AccountHandler"
- Then re-associate the component to DisplayCaseController
ex) controller="NS.DisplayCaseController"
DisplayCase.cmp
<aura:component controller="DisplayCaseController">
<aura:attribute name="record" type="Case[]"/>
<aura:iteration items="{!v.record.Subject}" var="c">
{!c.Subject}, {!c.Description}, {!c.Subject}, {!c.Status }
</aura:iteration>
<aura:iteration items="{!v.record.Description}" var="c">
{!c.Subject}, {!c.Description}, {!c.Subject}, {!c.Status }
</aura:iteration>
<aura:iteration items="{!v.record.Status}" var="c">
{!c.Subject}, {!c.Description}, {!c.Subject}, {!c.Status }
</aura:iteration>
</aura:component>
DisplayCaseController.js
({
getRecord: function(cmp){
var action = cmp.get("c.getCaseFromId");
action.setCallback(this, function(response){
var state = response.getState();
console.log(state);
if (state === "SUCCESS") {
cmp.set("v.record.Subject", response.getReturnValue());
}
});
$A.enqueueAction(action);
}
})
Hope it will help you.