Very often you would need to either display data from Force.com database or insert data in database variables. Well Force.com platform uses 'Controllers' to do the same task. A 'Controller' is just an APEX code that reads and writes data in the model that is the Force.com database. The variables in the database interact with the presentation layer using "getter" and "setter " methods of the Controller. Using the 'getter' method its possible to get the value of the variable and display it on the Visualforce pages. Similarly a setter method allows the user to change the value of the variable using the Visualforce components like text box.
Now there is something about this Force.com platform which is so majical. It provides default controller implementations called Standard Controllers. These standard controllers provide for the behaviour of native interface like 'editing' or 'creating' records. Now you can also customize these controllers using controller extensions (classes written in Apex). also you can implement controllers which are totally user defined called Custom Controllers.
Lets take a look at a simple example:
TestPage Code:
<apex:page controller="MyController">
<apex:form>
Name: <apex:inputText value="{!name}"/>
<apex: outputText value="{!mssg}"/>
<apex:commandLink action="{!Display}" value="Show Message" />
</apex:form>
</apex:page>
MyController Code:
public class MyController{
public String name {get ; set;}
public String mssg {get ; set;}
public PageReference Display() {
mssg='Good Morning' + name;
return null;
}
}
Now there is something about this Force.com platform which is so majical. It provides default controller implementations called Standard Controllers. These standard controllers provide for the behaviour of native interface like 'editing' or 'creating' records. Now you can also customize these controllers using controller extensions (classes written in Apex). also you can implement controllers which are totally user defined called Custom Controllers.
Lets take a look at a simple example:
TestPage Code:
<apex:page controller="MyController">
<apex:form>
Name: <apex:inputText value="{!name}"/>
<apex: outputText value="{!mssg}"/>
<apex:commandLink action="{!Display}" value="Show Message" />
</apex:form>
</apex:page>
MyController Code:
public class MyController{
public String name {get ; set;}
public String mssg {get ; set;}
public PageReference Display() {
mssg='Good Morning' + name;
return null;
}
}

No comments:
Post a Comment