anusha(salesforce developer)

Friday, 29 July 2016

How to use <apex:param>  in Visualforce Page?

<apex:param> :
A parameter for the parent component. The < apex:param > component can only be a child of the following components:

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

Within < apex:outputText >, there is support for the < apex:param > tag to match the syntax of the MessageFormat class in Java.

This tag supports following attributes:

Attribute
Description
assignTo
A setter method that assigns the value of this param to a variable in the associated Visualforce controller. If this attribute is used, getter and setter methods, or a property with get and set values, must be defined.
id
An identifier that allows the param component to be referenced by other components in the page.
name
The key for this parameter, for example, name="Location".
value
The data associated with this parameter, for example, value="San Francisco, CA". The value attribute must be set to a string, number, or boolean value. Note that value is the only required attribute for a param component because it is all that is needed when performing a string replacement. For example, if you use "My {0}" as the value of an outputText component and then include a param in the body of the outputText component, the value of the param tag replaces the {0} in the output text string.


Visualforce Example:

<apex:page standardController="Contact">
    <apex:outputLink value="http://google.com/search">
        Search Google
        <apex:param name="q" value="{!contact.name}"/>
    </apex:outputLink>
</apex:page>

Note: 


For this example to render properly, you must associate the Visualforce page with a valid contact record in the URL.
For example, if 001D000000IRt53 is the contact ID, the resulting URL should be:
https://Salesforce_instance/apex/myPage?id=001D000000IRt53
- See more at: http://sfdcgurukul.blogspot.in/2013/08/apexparam.html#sthash.hK9C70CN.dpuf
Note:
For this example to render properly, you must associate the Visualforce page with a valid contact record in the URL.
For example, if 001D000000IRt53 is the contact ID, the resulting URL should be:
https://Salesforce_instance/apex/myPage?id=001D000000IRt53






No comments:

Post a Comment