0

Please find below my apex controller for which I am getting unknown property error for TableExampleController.CISubClass.Id when I try compile my corresponding page with it.

I am not getting the reason for the error when controller is compiled fine. Below i have the page.

Apex code:

public with sharing class TableExampleController {
    // CI and selection set/variables
    private list<CISubClass> CIList {get; set;}
    private set<Id> CISelectedSet;
    public Integer CISelectedCount {get; set;}
    public String SelectedOneCI {get; set;}

    // selection and filter 
    public list<String> AlphaList {get; set;}
    public String AlphaFilter {get; set;}
    public String SearchName {get; set;}
    public String SearchBillingAddress {get; set;} 
    private String SaveSearchName;
    private String SaveSearchBillingAddress;
    private String QueryCI;

    // display sort and number
    public String RecPerPage {get; set;}
    public list<SelectOption> RecPerPageOption {get; set;}  
    public String SortFieldSave;

    /***
    * TableExampleController - Constructor initialization
    ***/
    public TableExampleController(){
        CIList = new list<CISubClass>();
        CISelectedSet = new set<Id>();

        //records for page initialization
        RecPerPageOption = new list<SelectOption>();
        RecPerPageOption.add(new SelectOption('10','10'));
        RecPerPageOption.add(new SelectOption('25','25'));
        RecPerPageOption.add(new SelectOption('50','50'));
        RecPerPageOption.add(new SelectOption('100','100'));
        RecPerPageOption.add(new SelectOption('200','200'));
        RecPerPage = '10'; //default records per page

        // initialization alpha list
        AlphaList = new list<String> {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Other', 'All'};
            SortFieldSave = SortField;

        // alpha filter, use page parameter or set default to all
        if (apexpages.currentpage().getparameters().get('alpha') == null) {
            AlphaFilter = 'All';
        } else {
            AlphaFilter = apexpages.currentpage().getparameters().get('alpha');
        }

        // list generation
        BuildQuery();  
    }

    /***
    * StdSetControllerCI - paging through the CI list
    ***/ 
    public ApexPages.StandardSetController StdSetControllerCI {
        get {
            if(StdSetControllerCI == null) {
                StdSetControllerCI = new ApexPages.StandardSetController(Database.getQueryLocator(QueryCI));
                // sets the number of records in each page set
                StdSetControllerCI.setPageSize(Integer.valueOf(RecPerPage));
            }
            return StdSetControllerCI;
        }
        set;
    }

    /***
    * getCurrentCIList - return an CI list for the table
    ***/  
    public list<CISubClass> getCurrentCIList() {
        UpdateCISelectedSet();

        CIList = new list<CISubClass>();
        for (Compliance_Incident_abv__c a : (list<Compliance_Incident_abv__c>)StdSetControllerCI.getRecords()) {
            CIList.add(new CISubClass(a, CISelectedSet.contains(a.Id)));
        }
        return CIList;
    }

    /***
    * UpdateCISelectedSet - add/remove CIs from the selected CI id list
    ***/
    public void UpdateCISelectedSet(){
        for(CISubClass a : CIList ){
            if(a.aCheckBox == true) {
                CISelectedSet.add(a.aCI.Id);
            } else {
                if(CISelectedSet.contains(a.aCI.Id)) {
                    CISelectedSet.remove(a.aCI.Id);
                }
            }
        }  
        CISelectedCount = CISelectedSet.size();
    }

    /***
    * ClearCISelectedSet - remove selected CIs and initialize counter
    ***/
    public PageReference ClearAll(){
        CIList.clear();
        CISelectedSet.clear();
        CISelectedCount = 0;
        SearchName = '';
        SearchBillingAddress = '';
        SaveSearchName = '';
        SaveSearchBillingAddress = '';
        AlphaFilter = 'All';

        BuildQuery();

        return null;
    }

    /***
    * SearchCI - set search criteria fields and refresh CI table
    ***/
    public PageReference SearchCI() {
        SaveSearchName = SearchName;
        SaveSearchBillingAddress = SearchBillingAddress;

        BuildQuery();

        return null;
    }

    /***
    * BuildQuery - build query command for list selection change
    ***/
    public void BuildQuery() {
        StdSetControllerCI = null;
        String QueryWhere = '';

        if (AlphaFilter == null || AlphaFilter.trim().length() == 0) {
            AlphaFilter = 'All';
        }

        QueryCI = 'SELECT Id, Publish_Date_abv__c,Name, Incident_Type_abv__c, Status_abv__c,  Rep_abv__c, Rep_Franchise_abv__c, RecordTypeID, No_Of_Transactions_abv__c FROM Compliance_Incident_abv__c'; 

        if (AlphaFilter == 'Other') {
            QueryWhere = BuildWhere(QueryWhere, '(' + String.escapeSingleQuotes(SortField) + ' < \'A\' OR ' + 
                                    String.escapeSingleQuotes(SortField) + ' > \'Z\') AND (NOT ' + 
                                    String.escapeSingleQuotes(SortField) + ' LIKE \'Z%\') ');
        } else if (AlphaFilter != 'All') {
            QueryWhere = BuildWhere(QueryWhere, '(' + String.escapeSingleQuotes(SortField) + ' LIKE \'' + String.escapeSingleQuotes(AlphaFilter) + '%\')' );
        }

        if (SaveSearchName != null) {
            QueryWhere = BuildWhere(QueryWhere, ' (Name LIKE \'%' + String.escapeSingleQuotes(SaveSearchName) + '%\')');
        }
        if (SaveSearchBillingAddress != null) {
            QueryWhere = BuildWhere(QueryWhere, '((BillingStreet LIKE \'%' + String.escapeSingleQuotes(SaveSearchBillingAddress) + '%\') or' +
                                    ' (BillingCity LIKE \'%' + String.escapeSingleQuotes(SaveSearchBillingAddress) + '%\') or' +
                                    ' (BillingState LIKE \'%' + String.escapeSingleQuotes(SaveSearchBillingAddress) + '%\') or' +
                                    ' (BillingPostalCode LIKE \'%' + String.escapeSingleQuotes(SaveSearchBillingAddress) + '%\') or' +
                                    ' (BillingCountry LIKE \'%' + String.escapeSingleQuotes(SaveSearchBillingAddress) + '%\'))');
        }

        QueryCI += QueryWhere;
        QueryCI += ' ORDER BY ' + String.escapeSingleQuotes(SortField) + ' ' + String.escapeSingleQuotes(SortDirection) + ' LIMIT 10000';

        system.debug('QueryCI:' + QueryCI);
    }

    /***
    * BuildWhere - build soql string for where criteria 
    ***/
    public String BuildWhere(String QW, String Cond) {
        if (QW == '') {
            return ' WHERE ' + Cond;
        } else {
            return QW + ' AND ' + Cond;
        }
    }

    /***
    * SortDirection - return sort direction. Default ascending(asc)
    ***/
    public String SortDirection {
        get { if (SortDirection == null) {  SortDirection = 'asc'; } return SortDirection;  }
        set;
    }

    /***
    * SortField - return sort by field. Default to Name
    ***/
    public String SortField {
        get { if (SortField == null) {SortField = 'Name'; } return SortField;  }
        set; 
    }

    /***
    * SortToggle - toggles the sorting of query from asc<-->desc
    ***/
    public void SortToggle() {
        SortDirection = SortDirection.equals('asc') ? 'desc NULLS LAST' : 'asc';
        // reset alpha filter and sort sequence when sorted field is changed
        if (SortFieldSave != SortField) {
            SortDirection = 'asc';
            AlphaFilter = 'All';
            SortFieldSave = SortField;
        }
        // run the query again
        BuildQuery();
    }

    /***
    * DoSomethingOne - do something with one selected CI
    ***/
    public PageReference DoSomethingOne() {
        system.debug('SelectedOneCI: ' + SelectedOneCI);
        return null;
    }

    /***
    * DoSomethingMany - do something with many selected CIs
    ***/
    public PageReference DoSomethingMany() {
        for (Id CIId : CISelectedSet) {
            system.debug('Checked: ' + CIId);
        }
        return null;
    }

    /***
    * CISubClass - Sub-Class to hold CI and checkbox for the table
    ***/
    public class CISubClass {
        public Boolean aCheckBox {get;set;}
        public Compliance_Incident_abv__c aCI {get;set;}

        // sub-class initialization
        public CISubClass(Compliance_Incident_abv__c a, Boolean chk){
            aCI = a;
            aCheckBox = chk;
        }
    }
}

Apex Page

<apex:page controller="TableExampleController">
 <style type="text/css">
.loading-icon {
   background-image: url(/img/loading.gif);
   width: 16px;
   height: 16px;
}

a.alpha-link {
   font-weight: normal;
   font-size: 91%;
   padding: 0 4px;
   color: #015BA7 !important;
}

a.alpha-link+a.alpha-link {
   border-left: 1px solid #CFCECE;
}

a.alpha-link:hover {
   background-color: #e0f5fc !important;
}

a.alpha-select {
   font-weight: bold;
   text-decoration: none;
   background-color: #C6E1FF;
   color: #000000 !important;
}

.search-block {
   text-align: center;
}

.search-block input {
   margin: 0px 15px 0px 5px;
}

.search-block-button {
   min-width: 110px;
}

.process-block {
   text-align: center;
   margin-top: 10px;
}

.process-block input {
   margin: 0px 15px;
}

.process-block-button {
   min-width: 110px;
}

.page-buttons input {
   min-width: 110px;
}
</style>

   <apex:form id="TheForm">
      <!-- ***************************** -->
      <!-- Search Criteria     -->         
      <apex:pageBlock mode="maindetail">
         <div class="search-block">
            <div style="display: inline-table">
               <span>Name:</span>
               <apex:inputText value="{!SearchName}" />
            </div>
            <div style="display: inline-table">
               <span>Billing Address:</span>
               <apex:inputText value="{!SearchBillingAddress}" />
            </div>
            <apex:commandButton styleClass="search-block-button" value="Search" action="{!SearchCI}" rerender="TablePanel"
               status="TableUpdateStatus" />
         </div>

         <div class="process-block">
            <apex:actionStatus id="ProcessButtonStatus">
               <apex:facet name="stop">
                  <apex:outputPanel >
                     <apex:commandButton styleClass="process-block-button" value="Process Selected" action="{!DoSomethingMany}"
                        status="ProcessButtonStatus" rerender="nothing" />
                     <apex:commandButton styleClass="process-block-button" value="Clear All" action="{!ClearAll}"
                        rerender="TheForm,TablePanel" />
                  </apex:outputPanel>
               </apex:facet>
               <apex:facet name="start">
                  <apex:outputPanel >
                     <apex:commandButton styleClass="process-block-button" value="Processing..." disabled="true" />
                     <apex:commandButton styleClass="process-block-button" value="Processing..." disabled="true" />
                  </apex:outputPanel>
               </apex:facet>
            </apex:actionStatus>
         </div>
      </apex:pageBlock>

      <!-- ************************* -->
      <!-- search results table   -->   
      <apex:pageBlock id="TablePanel">
         <div>
            <span class="page-buttons" style="float: left; margin-bottom: 5px;"> <apex:commandButton disabled="{!!StdSetControllerCI.hasprevious}" value="Previous" action="{!StdSetControllerCI.previous}"
                  rerender="TablePanel" /> <apex:commandButton disabled="{!!StdSetControllerCI.hasnext}" value="Next"
                  action="{!StdSetControllerCI.next}" rerender="TablePanel" />
            </span>
            <!-- alphabet selection -->
            <span style="float: right; margin: 5px 5px 5px 5px;"> <apex:repeat value="{!AlphaList}" var="a">
                  <apex:commandLink value="{!a}" action="{!BuildQuery}" rerender="TablePanel"
                     styleClass="alpha-link{!if(AlphaFilter=a,' alpha-select','')}" status="TableUpdateStatus">
                     <apex:param name="AlphaFilter" value="{!a}" assignTo="{!AlphaFilter}" />
                  </apex:commandLink>
               </apex:repeat>
            </span>
         </div>

         <div style="clear: both;"></div>

         <apex:actionStatus id="TableUpdateStatus">
            <apex:inputHidden value="{!AlphaFilter}" id="hiddenField" />
            <!-- loading message -->
            <apex:facet name="start">
               <apex:outputPanel layout="block" styleClass="message infoM4">
                  <apex:panelGrid columns="2" styleClass="messageTable" columnClasses="messageCell" style="padding:0px;margin:0px;">
                     <apex:panelGroup >
                        <img class="loading-icon" src="/s.gif" />
                     </apex:panelGroup>
                     <apex:panelGroup >
                        <div class="messageText">Please wait...</div>
                     </apex:panelGroup>
                  </apex:panelGrid>
               </apex:outputPanel>
            </apex:facet>

            <!-- CI table -->
            <apex:facet name="stop">
               <apex:pageBlockTable value="{!CurrentCIList}" var="a">
                  <apex:column >
                     <apex:commandLink styleClass="alpha-link" action="{!DoSomethingOne}">
                        <apex:param value="{!a.Id}" assignTo="{!SelectedOneCI}" />Select</apex:commandLink>
                  </apex:column>
                  <apex:column >
                     <apex:facet name="header">
                        <apex:outputPanel id="SelectedCount">
                           <div style="text-align: center;">
                              <apex:outputText value="Selected" />
                              <br />
                              <apex:outputText value="{!CISelectedCount}" />
                           </div>
                        </apex:outputPanel>
                     </apex:facet>
                     <div style="text-align: center;">
                        <apex:inputCheckBox value="{!a.aCheckBox}" id="check-box">
                           <apex:actionSupport event="onchange" rerender="SelectedCount" action="{!UpdateCISelectedSet}" />
                           </apex:inputcheckbox>
                     </div>
                  </apex:column>
                  <apex:column >
                     <apex:facet name="header">
                        <apex:commandLink action="{!SortToggle}" rerender="TablePanel" status="TableUpdateStatus">
                           <apex:param name="SortField" value="Report Date" assignTo="{!SortField}" />
                           <apex:outputText value="{!$ObjectType.Compliance_Incident_abv__c.Fields.Publish_Date_abv__c.Label}{!IF(SortField=='Publish_Date_abv__c',IF(SortDirection='asc','▲','▼'),'')}" />
                        </apex:commandLink>
                     </apex:facet>
                     <apex:outputField value="{!a.Publish_Date_abv__c}" />
                  </apex:column>
                  <apex:column >
                     <apex:facet name="header">
                        <apex:commandLink action="{!SortToggle}" rerender="TablePanel" status="TableUpdateStatus">
                           <apex:param name="SortField" value="Compliance Incident Name" assignTo="{!SortField}" />
                           <apex:outputText value="{!$ObjectType.Compliance_Incident_abv__c.Fields.Name.Label}{!IF(SortField=='Name',IF(SortDirection='asc','▲','▼'),'')}" />
                        </apex:commandLink>
                     </apex:facet>

                      <apex:outputLink value="/{!a.Id}" target="_blank">{!a.Name}</apex:outputlink>
                  </apex:column>
                  <apex:column >
                     <apex:facet name="header">
                        <apex:commandLink action="{!SortToggle}" rerender="TablePanel" status="TableUpdateStatus">
                           <apex:param name="SortField" value="Incident Type" assignTo="{!SortField}" />
                           <apex:outputText value="{!$ObjectType.Compliance_Incident_abv__c.Fields.Incident_Type_abv__c.Label}{!IF(SortField=='Incident_Type_abv__c',IF(SortDirection='asc','▲','▼'),'')}" />
                        </apex:commandLink>
                     </apex:facet>
                     <apex:outputField value="{!a.Incident_Type_abv__c}" />
                  </apex:column>
                  <apex:column >
                     <apex:facet name="header">
                        <apex:commandLink action="{!SortToggle}" rerender="TablePanel" status="TableUpdateStatus">
                           <apex:param name="SortField" value="Total Transactions" assignTo="{!SortField}" />
                           <apex:outputText value="{!$ObjectType.Compliance_Incident_abv__c.Fields.No_Of_Transactions_abv__c.Label}{!IF(SortField==' No_Of_Transactions_abv__c',IF(SortDirection='asc','▲','▼'),'')}" />
                        </apex:commandLink>
                     </apex:facet>
                     <apex:outputField value="{!a.No_Of_Transactions_abv__c}" />
                  </apex:column>

                  <apex:column >
                     <apex:facet name="header">
                        <apex:commandLink action="{!SortToggle}" rerender="TablePanel" status="TableUpdateStatus">
                           <apex:param name="SortField" value="Report Status" assignTo="{!SortField}" />
                           <apex:outputText value="{!$ObjectType.Compliance_Incident_abv__c.Fields.Status_abv__c.Label}{!IF(SortField=='Status_abv__c',IF(SortDirection='asc','▲','▼'),'')}" />
                        </apex:commandLink>
                     </apex:facet>
                     <apex:outputField value="{!a.Status_abv__c}" />
                  </apex:column>
                  <apex:column >
                     <apex:facet name="header">
                        <apex:commandLink action="{!SortToggle}" rerender="TablePanel" status="TableUpdateStatus">
                           <apex:param name="SortField" value="Representative" assignTo="{!SortField}" />
                           <apex:outputText value="{!$ObjectType.Compliance_Incident_abv__c.Fields.Rep_abv__c.Label}{!IF(SortField=='Rep_abv__c',IF(SortDirection='asc','▲','▼'),'')}" />
                        </apex:commandLink>
                     </apex:facet>
                      <apex:outputLink value="/{!a.Id}" target="_blank">{!a.Rep_abv__c}</apex:outputlink>
                  </apex:column>
                   <apex:column >
                     <apex:facet name="header">
                        <apex:commandLink action="{!SortToggle}" rerender="TablePanel" status="TableUpdateStatus">
                           <apex:param name="SortField" value="Representative Franschise" assignTo="{!SortField}" />
                           <apex:outputText value="{!$ObjectType.Compliance_Incident_abv__c.Fields.Rep_Franchise_abv__c.Label}{!IF(SortField=='Rep_Franchise_abv__c',IF(SortDirection='asc','▲','▼'),'')}" />
                        </apex:commandLink>
                     </apex:facet>
                     <apex:outputField value="{!a.Rep_Franchise_abv__c}" />
                  </apex:column>
               </apex:pageBlockTable>
            </apex:facet>
         </apex:actionStatus>
         <div style="margin-top: 5px;">
            <apex:outputText value="Number of Records per Page: " />
            <apex:selectList value="{!RecPerPage}" size="1">
               <apex:selectOptions value="{!RecPerPageOption}" />
               <apex:actionSupport event="onchange" action="{!BuildQuery}" reRender="TablePanel" status="TableUpdateStatus" />
            </apex:selectList>
         </div>
      </apex:pageBlock>
   </apex:form> 
</apex:page>
1

If you looked into the wrapper class.

You have record variable in wrapper class

but in VF page you are trying to access the object Id directly

ie.

 <apex:commandLink styleClass="alpha-link" action="{!DoSomethingOne}">
      <apex:param value="{!a.Id}" assignTo="{!SelectedOneCI}" />Select
  </apex:commandLink>

Here you are accessing a.Id but a is the wrapper instance

You have to use like a.aCI.Id

  <apex:commandLink styleClass="alpha-link" action="{!DoSomethingOne}">
     <apex:param value="{!a.aCI.Id}" assignTo="{!SelectedOneCI}" />Select
  </apex:commandLink>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.