Apex class to demonstrate setter method

Apex class to demonstrate setter method:


i.e Passing the values and saving the values to apex variables in Apex class:-

Public class Example
{
Public String name;
Public string getName()
 {
 return name;
   }


Public void setName(string name)
{
this.name=name;
  }
 }

VF Page:-

   <apex:page controller="Example">
  <apex:form>
  <apex:outputLabel> entername</apexoutputLabel>
 <apex:inputText value="{!name}"
<apex:commandButton value="click" reRender="one"/>
<apex:outputLabel id="one"> Your name is {!name} </apex:outputLabel>
 </apex:form>
<apex:page>

we can also define setter and getter methods in a single line.
     
      Public Integer{set;get;}


No comments:

Post a Comment