1

I have a VF component which has the following code, where the item variable is of type Map<String, object>:

<apex:outputPanel value="{!item['Id']}" />
<apex:commandLink value="View Details" action="{!setActiveItem}" reRender="{!$Component.su_form.su_details}">
  <apex:param name="itemId" value="{!item['Id']}}"/>
</apex:commandLink>

The outputPanel displays the ID of the item properly. However, the parameter is null in the controller. If I statically set the value of the parameter, such as like this <apex:param name="itemId" value="{!'a0R0a00000B5hNeEAJ'}"/> then I can see the Id value in the controller.

So I know that the VF Component is passing the parameter properly, and I know that the 'Id' key is not null in the item map. However, in the code block above, I get a null value in the controller. Why would this be?

2 Answers 2

1

I'm sorry to say that you can't pass an object as a parameter. Salesforce says:

The value attribute must be set to a string, number, or boolean value.

So you'll have to extract the value you want from the map and grab it in the controller. Since you have the id, you can just pass that and extract the correct map in the controller.

Reference is here

2
  • Thanks. I was passing an ID, but since it was of type object it wasn't working. I found a way to pass an actual ID type and it worked. Apr 24, 2017 at 20:24
  • Hi @CuriousBlueprints, can you tell us how did you make it work?
    – ajinkyah
    Jan 17, 2018 at 6:45
0

You have to set the map properly. Map is of type . So you have to set that from param by using a 2nd [], like following -

<apex:param name="itemId" value="{!item['Id'][<Your Object value>]}}"/>
1
  • I don't understand why I would use a second set of brackets. It isn't a Map<String, Map<>>. It is Map<String, Object>, in this case an Id. item['Id'] resolves to 'a0R0a00000B5hNeEAJ'. How would adding a second set of brackets help? Apr 24, 2017 at 14:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .