You need to sign in to do that
Don't have an account?
Gyanendra Singh 8
Getter and Setter behaviour
Below is a simple visualforce page which is self understood and the controller class:
VFPage----------
<apex:page controller="TestController1">
<apex:form >
<apex:pageBlock title="My Content" mode="edit">
<apex:pageBlockSection title="My Content Section" columns="2">
<apex:inputText value="{!acc}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller Class------------------
public class TestController1 {
public String S1;
public String acc {
get;
set{
S1='Hello'; }
} }
Now I want to know this. When I comment out the line S1='Hello' then my getter works and returns whatever text I enter in the inputText field. But when I don't comment out S1='Hello' or basically if I write any other statement/expression APART from the expression which sets some value to the Property acc (like acc='Wassup'. And in this case the getter returns Wassup or whatever I set the value of acc) the getter method does not return anything. Why is this behaviour?
This is purely for learning purpose.
Thank you
VFPage----------
<apex:page controller="TestController1">
<apex:form >
<apex:pageBlock title="My Content" mode="edit">
<apex:pageBlockSection title="My Content Section" columns="2">
<apex:inputText value="{!acc}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller Class------------------
public class TestController1 {
public String S1;
public String acc {
get;
set{
S1='Hello'; }
} }
Now I want to know this. When I comment out the line S1='Hello' then my getter works and returns whatever text I enter in the inputText field. But when I don't comment out S1='Hello' or basically if I write any other statement/expression APART from the expression which sets some value to the Property acc (like acc='Wassup'. And in this case the getter returns Wassup or whatever I set the value of acc) the getter method does not return anything. Why is this behaviour?
This is purely for learning purpose.
Thank you
* query isn't quite the right word, but it fits best. It is more pulled from the state variable that is passed to the save method on the button click.