• sduvvuri
  • NEWBIE
  • 0 Points
  • Member since 2015
  • Salesforce Technical Architect
  • Slalom LLC


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

So I've been trying to figure out my fieldset and dynamic binding with vf issue.

 

My goal is to have a Map of lists where each lists contains files. I've been experiencing wierd issues.

 

So I attempted to simplify this. Here's what I'm doing.

 

I create my list (lFields) which contains all the field names I'll be using. I have a pageblock section that displays the value of those fields and a second that just lists all the fields.

 

Then I have a map with 2 keys (List1 and List2) each with a list of fields that's a sub-section of lFields. This I loop through on the page. However if I try to put the field in an Output or Input I get this "Invalid Field Core." If I just display {! f} I get the fieldname just fine.

 

Here's my Extension:

public class Admin_FieldSetTest {
    
    public list<string> lFields {get;set;}
    public list<string> lTemps {get;set;}
    public map<string, list<string>> mLists {get;set;}
    public string ConId; 
    private final Case myCase;
    
    public Admin_FieldSetTest(ApexPages.StandardController controller){    
        ConId = controller.getId();
        BuildFieldList();
        controller.addfields(lFields);
        this.mycase = (Case)controller.getrecord(); 
    }
    public void BuildFieldList(){
        //SELECT AccountId,Budget__c,CaseNumber,ContactId,Id,Origin,OwnerId,Physician_List_Format__c,RecordTypeId,Status,Subject FROM Case
        lFields = new list<string>{'AccountId','CaseNumber','Status','Subject','Physician_List_Format__c'};
        ltemps = new list<string>{'AccountId','CaseNumber','Status','Subject','Physician_List_Format__c'};
        mLists = new map<string, list<string>>();
        mLists.put('List1', lTemps);
        ltemps = new list<string>{'Origin', 'OwnerId', 'RecordTypeId','ContactId','Budget__c'};
        mLists.put('List2', lTemps);    
        lFields.add('Origin');lFields.add('OwnerId'); lFields.add('RecordTypeId');lFields.add('ContactId'); lFields.add('Budget__c');   
        for(string s : lFields){
            boolean Matches = false;
            for(string p : mLists.get('List1')){
                if(s.equals(p)){Matches=true;} 
            }
            for(string p : mLists.get('List2')){
                 if(s.equals(p)){Matches=true;}           
            }                
            system.debug('value of: ' + s + ' has a Match: ' + Matches);
            system.assert(Matches,'Match Failure on value: ' + s);
        }
        
    }
}

 And the page:

 

<apex:page standardController="Case" extensions="Admin_FieldSetTest">
<apex:form >
    <apex:pageblock title="The Lists" >
        
        <apex:pageblocksection title="All the Fields" columns="2">
            <apex:repeat value="{!lFields}" var="f">
           <apex:outputfield value="{!Case[f]}" />            
            </apex:repeat>           
        </apex:pageblocksection>
        
    <apex:pageblocksection title="Field List" >
            <apex:repeat value="{!lFields}" var="f">
            {!f}          
            </apex:repeat>           
        </apex:pageblocksection>
        <apex:repeat value="{!mLists}" var="m">
            <apex:pageBlockSection title="{!m}" columns="2">
                <apex:repeat value="{!mLists[m]}" var="f">
                <!-- This Causes my Invalid Field Core Error -->    
                <!-- <apex:outputfield value="{!Case[f]}" /> -->
                    {!f} <!-- This Works just fine -->
                </apex:repeat>
            </apex:pageBlockSection>
        </apex:repeat>
    </apex:pageblock>
    </apex:form>
</apex:page>

 

Output: Output of page

In case the picture doesn't load: http://twitpic.com/9yo0ja