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

Getting Error 'List controllers are not supported for Profile'
Hi, I am trying to build a page which supports pagination and displaying list of Accounts with check boxes. The user can select multiple check boxes across the pages and on save we have to process all the selected Accounts. For this i have used a wrapper class and also i am able to select multiple accounts and perform any operation on it. But the same code if i doing it for Profile object i am facing error as 'List controllers are not supported for Profile'. Can any body help me out with this. Thanks!
Code looks like this
<apex:page controller="PagingController">
<apex:form >
<apex:iframe height="100" scrolling="true" width="100"/>
<!--This block is for Search functionality
<apex:pageBlock id="Profile">
<apex:pageBlockSection columns="1" collapsible="false">
<apex:panelGrid >
<apex:panelGroup >
<apex:outputLabel value="Profile Search"></apex:outputLabel>
<apex:inputText id="txtSearch" value="{!aName}" />
<apex:commandButton id="btnSearch" value="Search" action="{!search}"/>
</apex:panelGroup>
</apex:panelGrid>
</apex:pageBlockSection>
</apex:pageBlock>-->
<!--Paging functionality -->
<apex:pageBlock title="Paging through Categories of Stuff">
<apex:pageBlockButtons location="top">
<apex:commandButton action="{!process}" value="Process Selected"/>
<apex:commandButton action="{!cancel}" value="Cancel"/>
</apex:pageBlockButtons>
<apex:pageMessages />
<apex:pageBlockSection title="Category Results - Page #{!pageNumber}" columns="1">
<apex:pageBlockTable value="{!categories}" var="c">
<apex:column width="50px">
<apex:facet name="header">Select</apex:facet>
<apex:inputCheckbox value="{!c.checked}"/>
</apex:column>
<apex:column value="{!c.cat.Name}" headerValue="Name"/>
<apex:column value="{!c.cat.Type}" headerValue="Type"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<!--Paging footer -->
<apex:panelGrid columns="4">
<apex:commandLink action="{!first}">First</apex:commandlink>
<apex:commandLink action="{!previous}" rendered="{!hasPrevious}">Previous</apex:commandlink>
<apex:commandLink action="{!next}" rendered="{!hasNext}">Next</apex:commandlink>
<apex:commandLink action="{!last}">Last</apex:commandlink>
</apex:panelGrid>
<!--Existing profiles
<apex:pageBlock id="ExistingProfiles" title="Existing Profiles">
<apex:pageBlockButtons location="top">
<apex:commandButton action="{!deleteselected}" value="Delete"/>
<apex:commandButton action="{!cancel}" value="Cancel"/>
</apex:pageBlockButtons>
<apex:pageMessages />
<apex:pageBlockSection title="Existing Profiles for this account" columns="1">
<apex:pageBlockTable value="{!categories}" var="account">
<apex:column >
<apex:facet name="header">Remove</apex:facet>
<apex:inputCheckbox value="{!account.checked}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Name</apex:facet>
<apex:outputPanel >{!account.cat.name}</apex:outputPanel>
</apex:column>
<apex:column >
<apex:facet name="header">Type</apex:facet>
<apex:outputPanel >{!account.cat.Type}</apex:outputPanel>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock> -->
</apex:form>
</apex:page>
--Controller
public with sharing class PagingController
{
public PageReference deleteselected() {
return null;
}
public string aName;
public string getaName()
{
return aName;
}
public void setaName(string b)
{
aName=b;
}
public PageReference process()
{
system.debug('entered process...');
for (CategoryWrapper cw : categories)
{
system.debug('Selected : ' + cw.checked);
if(!CategoryWrapper.contains(cw.cat.Id))
{
if (cw.checked == true)
{
CategoryWrapper.add(cw.cat.Id);
CategoryWrapperList.add(cw.cat);
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,cw.cat.name));
}
}
else if(CategoryWrapper.contains(cw.cat.Id))
{
CategoryWrapper.remove(cw.cat.Id);
system.debug('CategoryWrapper.Size():' +categories.size());
for(integer i=0;i<categories.size();i++)
{
if(cw.checked == false && CategoryWrapper.contains(cw.cat.Id))
{
CategoryWrapperList.remove(i);
}
}
//CategoryWrapperList.remove(cw.cat.Id);
}
}
System.debug('These are the selected set...' + CategoryWrapper);
system.debug('These are selected List...' + CategoryWrapperList);
for(Account a : CategoryWrapperList)
{
system.debug('Ready Accounts..' + CategoryWrapperList);
system.debug('Ready for updation...');
update a;
}
return null;
}
List<categoryWrapper> categories {get;set;}
// instantiate the StandardSetController from a query locator
public ApexPages.StandardSetController con
{
get
{
if(con == null)
{
con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, Name,Type FROM Account Order By Name limit 20]));
//String strQuery = 'select Id, Name, Type from Account where Name like \'%'+aName+'%\'';
//con = new ApexPages.StandardSetController(Database.Query(strQuery));
// sets the number of records in each page set
con.setPageSize(5);
}
return con;
}
set;
}
// returns a list of wrapper objects for the sObjects in the current page set
public List<categoryWrapper> getCategories()
{
system.debug('Entereed getcategories...');
categories = new List<categoryWrapper>();
for (Account category : (List<Account>)con.getRecords())
categories.add(new CategoryWrapper(category));
//Checking for Previous Page values and checking if the list contains tat id.
for(CategoryWrapper cm : categories)
{
system.debug('Inside Prevous loop');
//system.debug('Check if checked:' CategoryWrapper.contains(cm.cat.Id));
if(CategoryWrapper.contains(cm.cat.Id))
{
system.debug('cm checked:' + cm.checked);
if(cm.checked == false)
{
cm.checked = true;
system.debug('Check the value');
}
}
}
return categories;
}
// displays the selected items
Set<Id> CategoryWrapper = new Set<Id>();
Map<Id,Account> CategoryWrapperMap = new Map<Id,Account>();
List<Account> CategoryWrapperList = new List<Account>();
public PageReference process(String variable)
{
if(variable == 'next' || variable =='previous' || variable == 'first' || variable == 'last')
{
system.debug('entered next process...');
for (CategoryWrapper cw : categories)
{
system.debug('Selected : ' + cw.checked);
if (cw.checked == true)
{
if(!CategoryWrapper.contains(cw.cat.Id))
{
CategoryWrapper.add(cw.cat.Id);
//CategoryWrapperMap.put(cw.cat.Id,cw.cat);
CategoryWrapperList.add(cw.cat);
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,cw.cat.name));
}
}
else if(CategoryWrapper.contains(cw.cat.Id))
{
system.debug('CategoryWrapper.Size():' +categories.size());
for(integer i=0;i<categories.size();i++)
{
if(cw.checked == false && CategoryWrapper.contains(cw.cat.Id))
{
CategoryWrapperList.remove(i);
CategoryWrapper.remove(cw.cat.Id);
}
}
}
}
system.debug('Categories added..' +CategoryWrapper);
//system.debug('CategoriesMap added..' +CategoryWrapperMap);
system.debug('CategoryList added..' +CategoryWrapperList);
}
return null;
}
// indicates whether there are more records after the current page set.
public Boolean hasNext
{
get
{
return con.getHasNext();
}
set;
}
// indicates whether there are more records before the current page set.
public Boolean hasPrevious
{
get
{
return con.getHasPrevious();
}
set;
}
// returns the page number of the current page set
public Integer pageNumber
{
get
{
return con.getPageNumber();
}
set;
}
// returns the first page of records
public void first()
{
system.debug('Entered first...');
process('first');
con.first();
}
// returns the last page of records
public void last()
{
system.debug('Entered Last...');
process('last');
con.last();
}
// returns the previous page of records
public void previous()
{
system.debug('Entered previous...');
process('previous');
con.previous();
}
// returns the next page of records
public void next()
{
system.debug('Entered Next...');
//getCategories();
process('next');
con.next();
}
// returns the PageReference of the original page, if known, or the home page.
public void cancel()
{
con.cancel();
}
public class CategoryWrapper
{
public Boolean checked{ get; set; }
public Account cat { get; set;}
public CategoryWrapper()
{
cat = new Account();
;
}
public CategoryWrapper(Account c)
{
cat = c;
;
}
}
}