+ Start a Discussion
suresh dupadasuresh dupada 

Please explain below code regarding hyperlink tag

<apex:page controller="DataTableEditRemoveController">
<apex:form id="form" >
<apex:pageBlock title="Accounts">
  <apex:pageMessages ></apex:pageMessages>
  <apex:pageBlockTable value="{!accs}" var="row">
     <apex:column >
       <apex:outputLink title="" value="/{!row.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="font-weight:bold">Edit</apex:outputLink>&nbsp;|&nbsp;
       <a href="javascript:if (window.confirm('Are you sure?')) DeleteAccount('{!row.Id}');" style="font-weight:bold">Del</a>
     </apex:column>

     <apex:column value="{!row.Name}"/>
     <apex:column value="{!row.BillingStreet}"/>
     <apex:column value="{!row.BillingCity}"/>
     <apex:column value="{!row.BillingPostalCode}"/>
     <apex:column value="{!row.BillingCountry}"/>
  </apex:pageBlockTable>
</apex:pageBlock>

<apex:actionFunction action="{!DeleteAccount}" name="DeleteAccount" reRender="form" >
   <apex:param name="accountid" value="" assignTo="{!SelectedAccountId}"/>
</apex:actionFunction>
</apex:form>
</apex:page>
********************
public class DataTableEditRemoveController {

   public List<Account> accs { get; set; }
 
   //used to get a hold of the account record selected for deletion
   public string SelectedAccountId { get; set; }
 
   public DataTableEditRemoveController() {
       //load account data into our DataTable
       LoadData();
   }
 
   private void LoadData() {
       accs = [Select id, name, BillingStreet, BillingCity, BillingPostalCode, BillingCountry from Account limit 20];
   }
 
   public void DeleteAccount()
   {
      // if for any reason we are missing the reference
      if (SelectedAccountId == null) {
     
         return;
      }
    
      // find the account record within the collection
      Account tobeDeleted = null;
      for(Account a : accs)
       if (a.Id == SelectedAccountId) {
          tobeDeleted = a;
          break;
       }
     
      //if account record found delete it
      if (tobeDeleted != null) {
       Delete tobeDeleted;
      }
    
      //refresh the data
      LoadData();
   }   
 
 
}
PratikPratik (Salesforce Developers) 
Hi Suresh,

The page and Class are to basically to show the account records with mentioned column in a table with "Edit" & "Del" link to these records.

The highlighted part of code, it will show first column of row with hyperlink and will link it to it's ID to edit. the next line is same for Delete but i don't see the delete operation in the delet method. (There is standard controller method to Delete available that you can use.) 

Thanks,
Pratik