assignTo in Apex

A setter method that assigns the value of this attribute to a class variable in the associated custom component controller. If this attribute is used, getter and setter methods, or a property with get and set values, must be defined.

Visualforce page:

<apex:page controller="sample" >
    <apex:form >
    <apex:outputText value="{!var}" id="a"/><br/>   
    <apex:commandButton value="Demo" action="{!demo}" rerender="a">
        <apex:param assignTo="{!var}" value="orgn"/>

Apex Controller:

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


Before clicking Demo Button:

After clicking Demo Button:

org has been changed to 'orgn' after clicking Demo button because orgn has been assigned to  var.

No comments:

Post a Comment

Sharing is Caring!!! Share this with your friends!!!

submit to reddit