+ Start a Discussion

edit method in visual force page

hello goup,



       i hav a few records in page block table


          i placed an edit link (command link) in vf page 



<apex:column headerValue="Action">
<apex:commandLink value="Edit" action="{!Edit}" id="edit"/>


               my requiremnt is i want to edit a single record 


                   how can achieve this by writing code in controller class


                   can any one help me to achieve my requiremnt.....



   thanks for giving reply in advance       






Hengky IlawanHengky Ilawan



To access the standard edit page basically is just adding "/e" to the end of the detail page URL. For eq "/<record id>/e".


So, if your link is only for redirecting user to the standard edit page, you can use apex:outputLink instead.


<apex:outputLink value="/{!therecordId}/e" id="edit">Edit</apex:outputLink>

Or if you need to use commandlink, then call the edit method of pagereference class in your action method:


PageReference editPage = new ApexPages.StandardController(<theSobjectVariable>).edit();
return editPage;

More detail on page reference class: