You need to sign in to do that
Don't have an account?
Issue with apex:attribute type="map"
I am having issue to assign a map from<apex:attribute type="map" assignedTo={!method}
Getting the below error message:
Error: Type mismatch for <apex:attribute assignTo>. Value binding to a property of type MAP<Object,Object> is required, property specified is of type MAP<String,String>. |
Below is the code snipet I am using:
VF Component:
<apex:attribute name="leftOptions" description="Map for left Picklist" type="map" required="true" assignTo="{!test}"/>
Definition in Controller:
public Map<String,String> test {get;set;}
Note: the same errot comes for below definitions as well -
public Map<Account,Contact> test {get;set;}
public Map<sObject,sObject> test {get;set;}
Please let me know anyone need more information to help. Thanks in advance.
Hi,
I think you cannot define a map with object types. Please go through the below URL for detail descrption on maps.
http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_collections_maps.htm
and for <apex:attribute pl. follow the below URL.
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_attribute.htm
Regards,
Sridhar Bonagiri
Hi Sridhar, thanks for your reply.
I think I am missing something here, you mean to say I cannot define a Map<String, String>()?
Also, to give you litle more info -
From my code snipet -
If I just remove RED marked, both page and controller gets saved without any issue -
Page:
<apex:attribute name="leftOptions" description="Map for left Picklist" type="map" required="true" assignTo="{!test}"/>
Definition in Controller:
public Map<String,String> test {get;set;}
Could you please help me with a simple example of apex:attribute type="map" where you are assigning the map into controller variable? (an example for below in other words!):
Thanks again for your time and help. Really appriciate!
Bump.
It is apparent that the assignTo parameter of apex:attribute does not support maps, period.
Even when the map property in the Apex controller is defined as a Map<Object,Object> it still doesn't work. What's worse is that the error message displayed is:
"Save error: Type mismatch for <apex:attribute assignTo>. Value binding to a property of type MAP<Object,Object> is required, property specified (testOptions) is of type MAP<ANY,ANY>."
Besides being a clear defect, this error message is incredibly silly.
I got the same error "Save error: Type mismatch for <apex:attribute assignTo>. Value binding to a property of type MAP<Object,Object> is required, property specified (testOptions) is of type MAP<ANY,ANY>." when trying to assign a map to a variable of controller using apex:attribute. It is still not supported for the Summer 13. Seems we can only use the map to display information not to pass it to the controller