0

Posting the markup from VF (posting only the relevant section as my total VF page exceeds the allowed limit in SFSE)

 <section id="section-line-8">

                            <apex:panelGrid id="history_section" columns="2" styleClass="factfind">
                              <apex:outputpanel id="no_rse" rendered="{! WrapperHistories.size == 0 || WrapperHistories == null }">
                                <p style="font-size:24px; text-align:center;color:#999999;"> No History Found </p>
                            </apex:outputpanel>
                            </apex:panelGrid>
                            <apex:outputPanel id="imp_his_section" rendered="{! WrapperHistories.size > 0 }">
                                    <table border="0" class="related_se">
                                        <tr>
                                            <td><span class="title">Date</span></td>
                                            <td><span class="title">User</span></td>
                                            <td><span class="title">Action</span></td>

                                        </tr>                                    
                                        <apex:variable value="{!0}" var="rowNum" />
                                        <apex:repeat id="imp_h" value="{!WrapperHistories}" var="wh">
                                            <tr>
                                                <td><apex:outputField value="{!wh.Implementation__History.CreatedDate}"/></td>
                                                <td><apex:outputField value="{!wh.Implementation__History.CreatedById}"/></td>
                                                <td>
                                                        <apex:outputText style="font-style:bold" value="Changed  "/>
                                                        <apex:outputText style="font-style:bold;color:blue;font-weight: bold;" value="{!wh.lbl}"/>
                                                        <apex:outputText style="font-style:bold" value="   from "/>
                                                        <apex:outputText style="font-style:bold;color:blue;font-weight: bold;" value="{!wh.Implementation__History.OldValue} "/>
                                                        <apex:outputText style="font-style:bold" value="to "/>
                                                        <apex:outputText style="font-style:bold;color:blue;font-weight: bold;" value="{!wh.Implementation__History.NewValue} "/>
                                                </td>


                                            </tr>
                                        </apex:repeat>
                                        <tr><td><br/></td></tr>

                                    </table>
                            </apex:outputPanel>
                        </section> 

This is my controller

public class ImplementationController {

    public ApexPages.standardController st_controller;
   // public Implementation__c i{get;set;}
    public Implementation__c implementation{get; set;}
    public Implementation_Status__c CancelledStatus = Implementation_Status__c.getValues('Cancelled'); // Cancelled
    public Service_Enquiry_Settings__c ses_exit_url = Service_Enquiry_Settings__c.getValues('ExitURLImp');
    public List<String> li_Implementation_Nav_Bar{get; set;}
    public List<WrapperHistoryList> WrapperHistories{get;set;}

    public ImplementationController (ApexPages.StandardController stdController){
     st_controller = stdController;
     implementation = getImplementation(st_controller.getId());
     li_Implementation_Nav_Bar = getImplementationNavBar(implementation);
     //implementationhistories = getImplementationHistory(implementation);
      WrapperHistories = getImplementationHistory(implementation);  
        }

    public class WrapperHistoryList{
        public String lbl{get;set;}
        public Implementation__History ImplementationHistory{get;set;}

    }

    public String GetLabel(String fname)
    {
        String type='Implementation__c';
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Schema.SObjectType leadSchema = schemaMap.get(type);
        Map<String, Schema.SObjectField> fieldMap = leadSchema.getDescribe().fields.getMap();
        return fieldMap.get(fname).getDescribe().getLabel();
    }

    public List<WrapperHistoryList> getImplementationHistory(Implementation__c impe)
    {
        List<WrapperHistoryList> wlist = new List<WrapperHistoryList>();

        List<Implementation__History> imphis = [SELECT ID,NewValue,OldValue,ParentId,Field,CreatedDate,CreatedById FROM Implementation__History WHERE ParentId= :impe.Id ORDER BY CreatedDate DESC];
        if(imphis.size()>0)
        {
            //return imphis;
            for(Implementation__History i : imphis)
            {
                WrapperHistoryList w = new WrapperHistoryList();
                w.ImplementationHistory = i;
                w.lbl = GetLabel(i.Field);
                wlist.add(w);
            }
            return wlist;
        }
        else
        {
            return null;
        }
    }

   public Implementation__c getImplementation(String ImpId){

        Implementation__c imp = new Implementation__c();
        String queryStr = 'Select ' + CommonUsedClass.sObjectGetAllFields(imp).trim() + ' From Implementation__c Where Id = : ImpId';
        try{
           imp = Database.query(queryStr);     
        }
        catch(Exception e){
            system.debug('****** Querying Service Enquiry Exception: ' + e.getMessage()); 
        }
        return imp;
    }

    public List<String> getImplementationNavBar(Implementation__c impe){
        List<String> li_nav = new List<String>();
        for(SelectOption option : CommonUsedClass.getPicklistValue('Implementation__c', 'Implementation_Status__c')){
            // Active Nav Bar - without 'Lost' status
            if(impe.Implementation_Status__c != CancelledStatus.Status_Name__c){
                if(option.getValue() != CancelledStatus.Status_Name__c){
                    li_nav.add(option.getLabel());    
                }                 
            }
            else{
                li_nav.add(option.getLabel());
            }

        }
        return li_nav;
    }

  public PageReference saveImp(){

       System.debug('~~~ Before Update'); 
        update implementation;
        PageReference page = new PageReference('/' + ses_exit_url.URL__c);
        return page;

    }

    public PageReference exitImp(){
        PageReference page = new PageReference('/' + ses_exit_url.URL__c);
        return page;
    }


}

Issue :

I am getting an error while compiling the VF page. The error is as follows

enter image description here

I am not able to understand why I am getting that error. I am using a wrapper class list variable as source for <apex:repeat> and I believe my getter/setter definition is right and I should be able to reference the list variable in my VF page without any error.

Can someone let me know as to what I am missing here ?

1

The lines

<apex:repeat id="imp_h" value="{!WrapperHistories}" var="wh">
    <tr>
     <td><apex:outputField value="{!wh.Implementation__History.CreatedDate}" ...

can be deconstructed as:

{!WrapperHistories} references a list of type WrapperHistoryList

wh is thus bound to a specific list element of type WrapperHistoryList

WrapperHistoryList is defined as an inner class:

public class WrapperHistoryList{
    public String lbl{get;set;}
    public Implementation__History ImplementationHistory{get;set;}

}

and has two properties:

lbl and ImplementationHistory (the latter of type Implementation__History

thus, when using wh in the repeat markup, the only things you can use are:

{!wh.lbl} and {!wh.ImplementationHistory.xxx} where xxx are fields on that Sobject

| improve this answer | |
2

Your Visualforce needs to reference the property name ImplementationHistory not the property type Implementation__History.

| improve this answer | |

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.