I have created simple vf component with its own controller but apparently you can not have vf component controller to call any soql and I have tried the following code below and does not show any count in the vf component and is that even possible to have something below? if yes then what i'm doing wrong here?
Class:
public class myComponentController
{
public List<Account> myAccounts {get;set};
public String myComponentController() {
myAccounts = [SELECT Name FROM Account LIMIT 10];
}
}
Component Page:
<apex:component controller="myComponentController">
<apex:pageBlock title="My Custom Component">
<p>
<code>Account</code> is "{!myAccounts.size}"
</p>
</apex:pageBlock>
</apex:component>
If that above is not possible then I know the other way that you send through <apex:attribute....
but i was curious to know why the above option is not available.