+ Start a Discussion
kishore64kishore64 

what is the main use of param tag, when we use in visual force pages

Ramesh KallooriRamesh Kalloori
apex:param tag is used to pass the parameters from visualforce to controller.

please go through the below example.

<apex:page controller="ParamCon" >
<apex:form >
<apex:commandLink action="{!Send}" value="Send">
<apex:param name="h" value="Hai" assignTo="{!s1}"/>
</apex:commandLink>
  </apex:form>
</apex:page>
public class ParamCon {
public String s1{get;set;}
    public PageReference Send() {
         PageReference openvfpage = New Pagereference('/apex/ParamRecieveVF');  
        openvfpage.getParameters().put('account',s1);
        openvfpage.setRedirect(false);
        return openvfpage ;        
    }

}

<apex:page controller="ParamRecieveCon" >
 {!$CurrentPage.parameters.account}
</apex:page>

thanks,
Ramesh

SFDC_DevloperSFDC_Devloper
Hi Kishore,

Basically the apex:param tag is used to pass values from the Visualforce Page to the Apex Controller. A simple Example could be this:

Here Example:
Display all the Leads in the Database in a tabulated form. There should be 2 Columns in which the first column would display the Lead Name and the last column will have a Delete button. When the User clicks the Delete button, the corresponding Lead will be Deleted from the Database.

Visual Force Page:
<apex:page controller="ApexParamDemoController">
  <apex:form id="form">
    <apex:pageBlock>
      <apex:pageBlockTable value="{!AllLeads}" var="Lead">
        <apex:column value="{!Lead.Name}"/>
        <apex:column>
          <apex:commandButton value="Delete" action="{!deleteRecord}" reRender="form">
            <apex:param 
              name="leadToDelete" 
              value="{!Lead.Id}" 
              assignTo="{!RecordToDelete}"/>
          </apex:commandButton>
        </apex:column>
      </apex:pageBlockTable>
    </apex:pageBlock>
  </apex:form>
</apex:page>

Controller:
public class ApexParamDemoController{
    
    public Id RecordToDelete {get; set;}
    
   
    public List<Lead> AllLeads{
        get{ return [SELECT Id, Name FROM Lead]; }
    }
    
    
    public void deleteRecord(){
        DELETE new Lead(Id = RecordToDelete);
    }
}
[If it helps, mark it as "Best Answer"]



Thanks,
Rockzz

sivaextsivaext
Hi, 

Param tag is used to send values from visualforce page to controller, it used with commandbutton, commandlink and action vf tags.