public class PagingControllerforCase { public list<categoryWrapper> wrapaccountList { get; set; } List<categoryWrapper> categories {get;set;} public list<Case> selectedAccounts{get;set;} // instantiate the StandardSetController from a query locator
public PagingControllerforCase() { wrapaccountList =new list<categoryWrapper>(); for(Case a:[select id from case limit 10]){ wrapaccountlist.add(new categoryWrapper(a));
} }
public ApexPages.StandardSetController con { get { if(con == null) { con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id FROM Case limit 100])); // 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() { categories = new List<categoryWrapper>(); for (Case category : (List<Case>)con.getRecords()) categories.add(new CategoryWrapper(category));
return categories; }
// 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() { con.first(); }
// returns the last page of records public void last() { con.last(); }
// returns the previous page of records public void previous() { con.previous(); }
// returns the next page of records public void next() { con.next(); }
// returns the PageReference of the original page, if known, or the home page. public void cancel() { con.cancel(); }
public void ProcessSelected(){ selectedAccounts=new list<Case>();
public Boolean checked{ get; set; } public Case cat { get; set;}
public CategoryWrapper(){ cat = new Case(); checked = false; }
public CategoryWrapper(Case c){ cat = c; checked = false; }
}}
my problem is I selected 3 records in first page show it in one pageblocktable after that i clicked next button again i selcted two records and displayed in same pageblocktable but only recent record appear , but i need all selected record in one pageblocktable.
Hi satheesh what i found is ur not storing values in any variable, if u store values using javascript/jquery u can easily display all selected records in pageblocktable
please help me , how to use javascript here ,could you please give me code for that , NOTE: i am also thinking same way but i don't know how to write code .
please give me solution very ugent. Thanks Satheesh
<apex:page controller="PagingControllerforCase">
<apex:form >
<apex:pageBlock title="Paging through Categories of Stuff">
<apex:pageBlockButtons location="top">
<apex:commandButton action="{!ProcessSelected}" value="Show Selected accounts" reRender="block2"/>
<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="25px">
<apex:inputCheckbox value="{!c.checked}"/>
</apex:column>
<apex:column value="{!c.cat.id}" headerValue="ID"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<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>
<apex:pageBlock >
<apex:pageBlockTable value="{!selectedAccounts}" var="sa" id="block2">
<apex:column value="{!sa.Id}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
apex:
public class PagingControllerforCase {
public list<categoryWrapper> wrapaccountList { get; set; }
List<categoryWrapper> categories {get;set;}
public list<Case> selectedAccounts{get;set;}
// instantiate the StandardSetController from a query locator
public PagingControllerforCase()
{
wrapaccountList =new list<categoryWrapper>();
for(Case a:[select id from case limit 10]){
wrapaccountlist.add(new categoryWrapper(a));
}
}
public ApexPages.StandardSetController con {
get {
if(con == null) {
con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id FROM Case limit 100]));
// 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() {
categories = new List<categoryWrapper>();
for (Case category : (List<Case>)con.getRecords())
categories.add(new CategoryWrapper(category));
return categories;
}
// 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() {
con.first();
}
// returns the last page of records
public void last() {
con.last();
}
// returns the previous page of records
public void previous() {
con.previous();
}
// returns the next page of records
public void next() {
con.next();
}
// returns the PageReference of the original page, if known, or the home page.
public void cancel() {
con.cancel();
}
public void ProcessSelected(){
selectedAccounts=new list<Case>();
for(CategoryWrapper wrapobj:categories )
{
if(wrapobj.checked==true)
{
selectedAccounts.add(wrapobj.cat);
}
}
System.debug('@@@@@@'+selectedAccounts);
update selectedAccounts;
wrapaccountList=null;
}
public class CategoryWrapper {
public Boolean checked{ get; set; }
public Case cat { get; set;}
public CategoryWrapper(){
cat = new Case();
checked = false;
}
public CategoryWrapper(Case c){
cat = c;
checked = false;
}
}}
my problem is I selected 3 records in first page show it in one pageblocktable after that i clicked next button again i selcted two records and displayed in same pageblocktable but only recent record appear , but i need all selected record in one pageblocktable.
Thanks
Satheesh
please help me , how to use javascript here ,could you please give me code for that ,
NOTE: i am also thinking same way but i don't know how to write code .
please give me solution very ugent.
Thanks
Satheesh