You need to sign in to do that
Don't have an account?

getting in while using map in visualforce page
hi, i am getting this error while saving the code in visualforce page. This error is caused due to of "{!accts[a].name}" in VF apge.
Error:-
Error: /apex/retunrtype: java.lang.NullPointerException
Error: null
Error:-
Error: /apex/retunrtype: java.lang.NullPointerException
Error: null
<apex:page controller="allaccountslist"> <apex:repeat value="{!accts}" var="a"> {!a.id}............... {!accts[a].name} <br/><br/> </apex:repeat> </apex:page>
public class allaccountslist { public list<sobject> getaccts () { list<sobject> acc= [select id,name from account limit 20]; return acc; }}
Accts is list not map So got the value from List you need to pass the index in Number not in ID. Like below
Option 1:- Value from List
Try below code if you want to get value from index.
Option 2:- If you want to use Map then
Change your class like below :- return type should me Map<Id,Account>
Page lik below
Please let us know if this will help you
Thanks
Amit Chaudhary