You need to sign in to do that
Don't have an account?
Command button pass ID to function
I have a datatable on a visualforce page that lists tickets. I have one column on the datatable that has a button that will redirect to a page with details about the ticket.
Here is the portion of the visualforce page that affects the current issue:
<apex:form > <apex:dataTable value="{!openTickets}" var="OT" width="80%" rowClasses="odd,even" cellspacing="1px" cellpadding="5px"> <apex:column value="{!OT.id}"><apex:facet name="header">Ticket ID</apex:facet></apex:column> <apex:column ><apex:commandButton value="Ticket Details" action="{!redirectTicketDetails}"/></apex:column> </apex:dataTable> </apex:form>
Here is the apex extension:
public PageReference redirectTicketDetails(){ PageReference pageRef = new PageReference('/apex/ticketDetails'); return pageRef; }
The button works correctly. What I would like to be able to do though is have the page it redirects to be /apex/ticketDetails?id=******* but replace the ****** with the id from the ticket where they clicked on the button. I am pretty new to apex and am learning as I go. How would I go about doing this? Any help would be appreciated.
I found my own answer. For anyone that needs it here is what I did. I changed the command button from
To
Then I was just able to get rid of the method entirely.
All Answers
I found my own answer. For anyone that needs it here is what I did. I changed the command button from
To
Then I was just able to get rid of the method entirely.
you should have a look at the apex:param
Something like this