function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JimmyBeWhiteJimmyBeWhite 

apex:intputCheckBox value not binding to wrapper class

I've run into an issue that is baffling and frustrating. I've got a pageblocktable that simply shows a few elements of a wrapper class that includes some selectoptions, display strings, and most importantly a boolean that is tied to a checkbox. I just discovered that the checkbox values are not binding to the booleans in the wrapper (they were last week), which totally breaks the page and sucks. Please help me...

 

here's the visualforce code: 

<apex:pageBlockTable title="Select School(s)" var="s" value="{!schoolListChoices}">
     <apex:column title="Select">     
          <apex:facet name="header">Select</apex:facet>     
          <apex:inputCheckBox value="{!s.Selected}" /> <!--not binding...-->
     </apex:column>
     <apex:column title="Name">
          <apex:facet name="header">Name</apex:facet>
          <apex:outputText value="{!s.DisplayName}" />
     </apex:column>
</apex:pageBlockTable>

 

Here's the relevant APEX:

//Wrapper

public class reportCardWrapper{
public String displayName {get;set;}
public ID recordID {get;set;}
public ID selectedReportingPeriod {get;set;}
public boolean selected {get;set;}
public list<selectOption> reportingPeriods {get;set;}

public reportCardWrapper(string dn, ID rid){
this.selected = false; //this stopped binding for some reason
this.recordID = rid;
this.displayName = dn;
this.reportingPeriods = new List<selectOption>();
selectedReportingPeriod = null;
}

}

//Loop that checks for "selected"

boolean bSchoolOrGradeSelected = false;
for(reportCardWrapper rw : schoolListChoices){
     if(rw.selected){ //should be true because of the checkbox tied to it on the page.
          schoolToSelectedReportingPeriod.put(rw.recordID,rw.selectedReportingPeriod);
          if(bSchoolOrGradeSelected){//add to the or statement     
               query += ' OR Student__r.School__c = \'' + rw.recordID + '\'';
          }
          else{
               query += ' Student__r.School__c = \'' + rw.recordID + '\'';
               bSchoolOrGradeSelected = true;//this never goes true because the selected value wont bind
           }
     }
}

There is no salesforce error, the only error I get is the one I wrote that checks to make sure at least one box is selected (by looping thru the wrappers and checking the "selected" field. I have another section of the page that has similar logic, but uses datatables instead of pageblocktable, which also has the same issue suddenly.

 

What is going on SF?!

 

Thanks,

Jimmy

Best Answer chosen by Admin (Salesforce Developers) 
JimmyBeWhiteJimmyBeWhite

I fixed it, the issue was that the same list was being referred to elsewhere in the page - thus causing the field to be both true/false at the same time

All Answers

JimmyBeWhiteJimmyBeWhite

I fixed it, the issue was that the same list was being referred to elsewhere in the page - thus causing the field to be both true/false at the same time

This was selected as the best answer
ViwalViwal

Hi

Jimmy, Can u please explain how u resolved the issue.

I am facing the same issue.