Different Ways Of Using Apex:Param Tag

Aside

What Is Parm Tag?
<apex:Param> :- apex:param tag is used to hold java Script values.
param means parameter. This tag is also used to Pass values from 
java Script to an Apex controller. 

The <apex:param> component can only be a child of the following components:

  • <apex:actionFunction>
  • <apex:actionSupport>
  • <apex:commandLink>
  • <apex:outputLink>
  • <apex:outputText>
  • <flow:interview>

Syntax:

 <apex:param name="ParamName" value"{!someValue}" assignTo="{!someproperty}"/> 

value : Required = T R U E

Ques)So, When To Use assingTo & value And How To Use It?
Ans:
If you use value u can set the value to the query string param name like

<apex:param name="ParamName" value"1234"/> 

& Now, You can access this value in the controller using

Integer res=apexpages.currentpage().getparameters.get('ParamName');

 

If you use assingTo attribute then this will asigen the value to a property in the controller.
In Visualforce Page:

 <apex:param name="ParamName" value"{!someValue}" assignTo="{!someproperty}"/> 

In The Controller:

public string someproperty {get;set;} 

Now The Value What is Present in Value shall be assign to someproperty

 

Example:


<apex:page controller="paramexample">
 <apex:form >
 <apex:pageblock >
<apex:pageblockTable title="Accounts" value="{!acclist}" var="a">
<apex:column headervalue="Account name">
<apex:commandlink reRender="out" action="{!Paramdemo}">
{!a.name}
<apex:param name="aid" value="{!a.name}" assignTo="{!accname}"/>
</apex:commandlink>
</apex:column>
<apex:column value="{!a.phone}"/>
<apex:column value="{!a.industry}"/>
</apex:pageblockTable>
</apex:pageblock>

<apex:outputpanel id="out">
accname = {!accname}
</apex:outputpanel>

 </apex:form>
</apex:page>
public class paramexample
{
public string accname{get;set;}
public list<account> acclist { get; set; }

public paramexample(){
acclist = new list<account>();
for(account a : [select id, name, phone, industry from account limit 20])
acclist.add(a);
}

public void Paramdemo() {}
}
}

 

param example

ssing  param example

Click This To Know  Passing Parameters Using Javascript & ActionFunction