Background
I'm working with two VF pages, OutOfOffice and AddNewOutOfOffice. The OutOfOffice page displays a list of custom object records. For each record there is an edit and a delete button. There is also a single 'add new' button at the top the OutOfOffice that links to the AddNewOutOfOffice page.
Issue
I need the edit button(s) on the OutOfOffice to link to the AddNewOutOfOffice page and pass the record ID into the URL. However with my current code, when I click the edit button I get the url /AddNewOutOfOffice?id=null
Here's what I have so far for the edit button in the VF Page:
<apex:repeat value="{!OOOrecs}" var="OOO">
<apex:commandButton value="Edit" action="{!EditOutOfOffice}"/>
<apex:param name="oooIdEdit" value="{!OOO.id}" assignTo="{!oooIdEdit}"/>
<apex:commandButton value="Delete" action="{!deleteOOO}" rerender="all">
<apex:param name="oooIdDelete" value="{!OOO.id}" assignTo="{!oooIdDelete}"/>
</apex:commandButton>
<br/><br/>
</apex:repeat>
and controller:
public String oooIdEdit {get;set;}
public PageReference EditOutOfOffice() {
return new PageReference('/AddNewOutOfOffice/?id='+oooIdEdit);
}
Best Answer
This is a known issue,use rerender with commandbutton to fix this (or) use command link and style it to make it look like a command button :
https://success.salesforce.com/ideaView?id=08730000000YcV8AAK
Why does apex:param assignTo work with apex:commandLink but not apex:commandButton?