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

navigate list view error
Hello
I have created visual force page to navigate the account list view.
when I execute I get error"attempt to deference a null object"
pls le tme know eeher I am going wrong.
I have created visual force page to navigate the account list view.
when I execute I get error"attempt to deference a null object"
pls le tme know eeher I am going wrong.
public class ListViewDemo { string basequery='Select ID, Name FROM Account ORDER BY NAME ASC'; private Integer pageSize = 10; public String AccFilterId {get; set;} public ListViewDemo(){} public ApexPages.StandardSetController AccSetController //this is a property { get { if (AccSetController == null) { ApexPages.StandardSetController AccSetController=new ApexPages.StandardSetController(Database.getQueryLocator(basequery)); AccSetController.setPageSize(pageSize); if (AccFilterId != null) { AccSetController.setFilterID(AccFilterId); } } return AccSetController; } set; } public ListViewDemo(ApexPages.StandardSetController c) { } //Navigate to first Page public void firstPage() { AccSetController.first(); } //Navigate to last Page public void lastPage() { AccSetController.last(); } //Navigate to Next page public void next() { if(AccSetController.getHasNext()) { AccSetController.next(); } } //Navigate to Prev Page public void prev() { if(AccSetController.getHasPrevious()) { AccSetController.previous(); } } public SelectOption[] getAccountExistingViews() { return AccSetController.getListViewOptions(); } public List<Account> getAccounts() { return AccSetController.getRecords(); } public PageReference resetFilter() { AccSetController = null; AccSetController.setPageNumber(1); return null; } } <apex:page controller="ListViewDemo"> <apex:form id="pageForm"> <apex:selectList value="{!AccFilterId}" size="1" id="filterMenu"> <apex:selectOptions value="{!AccountExistingViews}"/> <apex:actionSupport event="onchange" action="{!resetFilter}" rerender="AccntTable" status="ajaxStatus"/> </apex:selectList> <apex:actionStatus id="ajaxStatus" startText="Loading..." stopText=""/> <apex:pageBlock title="Accounts"> <apex:pageBlockButtons> <apex:commandButton action="{!firstPage}" value="|<<" reRender="AccntTable" status="ajaxStatus"/> <apex:commandButton action="{!prev}" value="<" reRender="AccntTable" status="ajaxStatus" /> <apex:commandButton action="{!next}" value=">" reRender="AccntTable" status="ajaxStatus" /> <apex:commandButton action="{!lastPage}" value=">>|" reRender="AccntTable" status="ajaxStatus" /> </apex:pageBlockButtons> <apex:pageBlockTable value="{!Accounts}" var="item" id="AccntTable"> <apex:column value="{!item.ID}"/> <apex:column value="{!item.Name}"/> <apex:column value="{!item.Phone}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
All Answers
But I want to call this page in Account, List view i.e I want to add a custom button, content source= name of visual force page.
But I am not able to see the vf page in content.
I got the answer. In VF page we need to have a standard controller with extension class.
Also we need to use recordSetVar attribute.