1

enter image description here

Visualforce Page

<apex:page docType="html-5.0" showHeader="false" controller="TaskRayController">
    <apex:form >
        <html>
            <head>
                <apex:slds />
            </head>
        </html>
        <apex:repeat value="{!wrapperMap[India]}" var="key" id="Repeat12">
                <apex:repeat value="{!wrapperMap[India][key]}" var="wrp" id="Repeat21">
                    <apex:input styleClass="slds-float--right" value="{!wrp.xc1}" style="width:112px;border-color: black;border-width: 1px;"></apex:input>
                </apex:repeat>
            </apex:repeat>
    </apex:form>
</apex:page>

Apex Class

public class TaskRayController {
    
    public TaskRayWrapper wrapper {get;set;}
    public Map<String,Map<String,TaskRayWrapper>> wrapperMap{get;set;}
    
    
    public TaskRayController() {
        wrapper = new TaskRayWrapper();
        wrapperMap = new Map<String,Map<String,TaskRayWrapper>>();
         map<string,TaskRayWrapper> tempMap = new map<string,TaskRayWrapper>();
        TaskRayWrapper wrpTemp = new TaskRayWrapper();
        
        tempMap.put('XC1', wrpTemp );
        wrapperMap.put('India',tempMap);
        
        List<TASKRAY__Project__c> records = [select id , Name,CreatedDate,Country__c  from TASKRAY__Project__c  
                                             order by CreatedDate desc limit 1];
        system.debug('currentRecord-->'+records);
    }
}

Wrapper Class

public class TaskRayWrapper {
    public string xc1{get;set;}
    public string xc1Comments {get;set;}
    
    public TaskRayWrapper(){
        xc1 = null;
        xc1Comments = null;
        
    }

}
1
  • 2
    You have tried to use a symbol, India, in the expression instead of using a string. Try value="{!wrapperMap['India']}" instead.
    – Phil W
    Nov 1 '21 at 7:01
2

Your syntax first is incorrect.

You have written <apex:repeat value="{!wrapperMap[India]}" var="key" id="Repeat12"> It should be <apex:repeat value="{!wrapperMap['India']}" var="key" id="Repeat12"> India with 'India'. So that VF page recognizes it's a key from Map.

Rest I can see it working perfectly fine.

TaskRayWrapper wrpTemp = new TaskRayWrapper();
wrpTemp.xc1 = 'Hi';
wrpTemp.xc1Comments = 'Hi Comment';
tempMap.put('XC1', wrpTemp );
wrapperMap.put('India',tempMap);

enter image description here

2
  • Thanks it works fine now. Just one more question what if I have 2 input and I want to catch multiple values in same variable XC1, is it possible? Nov 1 '21 at 7:29
  • Then this map, map<string,TaskRayWrapper> tempMap = new map<string,TaskRayWrapper>(); should change to map<string,List<TaskRayWrapper> tempMap = new map<string,List<TaskRayWrapper>(); Nov 1 '21 at 7:40

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.