I have created a VF page where i have create data table on the head i have a select all check box which check all the current records shown on the VF page. I have defined a action support which work on change and call a method. The action support is calling the method on change but the check box on UI not displaying as checked. I was using wrapper class for displaying the records on my VF page but due to some issue on pagination standardsetcontroller i created check box field on my object and now i am displaying check box there. Before i was using wrapper class to display, it was working fine but now checkbox is not getting updated on UI. Please guide me what is getting wrong on my VF page. VF page :
<apex:page standardController="Vendor_Registration__c" extensions="VendorVerificationExt" sidebar="false" showHeader="false" >
<apex:stylesheet value="{!URLFOR($Resource.bootstrap,'/css/bootstrap.css')}" />
<apex:stylesheet value="{!URLFOR($Resource.bootstrap,'/css/bootstrap-responsive.css')}" />
<apex:form style="background-color:#D8D8D8">
<div class="container">
<div class="row-fluid">
<apex:pageBlock >
<apex:pageMessages id="msg"></apex:pageMessages>
<table align="right"><tr>
<td align="right" ><a href="/home/home.jsp" id = "home"><apex:image value="{!$Resource.Home}" title="Home" height="40" width="50" /></a></td>
</tr></table>
<br/>
<br/>
<center><b><font size="5" color="#173B0B" face="monotype corsiva"><u>Verification Screen</u></font></b></center>
<br/>
<center> <apex:outputpanel rendered="{!ShowVerificationBlock == false}">
Temp Reg Number <apex:inputText value="{!EnterRegisId}" label="Temp Reg Number "/><br/><br/>
Vendor Name <apex:inputfield value="{!Vendor_Registration__c.Vendor_Name__c}"/>
</apex:outputpanel>
</center><br/>
<center><apex:commandButton value="Search" action="{!search}" rerender="msg,PB,btnID" rendered="{!ShowVerificationBlock == false}"/></center>
<br/><br/>
<!--
<center>
<apex:outputPanel id="PB" >
<apex:datatable headerClass="hdr" columns="8" style="border: 2px solid black;background-color:#E6E6E6" frame="box" rules="all" value="{!wrapVendor_RegistrationList}" var="nvv" rendered="{!if(wrapVendor_RegistrationList.size > 0, true, false) && ShowVerificationBlock == false}" >
<apex:column headerValue="Select All" >
<apex:facet name="header" >
<apex:outputText value="Select All" /><apex:inputCheckbox value="{!selectall}" label="Select All">
<apex:actionSupport event="onchange" action="{!selectAll}" reRender="PB" />
</apex:inputCheckbox>
</apex:facet>
<apex:inputCheckbox value="{!nvv.select_vendor}" rendered="{!if(nvv.vendor_wapper_lst.Status__c == 'Verified', true, false)}"/>
</apex:column>
<apex:column headerValue="Temp Reg No" >
<apex:outputLink value="/{!nvv.vendor_wapper_lst.id}" id="contactLink" target="__blank">{!nvv.vendor_wapper_lst.name}</apex:outputLink>
</apex:column>
<apex:column headerValue="Name" >
<apex:outputField value="{!nvv.vendor_wapper_lst.Vendor_Name__c}"/>
</apex:column>
<apex:column headerValue="Area of Operation" >
<apex:outputField value="{!nvv.vendor_wapper_lst.Area_of_Operation__c}"/>
</apex:column>
<apex:column headerValue="Phone No:" >
<apex:outputField value="{!nvv.vendor_wapper_lst.Phone_Number_1__c}"/>
</apex:column>
<apex:column headerValue="Status" >
<apex:outputField value="{!nvv.vendor_wapper_lst.Status__c}"/>
</apex:column>
<apex:column headerValue="Start Verification">
<apex:commandLink value="Click to Verify" action="{!showVerificationVendor}" rendered="{!nvv.vendor_wapper_lst.Status__c <> 'Verified'}" target="__Blank">
<apex:param value="{!nvv.vendor_wapper_lst.name}" name="Nam" assignTo="{!SelectedVendor}"/>
</apex:commandLink>
</apex:column>
<apex:column headerValue="Perm Reg No">
<apex:outputField value="{!nvv.vendor_wapper_lst.Permanent_Registration_ID__c}"/>
</apex:column>
</apex:datatable>
<apex:outputPanel rendered="{!if(NonVerifiedVendors.size > 0, true, false)}" >
<apex:commandButton value="<<" rerender="PB" action="{!FirstPage}" disabled="{!prev}"/>
<apex:commandButton value="<" rerender="PB" action="{!previous}" disabled="{!prev}"/>
<apex:commandButton value=">" rerender="PB" action="{!next}" disabled="{!nxt}"/>
<apex:commandButton value=">>" rerender="PB" action="{!LastPage}" disabled="{!nxt}"/>
<br/>
<br/>
<br/>
<br/>
<apex:commandButton value="Generate Id Cards" action="{!GenerateIdCards}" />
</apex:outputPanel>
</apex:outputPanel>
--
<!--
<apex:outputPanel rendered="{!if(NonVerifiedVendors.size > 0, true, false)}" id="btnID" >
<apex:commandButton value="<<" rerender="PB" action="{!FirstPage}" />
<apex:commandButton value="<" rerender="PB" action="{!previous}" />
<apex:commandButton value=">" rerender="PB" action="{!next}" />
<apex:commandButton value=">>" rerender="PB" action="{!LastPage}" />
</apex:outputPanel>
-->
<!-- </center> -->
<center>
<apex:outputPanel id="PB" >
<apex:datatable headerClass="hdr" columns="8" style="border: 2px solid black;background-color:#E6E6E6" frame="box" rules="all" value="{!VendorRegistration}" var="nvv" rendered="{!if(NonVerifiedVendors.size > 0, true, false) && ShowVerificationBlock == false}" >
<apex:column headerValue="Select All" >
<apex:facet name="header" >
<apex:outputText value="Select All" />
<apex:inputCheckbox value="{!selectall}" label="Select All">
<apex:actionSupport event="onchange" action="{!selectAll}" reRender="PB" />
</apex:inputCheckbox>
</apex:facet>
<apex:inputCheckbox value="{!nvv.Selected__c}" rendered="{!if(nvv.Status__c == 'Verified', true, false)}"/>
</apex:column>
<apex:column headerValue="Temp Reg No" >
<apex:outputLink value="/{!nvv.id}" id="contactLink" target="__blank">{!nvv.name}</apex:outputLink>
</apex:column>
<apex:column headerValue="Name" >
<apex:outputField value="{!nvv.Vendor_Name__c}"/>
</apex:column>
<apex:column headerValue="Area of Operation" >
<apex:outputField value="{!nvv.Area_of_Operation__c}"/>
</apex:column>
<apex:column headerValue="Phone No:" >
<apex:outputField value="{!nvv.Phone_Number_1__c}"/>
</apex:column>
<apex:column headerValue="Status" >
<apex:outputField value="{!nvv.Status__c}"/>
</apex:column>
<apex:column headerValue="Start Verification">
<apex:commandLink value="Click to Verify" action="{!showVerificationVendor}" rendered="{!nvv.Status__c <> 'Verified'}" target="__Blank">
<apex:param value="{!nvv.name}" name="Nam" assignTo="{!SelectedVendor}"/>
</apex:commandLink>
</apex:column>
<apex:column headerValue="Perm Reg No">
<apex:outputField value="{!nvv.Permanent_Registration_ID__c}"/>
</apex:column>
</apex:datatable>
<apex:outputPanel rendered="{!if(NonVerifiedVendors.size > 0, true, false)}" >
<apex:commandButton value="|<<" rerender="PB" action="{!FirstPage}" disabled="{!hasprev}"/>
<apex:commandButton value="<" rerender="PB" action="{!previous}" disabled="{!hasprev}"/>
<apex:commandButton value=">" rerender="PB" action="{!next}" disabled="{!hasnxt}"/>
<apex:commandButton value=">>|" rerender="PB" action="{!LastPage}" disabled="{!hasnxt}"/>
<br/>
<br/>
<br/>
<br/>
<apex:commandButton value="Generate Id Cards" action="{!GenerateIdCards}" />
</apex:outputPanel>
</apex:outputPanel>
</center>
<!------ verification Panel---->
<center> <apex:outputpanel rendered="{!ShowVerificationBlock}" title="Enter Verification Details" style="left-margin:-8px">
<div style="width:40%;margin: auto; " >
<p style="text-align:left;"><span style=" width:50%; float:left;" >No. of persons on Job Location?</span> <apex:inputField style="width:auto; float:left;" value="{!VerificationInfo.No_of_persons_on_Job_Location__c}"/></p><br/><br/>
<p style="text-align:left;"><span style=" width:50%; float:left;" >Previous Work Information</span> <apex:inputField style="width:auto; float:left;" value="{!VerificationInfo.Previous_work_Information__c}"/></p><br/><br/>
<p style="text-align:left;"><span style=" width:50%; float:left;" >Submitted all required Documents?</span> <apex:inputField style="width:auto; float:left;" value="{!VerificationInfo.Submitted_all_required_Documents__c}"/></p><br/><br/>
<p style="text-align:left;"><span style=" width:50%; float:left;" >No. of Family members </span><apex:inputField style="width:auto; float:left;" value="{!VerificationInfo.No_of_Family_members__c}"/> </p> <br/><br/>
<center>
<p style="text-align:left;"><apex:commandButton value="Approve && Generate Permanent ID Card" rendered="{!ShowVerificationBlock}" action="{!ApproveAndIDCard}"/>
<apex:commandButton value="Reject" rendered="{!ShowVerificationBlock}" action="{!Reject}"/>
</p></center>
</div>
</apex:outputpanel>
</center>
<br/><br/>
</apex:pageBlock>
<apex:outputPanel styleClass="popupBackground" rendered="{!ShowRejectMessage}">
<apex:outputPanel styleClass="custPopup" rendered="{!ShowRejectMessage}">
<br/>
<center>Verification failed<br/><br/>
<apex:commandButton value="OK" action="javascript: parent.window.close();"/><br/><br/></center>
</apex:outputPanel>
</apex:outputPanel>
</div>
</div>
</apex:form>
<style>
.custPopup{
background-color: white;
Text-color: black;
border-width: 2px;
border-color: Black;
border-style: solid;
z-index: 9999;
left: 50%;
padding:2px;
position: absolute;
width: 250px;
margin-left: -50px;
top:150px;
}
.popupBackground{
background-color:black;
opacity: 0.90;
/* filter: alpha(opacity = 20); */
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 9998;
}
.hdr{
background-color:#21610B;
color: white;
text-align:left;
}
</style>
controller :
public with sharing class VendorVerificationExt {
public integer totalRecs = 0; // Total no of records
public integer OffsetSize {get; set;} // Offset Size
public integer LimitSize= 5; // Limit ot the number of records
public List<WrapperController> wrapVendor_RegistrationList {get; set;} // list of wrapper
public Set<Id> vendID = new Set<ID>(); // To hold all the id of the vendor's before pagination
public string vendor_ids = '';
public boolean selectall {get; set;}
public string EnterRegisId{get;set;}
public string EnterLocation{get;set;}
public string SelectedVendor{get;set;}
public boolean ShowVerificationBlock{get;set;}
public boolean ShowRejectMessage{get;set;}
public Vendor_Registration__c VendorInfo{get;set;}
public Vendor_Registration__c VerificationInfo{get;set;}
public list<Vendor_Registration__c> NonVerifiedVendors{get;set;}
public list<Vendor_Registration__c> NonVerifiedVendors_nolimt{get;set;}
public ApexPages.StandardSetController setCon {get; set;}
public List<Vendor_Registration__c> VendorRegistration ;
public List<Vendor_Registration__c> vrList = new List<Vendor_Registration__c >();
public List<Vendor_Registration__c> VendorRegistration_deepClone = new List<Vendor_Registration__c>();
public VendorVerificationExt(ApexPages.StandardSetController controller) {
}
public VendorVerificationExt(ApexPages.StandardController controller) {
VendorInfo = (Vendor_Registration__c)controller.GetRecord();
NonVerifiedVendors = new list<Vendor_Registration__c>();
NonVerifiedVendors_nolimt = new list<Vendor_Registration__c>();
VerificationInfo = new Vendor_Registration__c();
OffsetSize = 0;
wrapVendor_RegistrationList = new List<WrapperController>();
ShowVerificationBlock = false;
VendorRegistration = new List<Vendor_Registration__c>();
// setCon = new ApexPages.StandardSetController();
}
public void Search(){
wrapVendor_RegistrationList.clear();
NonVerifiedVendors_nolimt.clear();
NonVerifiedVendors.clear();
selectall = false;
//OffsetSize = 0;
SYSTEM.DEBUG('Offset Value before search ' + OffsetSize );
if(((EnterRegisId <> null && EnterRegisId <> '')) && (VendorInfo.Vendor_Name__c <> null && VendorInfo.Vendor_Name__c <> '')){
NonVerifiedVendors_nolimt = [select Selected__c, Permanent_Registration_ID__c,id,name,Vendor_Name__c,Status__c,Phone_Number_1__c,Phone_Number_2__c,Email_If_Any__c,Area_of_Operation__c,Home_Address__c,Verified_By__c from Vendor_Registration__c where name like :'%'+EnterRegisId +'%' AND Vendor_Name__c Like : '%'+VendorInfo.Vendor_Name__c+'%'];
}else if((EnterRegisId <> null && EnterRegisId <> '')){
NonVerifiedVendors_nolimt = [select Selected__c, Permanent_Registration_ID__c,id,name,Vendor_Name__c,Status__c,Phone_Number_1__c,Phone_Number_2__c,Email_If_Any__c,Area_of_Operation__c,Home_Address__c,Verified_By__c from Vendor_Registration__c where name like :'%'+EnterRegisId +'%' ];
}else if((VendorInfo.Vendor_Name__c <> null && VendorInfo.Vendor_Name__c <> '')){
NonVerifiedVendors_nolimt = [select Selected__c, Permanent_Registration_ID__c,id,name,Vendor_Name__c,Status__c,Phone_Number_1__c,Phone_Number_2__c,Email_If_Any__c,Area_of_Operation__c,Home_Address__c,Verified_By__c from Vendor_Registration__c where Vendor_Name__c Like : '%'+VendorInfo.Vendor_Name__c+'%' ];
}
if(NonVerifiedVendors_nolimt.IsEmpty() == false){
totalRecs = NonVerifiedVendors_nolimt.size() - 1;
}
if(((EnterRegisId <> null && EnterRegisId <> '')) && (VendorInfo.Vendor_Name__c <> null && VendorInfo.Vendor_Name__c <> '')){
NonVerifiedVendors = [select Selected__c, Permanent_Registration_ID__c,id,name,Vendor_Name__c,Status__c,Phone_Number_1__c,Phone_Number_2__c,Email_If_Any__c,Area_of_Operation__c,Home_Address__c,Verified_By__c from Vendor_Registration__c where name like :'%'+EnterRegisId +'%' AND Vendor_Name__c Like : '%'+VendorInfo.Vendor_Name__c+'%' LIMIT :LimitSize OFFSET :OffsetSize];
}else if((EnterRegisId <> null && EnterRegisId <> '')){
NonVerifiedVendors = [select Selected__c, Permanent_Registration_ID__c,id,name,Vendor_Name__c,Status__c,Phone_Number_1__c,Phone_Number_2__c,Email_If_Any__c,Area_of_Operation__c,Home_Address__c,Verified_By__c from Vendor_Registration__c where name like :'%'+EnterRegisId +'%' LIMIT :LimitSize OFFSET :OffsetSize];
}else if((VendorInfo.Vendor_Name__c <> null && VendorInfo.Vendor_Name__c <> '')){
NonVerifiedVendors = [select Selected__c, Permanent_Registration_ID__c,id,name,Vendor_Name__c,Status__c,Phone_Number_1__c,Phone_Number_2__c,Email_If_Any__c,Area_of_Operation__c,Home_Address__c,Verified_By__c from Vendor_Registration__c where Vendor_Name__c Like : '%'+VendorInfo.Vendor_Name__c+'%' LIMIT :LimitSize OFFSET :OffsetSize];
}
SYSTEM.DEBUG('Non Verified Vendors size ' + totalRecs );
SYSTEM.DEBUG('Non Verified Vendors ' + NonVerifiedVendors );
/*
for(Vendor_Registration__c vr: NonVerifiedVendors){
//WrapperController wc = new WrapperController(vr);
//wrapVendor_RegistrationList.add(wc);
}
list<Vendor_Registration__c> vrWrapper_list = new List<Vendor_Registration__c>();
for(integer i=0; i<wrapVendor_RegistrationList.size(); i++){
SYSTEM.DEBUG('wrapper list contaion ' + wrapVendor_RegistrationList[i]);
//vrWrapper_list.add(wrapVendor_RegistrationList[i].select_vendor);
//vrWrapper_list.add(wrapVendor_RegistrationList[i].vendor_wapper_lst);
}
*/
setCon = new ApexPages.StandardSetController(NonVerifiedVendors_nolimt);
setCon.setPageSize(LimitSize);
totalRecs = setCon.getResultSize();
getVendorRegistration();
SYSTEM.DEBUG('Standard Set Controller ' + setCon );
//integer totalpage = totalrecs - math.mod(totalRecs,LimitSize);
//SYSTEM.DEBUG('TOTAL NO OF PAGES ' + totalpage );
if(NonVerifiedVendors.size() == 0 ){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'No Vendor found matching with given information.'));
return;
}
}
public List<Vendor_Registration__c > getVendorRegistration(){
//List<Vendor_Registration__c> vrList = new List<Vendor_Registration__c >();
vrList.clear();
SYSTEM.DEBUG('Standard Set Controller in get VendorRegistration ' + setCon );
VendorRegistration_deepClone = setCon.getRecords().deepClone(true, true, true);
if(setCon != null){
for(Vendor_Registration__c vr : VendorRegistration_deepClone)
vrList.add(vr);
}
return vrList;
}
// The first page where offset value will be 0
public void firstPage(){
//selectall = false;
//OffsetSize = 0;
setCon.first();
}
// next button
public void next()
{
//selectall = false;
//OffsetSize = (OffsetSize + LimitSize);
SYSTEM.DEBUG(' setCon Value ' + setCon);
setCon.next();
}
// previous button
public void previous()
{
//selectall = false;
//OffsetSize -= LimitSize;
//selectall = false;
setCon.previous();
}
// LastPage button
public void LastPage()
{
//selectall = false;
//OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
//selectall = false;
setCon.last();
}
public list<Vendor_Registration__c> GetNonVerifiedVendors(){
return NonVerifiedVendors;
}
// to disabled buttons
public boolean hasprev{
/*
if(OffsetSize == 0)
return true;
else
return false;
*/
get {
SYSTEM.DEBUG('set Con result in has prev ' + setCon.getHasPrevious());
return setCon.getHasPrevious();
}
set;
}
// to disabled buttons
public boolean hasnxt{
//selectall = false;
/*
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
*/
get {
SYSTEM.DEBUG('set Con result in has next ' + setCon.getHasNext());
return setCon.getHasNext();
}
set;
}
//Select All
public void selectAll(){
SYSTEM.DEBUG('Inside select all method ');
if(selectAll == true){
SYSTEM.DEBUG('If select all equels to true ');
SYSTEM.DEBUG('Vendor Registration size ' + vrList.size());
for(integer i =0; i < vrList.size(); i++){
if(vrList[i].Status__c == 'Verified'){
SYSTEM.DEBUG('Vendor Registration status ' + vrList[i].Status__c);
SYSTEM.DEBUG('Vendor Registration ID ' + vrList[i].Name);
vrList[i].Selected__c = true;
SYSTEM.DEBUG('Vendor Registration selected field ' + vrList[i].Selected__c);
}
}
}
else if(selectAll == false){
for(integer i =0; i < vrList.size(); i++){
if(vrList[i].Status__c == 'Verified'){
vrList[i].Selected__c = false;
}
}
}
GenerateIdCards();
}
public void showVerificationVendor(){
if(SelectedVendor <> null && SelectedVendor <> ''){
VerificationInfo = [select id,Verified_By__c,name,No_of_persons_on_Job_Location__c,Previous_work_Information__c,Submitted_all_required_Documents__c,No_of_Family_members__c from Vendor_Registration__c where name =:SelectedVendor];
ShowVerificationBlock = true;
}
}
public void Approve(){
VerificationInfo.Status__c = 'Verified';
update VerificationInfo;
}
public pagereference ApproveAndIDCard(){
VerificationInfo.Status__c = 'Verified';
update VerificationInfo;
pagereference pg = new pagereference('/apex/GenerateTemporaryIdCard?id='+VerificationInfo.id+'&IdNo=IdN');
pg.SetRedirect(true);
return pg;
}
// Passing ids to GenerateTemporaryIdCard page for Generateing Id Cards
public pagereference GenerateIdCards(){
SYSTEM.DEBUG('vendor ids before for ' + vendor_ids );
for(integer i =0; i < vrList.size(); i++){
if(vrList[i].Selected__c == true){
SYSTEM.DEBUG('Vendor selected Registration List ' + vrList[i].Vendor_Name__c);
if(vendor_ids != null && vendor_ids != ''){
vendor_ids = vendor_ids +'~'+ vrList[i].id;
}else{
vendor_ids = vrList[i].id;
}
}
}
SYSTEM.DEBUG('Generated ids ' + vendor_ids );
pagereference pg = new pagereference('/apex/GenerateTemporaryIdCard?Multipleid='+vendor_ids);
pg.SetRedirect(true);
return pg;
//return null;
}
public void Reject(){
VerificationInfo.Status__c = 'Verification failed';
update VerificationInfo;
ShowRejectMessage = true;
}
//Wrapper class
public class WrapperController{
public Vendor_Registration__c vendor_wapper_lst {get; set;}
public Boolean select_vendor {get; set;}
public WrapperController(Vendor_Registration__c vendor_wapper_lst ){
this.vendor_wapper_lst = vendor_wapper_lst;
select_vendor = false;
//SYSTEM.DEBUG('Wrapper list contains in wrapper ' + wrapVendor_RegistrationList);
}
}
}
Please guide me what is getting wrong with this.