I have a component that gets an instance custom Apex Class as an attribute, ie:
<apex:component controller="ComponentController"> <apex:attribute name="myAttr" assignTo="{!attr}" type="MyApexClass" /> </apex:component>
I also have this class:
public with sharing class MyApexClass{ //lots of content }
But, since I updated Eclipse to the latest version (Summer ’14, API version 31) I get this error when I try to save the component (or a page on which the component is used):
Compilation error: Type is not visible: myapexclass
.I’ve already tried making MyApexClass global, doing so does solve the problem, however, this is for managed package so I really want to avoid making anything global that doesn’t logically have to be, especially because it does work if I use Eclipse for version 30.
Answer
Please Find the solution.
<apex:attribute name="myAttr" assignTo="{!attr}" type="MyApexClass" />
In this line attribute type should be object then it would work fine
you can take reference from my code;
aura component
<apex:component controller="ComponentController">
<aura:attribute name="check" type="object" description="" access="public"/>
<h1>"{!v.check.accountList[0].Name}"</h1>//showing data
</apex:component>
controller or helper
var wrapperList=response.getReturnValue();
c.set("v.check",wrapperList)
//apex class
public class Test {
public with sharing class wrapperList{
@auraEnabled
public List<Account> accountList;
}
@auraEnabled
public static wrapperList containerofList(){
wrapperList obj=new wrapperList();
list<Account> aclist = new list<Account>();
aclist = [Select id,name from account limit 20];
obj.accountList=aclist;
return obj;
}
}
Attribution
Source : Link , Question Author : rael_kid , Answer Author : nbrown