You need to sign in to do that
Don't have an account?
Arun Kharb
Binding the values of a Map on VF page dynamically not working
Hi All,
I have a page in which I am rendering various fields of different datatype based on some condition.
Here is the controller code for this.
Now, Whenever I am trying to submit the page without filling up any value in selectlist, radiobutton and many more types excluding text Input Type. I am getting following error:
and If I fill out all the values like select something in select list and check all radio buttons then No Error is thrown. I am not even Using REQUIRED Attribute here.
Any Help would be very much appreciated.
I have a page in which I am rendering various fields of different datatype based on some condition.
Here is the controller code for this.
public Map<String,String> finalselectedvalues{get;set;} public map<String,List<SelectOption>> dataarraymap{get;set;} public List<Objectname> lstProducts{get;set;} public demoController() { finalselectedvalues=new Map<String,String>(); dataarraymap=new Map<String,List<SelectOption>>(); SelectedValues=new Map<String,String>(); lstProducts=[//query to get values]; lst.add(new SelectOption('Default','----none---- ')); dataarraymap.put(String.valueof(obj.name),lst); for(objectname obj:lstProducts) { if(obj.Attribute_Type__c=='Heading' || obj.Attribute_Type__c=='State Coverage') //many more condition goes here { List<selectOption> lst=new List<selectOption>(); lst.add(new SelectOption('Default','----none---- ')); dataarraymap.put(String.valueof(obj.name),lst); } finalselectedvalues.put(obj.name,' '); } }and in vf page i am rendering different type of input fields like this:
<apex:repeat id="dvProducts" value="{!lstProducts}" var="product"> <apex:outputPanel rendered="{!IF(product.Attribute_Type__c=='State Coverage',TRUE,FALSE)}" > <apex:selectList value="{!finalselectedvalues[product.name]}" size="3" multiselect="true" > <apex:selectOptions value="{!dataarraymap[product.name]}" /> </apex:selectList> </apex:outputPanel> </apex:repeat>
Map key {{keyvalue}} not found in map Error is in expression '{!finalselectedvalues[key]}'
and If I fill out all the values like select something in select list and check all radio buttons then No Error is thrown. I am not even Using REQUIRED Attribute here.
Any Help would be very much appreciated.
There might be issue with your map not having a specific value and trying to get that value is causing your the error. I am not sure if this is complete code, but assuming you are using finalSelectedValue only in one place. try doing this in your page
I have tried printing them in debug as well as on VF page and all are returning the required output.