AssignTo method in apex (Salesforce)

| By Webner

AssignTo method is a getter method in Salesforce. It is used to assign the value of an attribute to a class variable in the associated custom component controller. Getter and Setter methods or a property with get and set values must be defined, if this attribute is to be used.

Here is an example: Visualforce page:

<apex:page controller=”Test" >
<apex:form >
<apex:outputText value="{!var}" id="a"/><br/>    
<apex:commandButton value="Show" action="{!show}" rerender="a">
<apex:param assignTo="{!var}" value="orgn"/>

Apex Controller:

public class Test
public String var {get;set;}
public sample()
var = 'org';
public void show()

Before Clicking Show button:


Leave a Reply

Your email address will not be published. Required fields are marked *