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}"/>
</apex:commandButton>
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}"/>
</apex:commandButton>
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.
Best Answer
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:
will work if
d.theDeal
is an SObject and if thedeal
property is pre-populated with aDeal__c
object. Or you might choose to add a separatedealId
property to the controller (of type ID):so it is clearer what is going on.