You need to sign in to do that
Don't have an account?
santhi sanapala 5
details not visible
hi ,
i've written a code to show account details but its not working.kindly help as it is not throwing any error and there is also data in list<Account> in apex class.
Vf code :
<apex:page controller="accountInformation">
<apex:pageblock title="Accounts" >
<!--
<apex:repeat value="{!accs}" var="a">
<apex:pageblocksection >
<apex:outputlabel value="{!a.Name}"/>
<apex:outputfield value="{!a.Phone}"/>
<apex:outputfield value="{!a.Active__c}"/>
<apex:outputfield value="{!a.CleanStatus}"/>
</apex:pageblocksection>
</apex:repeat>
-->
<apex:pageblockTable value="{!accs}" var="a">
<apex:column value="{!a.Name}"/>
<apex:column value="{!a.Phone}"/>
<apex:column value="{!a.Active__c}"/>
<apex:column value="{!a.CleanStatus}"/>
</apex:pageblockTable>
</apex:pageblock>
</apex:page>
apex class:
public class accountInformation {
public list<Account> accs{ get; set;}
public list<Account> getAccounts(){
accs=[select Name,Phone,Active__c,CleanStatus from Account];
system.debug('Account info:'+accs);
return accs;
}
}
i've written a code to show account details but its not working.kindly help as it is not throwing any error and there is also data in list<Account> in apex class.
Vf code :
<apex:page controller="accountInformation">
<apex:pageblock title="Accounts" >
<!--
<apex:repeat value="{!accs}" var="a">
<apex:pageblocksection >
<apex:outputlabel value="{!a.Name}"/>
<apex:outputfield value="{!a.Phone}"/>
<apex:outputfield value="{!a.Active__c}"/>
<apex:outputfield value="{!a.CleanStatus}"/>
</apex:pageblocksection>
</apex:repeat>
-->
<apex:pageblockTable value="{!accs}" var="a">
<apex:column value="{!a.Name}"/>
<apex:column value="{!a.Phone}"/>
<apex:column value="{!a.Active__c}"/>
<apex:column value="{!a.CleanStatus}"/>
</apex:pageblockTable>
</apex:pageblock>
</apex:page>
apex class:
public class accountInformation {
public list<Account> accs{ get; set;}
public list<Account> getAccounts(){
accs=[select Name,Phone,Active__c,CleanStatus from Account];
system.debug('Account info:'+accs);
return accs;
}
}
Please find the below code. I have modified your code little bit.
Hope this helps. Mark this as your best answer if this resolves your query.
Regards,
Avishek Nanda
All Answers
Please find the below code. I have modified your code little bit.
Hope this helps. Mark this as your best answer if this resolves your query.
Regards,
Avishek Nanda
Thank you, your code has worked !!!.
But after i removed soql query from function and placed in constructor (in my code) then only it worked.
please explain me why vf page couldn't fetch accs records from a method when it could fetch accs records successfully from a constructor. Is there any particular reason? or is there anything i have missed in the method.
Regards,
Santhi
Get method should not be used lyk that. Get method itself return value. U don't need separate variable and And it depends how u call from vf page.
Please Check this link https://www.tutorialkart.com/learn_apex/visualforce-getter-method-and-setter-method which will give you a details idea.
Regards,
Avishek Nanda