I am not able to pass the data from one page to other page to display some values coming from first page to second page.
Visualforce Page1
<apex:page controller="wrapCustomObj">
<apex:form >
<apex:pageBlock title="Employee Details">
<apex:pageBlockSection title="List of Employee" id="details">
<apex:pageBlockTable value="{!empDetails}" var="e">
<apex:column >
<apex:inputCheckbox value="{!e.selected}"/>
</apex:column>
<apex:column value="{!e.empDet.name}"/>
<apex:column value="{!e.empDet.Salary__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!previous}" value="Previous" reRender="details"/>
<apex:commandButton action="{!next}" value="Next" reRender="details"/>
<apex:commandButton action="{!fPage}" value="First Page" reRender="details"/>
<apex:commandButton action="{!lPage}" value="Last Page" reRender="details"/>
</apex:pageBlockButtons>
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!DisplayDetails}" value="Details"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Visualforce Page2
<apex:page controller="wrapCustomObj">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!SelectEmpDetails}" var="e">
<apex:column value="{!e.empDet.name}"/>
<apex:column value="{!e.empDet.Salary__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Controller
public with sharing class wrapCustomObj {
public Integer limitSize=5;
public Integer OffsetSize=0;
public Integer totalRecs=0;
public List<employee__c> selectedEmp;
public List<employee__c> getSelectedEmp()
{
selectedEmp=new List<employee__c>();
if(selectedEmp.size()>0)
return selectedEmp;
else
return null;
}
public void lPage() {
OffsetSize=totalrecs-math.mod(totalRecs,limitSize);
}
public void fPage() {
OffsetSize=0;
}
public void next() {
OffsetSize=OffsetSize+limitSize;
}
public void previous() {
OffsetSize=OffsetSize-limitSize;
}
public PageReference DisplayDetails() {
PageReference reRend = new PageReference('/apex/wrapperCustomObjpage2');
reRend.setRedirect(false);
return reRend;
}
public List<wrapObj> wrpList{get;set;}
public List<wrapObj> selectedwrpList{get;set;}
public List<wrapObj> getEmpDetails() {
wrpList=new List<wrapObj>();
List<Employee__c> emps=[select id,name,salary__c from employee__c where salary__c !=null limit:limitSize Offset:OffsetSize];
totalRecs=[select count() from Employee__c];
for(Employee__c e:emps)
{
wrpList.add(new wrapObj(e,false));
}
return wrpList;
}
public List<wrapObj> getSelectEmpDetails()
{
selectedwrpList=new List<wrapObj>();
for(wrapObj w:getEmpDetails())
{
if(w.selected==true)
selectedwrpList.add(w);
}
return selectedwrpList;
}
public class wrapObj
{
public Employee__c empDet{get;set;}
public Boolean selected{get;set;}
public wrapObj(Employee__c emp,boolean check)
{
empDet=emp;
selected=check;
}
}
}
I am able to redirect to second page but i am not able to get the data from the first page. so it is displaying blanks rows and columns in pageBlocktable in second page. could any one figure me out where i am misleaded.
selectedwrpList
is always empty since thewrapObj.selected = false