I'm trying to pass a parameter with a commandButton. I've seen a few ways to do it on the net, but they don't work. What I have now:

<apex:commandButton value="Accept" action="{!acceptDeal}" disabled="{!d.buttonsAreDisabled}">
    <apex:param name="deal" value="{!d.theDeal}" assignTo="{!deal}"/>

the parameter is not being passed through. Many posts suggest to add reRender to my commandButton, but when I try that

<apex:commandButton value="Accept" action="{!acceptDeal}" disabled="{!d.buttonsAreDisabled}" rerender="someRerenderText">
    <apex:param name="deal" value="{!d.theDeal}" assignTo="{!deal}"/>

I get the following error:

Visualforce Error

A String, Number, or Boolean is required for attribute 'value' in <apex:param>.

Another option was to change commandButton to commandLink with styleClass="btn" attribute, but commandLink does not have disabled attribute that I need.

  • It looks like the rerender is helping but just moving you on to the next problem. What exactly are d.theDeal and deal? – Keith C Nov 12 '14 at 11:44
  • @KeithC d is a variable responsible for table rows. Each table row is an object in apex code which contains a few other objects from salesforce. Table row is an inner class in the controller. Deal is a parameter name and there is also a deal property in the apex class that represents my custom object Deal__c. – Novarg Nov 12 '14 at 12:41

As the error message explains, apex:param can only handle primitive values not whole objects. Your description of types isn't entirely clear to me but something like this:

<apex:param name="deal" value="{!d.theDeal.Id}" assignTo="{!deal.Id}"/>

will work if d.theDeal is an SObject and if the deal property is pre-populated with a Deal__c object. Or you might choose to add a separate dealId property to the controller (of type ID):

<apex:param name="deal" value="{!d.theDeal.Id}" assignTo="{!dealId}"/>

so it is clearer what is going on.

| improve this answer | |

I faced a similar problem. Although I couldn't find the reason why, but it was solved when I just added reRender="". I put nothing inside the quotes. I read on one of the posts that this is a mandate for the param to go through. Although I still don't know why. It worked in my case though. Hope it works for you too.

| improve this answer | |

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.