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
SATHISH REDDY.SATHISH REDDY. 

Checkbox selection using Wrapper is not passed to controller

Hi All,
This might have been posted several times but i'm unable to workaround this issue using apex & I also looked at all the existing questions similar to this. I have a list of Opps with checkboxes in wrapper and i'm unable to retrieve the selections in apex where it always show false. Any help is really appreciated.
User-added imageVFP:
<apex:page controller="ForecastQuotaUpdateController" sidebar="false" docType="html-5.0">
    <apex:form >
        <apex:pagemessages />
        <apex:pageblock >
            <input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search by Acc/Owner/Parent..." title="Type in an Account Name"/>
            Year : &nbsp;
            <apex:inputField value="{!history.Year__c}"/>            
            User &nbsp;
            <apex:selectList multiselect="false" size="1" value="{!selectedUser}">
                <apex:selectOptions value="{!userOptionsList}"></apex:selectOptions>
            </apex:selectList>
            Team &nbsp;
            <apex:inputCheckbox value="{!isTeam}"/>            
            Confidence % &nbsp;
            <apex:inputCheckbox value="{!isOppConfidence}"/>            
            Exclude S1 &nbsp;
            <apex:inputCheckbox value="{!isS1Exclude}"/>
            Exclude S2 &nbsp;
            <apex:inputCheckbox value="{!isS2Exclude}"/>            
            Exclude S3 &nbsp;
            <apex:inputCheckbox value="{!isS3Exclude}"/>
            <apex:commandButton value="Search" action="{!searchAction}" status="status" rerender="formId"/>
        </apex:pageblock>
    </apex:form>
    
    <apex:form id="formId">
        <!-- List of Opps -->
        <div id="oppstblDiv">
            <table class="oppstbl" id="myTable">
                <thead>
                    <tr>
                        <th colspan="1" style="width:50px;">Select</th>
                        <th colspan="1">Opp Name</th>
                        <th colspan="1">Stage</th>
                        <th colspan="1">Budget</th>
                        <th colspan="1">Owner</th>
                        <th colspan="1">End Date</th>
                    </tr>
                </thead>
                <tbody>
                    <apex:repeat value="{!forecastOppWrapList}" var="oppWrap">
                        <tr>
                            <td><apex:inputCheckbox value="{!oppWrap.selected}"/></td>
                            <td>{!oppWrap.opp.Opportunity_Number__c}</td>
                            <td>{!oppWrap.opp.StageName}</td>
                            <td>{!oppWrap.opp.Budget__c}</td>
                            <td>{!oppWrap.opp.Owner.Name}</td>
                            <td>{!oppWrap.opp.End_Date__c}}</td>
                        </tr>
                    </apex:repeat>
                </tbody>
            </table>
        </div>        
    </apex:form>
</apex:page>

Controller:
public class ForecastQuotaUpdateController {
    
    public String selectedUser { get; set; }
    public Boolean isTeam { get; set; }
    public Boolean isOppConfidence { get; set; }
    public Boolean isS1Exclude { get; set; }
    public Boolean isS2Exclude { get; set; }
    public Boolean isS3Exclude { get; set; }    
    public ForecastQuotaUpdateController(){
        isTeam = false;
        isOppConfidence = false;
        isS1Exclude = false;
        isS2Exclude = false;
        isS3Exclude = false;
        selectedUser = '';
        userOptionsList = new List<SelectOption>();
        userOptionsList.add(new SelectOption('', '--None--'));
        history = new Quota_History__c();
        yearCurrent = String.valueOf(System.Today().year());
        searchUtility('', yearCurrent,'', false, false, false, false, false, new List<ForecastOpportunityListWrapper>());
    }
    
    //Search Button
    public void searchAction(){
        List<SelectOption>  userOptionsListTemp = new List<SelectOption>();
        if(!userOptionsList.isEmpty()){
            userOptionsListTemp.addAll(userOptionsList);
        }
        if(history.year__c != null)        
            yearCurrent =   history.year__c;
        if(String.isBlank(selectedUser) && isTeam)
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, 'Select a User'));        
        else    //Here i'm expecting "forecastOppWrapList" to have "selected" = true after selection on VFP (which isNOT working)
            searchUtility('', yearCurrent, selectedUser, isTeam, isOppConfidence, isS1Exclude, isS2Exclude, isS3Exclude, forecastOppWrapList); 

        if(!userOptionsListTemp.isEmpty()){
            userOptionsList.clear();
            userOptionsList.addAll(userOptionsListTemp);
        }    
    }
    
    public void searchUtility(String AccountId, String yearStr, String sltUser, Boolean isTeamUser, Boolean isOppConfidenceSet, Boolean isS1ExcludeSet, Boolean isS2ExcludeSet, Boolean isS3ExcludeSet, List<ForecastOpportunityListWrapper> tempforecastOppWrapList){       
        for(Some accs query){
            ...
            ...
             //Opportunities List S1 S2 S3
            forecastOppWrapList = new List<ForecastOpportunityListWrapper>();
            for(Opportunity tempOpp : tempClosedWon.Values()){
                ForecastOpportunityListWrapper wrapOpp = new ForecastOpportunityListWrapper(tempOpp);
                forecastOppWrapList.add(wrapOpp);
            }
        }

        if(!tempforecastOppWrapList.isEmpty()){
            for(ForecastOpportunityListWrapper selectedOpp : tempforecastOppWrapList){
                if(selectedOpp.selected){
                    ...//Capture the selected opps logic
                }
            }
        }       
    }
   //Wrapper Class
    public List<ForecastOpportunityListWrapper> forecastOppWrapList { get; set; }
    public Class ForecastOpportunityListWrapper{
        public Id oppId { get; set; }
        public Opportunity opp {get; set;}
        public Boolean selected {get; set;}
        public ForecastOpportunityListWrapper(Opportunity o){
            opp = o;
            selected = false;
        }
    } 
}



 
SATHISH REDDY.SATHISH REDDY.
Can someone help me with this?