You need to sign in to do that
Don't have an account?
SaintMichael
Custom Controllers not working
Trying to do soe simple data querying and show to visualforce page.
Here is the VisualForce page:
<apex:page controller="MyController" > <apex:pageBlock title="Accounts"> <apex:outputPanel > <apex:dataTable value="{!myAccounts}" var="aAccount" width="100%" > <apex:column > <apex:facet name="header"><b>Id</b></apex:facet> {!aAccount.Id} </apex:column> <apex:column > <apex:facet name="header"><b>Name</b></apex:facet> {!aAccount.Name} </apex:column> </apex:dataTable> </apex:outputPanel> </apex:pageBlock> </apex:page>
here is the custom controller 'MyController'
public class MyController { public List<Account> getMyAccounts(){ return [select Id, Name from Account]; } }
The column headers show up but the data is not coming in. I do have records, so not sure why this isn't working?
Ok, so the problem was I was testing using the real site url. I used the url that is shown
when using editing the apex class and visualforce pages instead of the real/public site url.
Duh!
All Answers
You can put debug statement inside method and check how many record has been return by the query.
I dont see any flaw in code.
I took your code verbatim and it worked just fine. Are you seeing any error messages? If not I would suggest building your Visualforce page a piece at a time. eg: just loop through the results, then add them to a table etc.
Ok, so the problem was I was testing using the real site url. I used the url that is shown
when using editing the apex class and visualforce pages instead of the real/public site url.
Duh!