0

I have Written Apex Class:

public class one{
   public PageReference method() {
      return null;
   }
   public string acName{set;get;}
   public integer acPhone{set;get;}
   public List<Account> accs{set;get;}
   public string accid {set;get;}
   public pagereference save(){
       //accid = apexpages.currentPage().getParameters().get('id');
       accs = [select id,name,phone,type from account limit 10];
       return null;
   }
}

VisualForce Page:

<apex:page controller="one" action="{!save}">
    <apex:form >
        <apex:pageBlock id="one">
            <apex:pageBlockTable value="{!accs}" var="a">
                <apex:column value="{!a.id}"/>
                <apex:column value="{!a.name}"/>
                <apex:column >
                <apex:commandButton value="click" action="{!save}" reRender="two">
                <apex:param name="accountName" value="{!a.name}" assignTo="{!acName}"/>
                </apex:commandButton>
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
        <apex:pageBlock id="two">
            <apex:pageBlockSection >
                <apex:pageBlockSectionItem >
                ID:{!acName}
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection> 
        </apex:pageBlock>
    </apex:form>
</apex:page>

what is the use of this Line:

<apex:param name="accountName" value="{!a.name}" assignTo="{!acName}"/>

if I Remove this Line also it is Not showing any Effect in the output,anyone explains the Logic for <apex:param> tag

2 Answers 2

0

In general term, the <apex:param> tag is used to pass values from JavaScript to an Apex controller, it can be used with the following parent tags.

apex:actionFunction

apex:actionSupport

apex:commandLink

apex:outputLink

apex:outputText

flow:interview

Reference

1
<apex:commandButton value="click" action="{!save}" reRender="two">
    <apex:param name="accountName" value="{!a.name}" assignTo="{!acName}"/>
</apex:commandButton>

In general word, when you click on this button. apex:param will assign the a.name value to controller acName variable. This way you can get the Account name in controller

13
  • when i click the command button No action is Performed in the output, how to identify for the apex param value, shall i set any Debug log for this apex class
    – SFDC
    Commented Aug 23, 2016 at 6:15
  • what value should store in {!a name}, what Value should assigned,Please anyone explain Clearly
    – SFDC
    Commented Aug 23, 2016 at 6:18
  • @user36188 whatever value will have in account.name that value will assign to acName variable..
    – Ratan Paul
    Commented Aug 23, 2016 at 6:19
  • what is the use of <apex param>
    – SFDC
    Commented Aug 23, 2016 at 6:20
  • 1
    You are always Great @Ratan
    – SFDC
    Commented Aug 23, 2016 at 7:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .