+ Start a Discussion
Vijay Kumar Rebbala 11Vijay Kumar Rebbala 11 

Set map values from visualforce page

<apex:pageBlock>
                <apex:pageBlockTable value="{!Questions}" var="ques" id="questable">
                    <apex:column headerValue="Question">
                        <apex:inputText value="{!Questions[ques]}" id="quesid" style="width: 500px;"/>
                    </apex:column>
                    <apex:column headerValue="Language">
                        <apex:OutputText value="{!ques}" id="langid"/>
                    </apex:column>
                </apex:pageBlockTable>
</apex:pageBlock>
My apex code: 
public Map<String,String> Questions {
        get {
            return new Map<String, String> {
                'French' => '', 
                'German' => '', 
                'Italian' => '',
                'Japanese' => '', 
                'Korean' => '', 
                'Portuguese' => '',
                'Russian' => '', 
                'Chinese Simplified' => '', 
                'Spanish' => '',
                'Chinese Traditional' => ''
            };
        }
        set;
}

Problems is, I cannot access the input text from vfp to maps in apex code.
 
Best Answer chosen by Vijay Kumar Rebbala 11
Rohit K SethiRohit K Sethi
Hi Vijay,

Use below code this will resolve your issue.
public Map<String,String> Questions {set;get;}
public controller(){
    Question = new Map<String, String> {
                'French' => '', 
                'German' => '', 
                'Italian' => '',
                'Japanese' => '', 
                'Korean' => '', 
                'Portuguese' => '',
                'Russian' => '', 
                'Chinese Simplified' => '', 
                'Spanish' => '',
                'Chinese Traditional' => ''
    };
}


Thanks.