You need to sign in to do that
Don't have an account?
Passing Parameters with Commandbutton
I want to pass one parameter when user clicks on a command button.
I tried the following
<apex:commandButton action="{!registerForEvent}" value="Register" title="Register">
<apex:param name="eventId" value="{!r.id}" assignTo="{!eventId}"/>
</apex:commandButton>
It does not work. The eventid value is coming as null in the controller.
I was searching through the posts and found a few that says that this is a bug and parameters cannot be passed with command button. Some posts say, it works using assignTo attribute and having proper getter and setter methods for the assignTo variable. It is not working for me.
Is it working for anyone? Please let me know.
Hai
You can pass Parameter ,find below small test program
// Controller
Regards
Thanga
Thanks for posting the code. Your finding is correct and is passing the param in the sample code.
But when you remove rerender attribute from the command button it looses the value.
<apex:commandButton value="Go!" action="{!passParam}" rerender="block" >
Somehow it is not behaving properly.
If you get a chance please retest and let me know what you find.
This has been a bug for a while now. If you change your commandbutton to a commandlink it will work. You can then style the link to look like a button.
Wes
and that reRender is required but the block doesn't actually need to exist.