• Basu, Saikat
  • NEWBIE
  • 0 Points
  • Member since 2019


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
I have below controller:
public class MyController {
public string cString { get; set;}

public string getStringMethod1(){
return cString;
}

public string getStringMethod2(){
if(cString == null)
cString = 'Method2';
return cString;
}
}
VF:
<apex:page controller="MyController">
{!cString}, {!StringMethod1}, {!StringMethod2}, {!cString}
</apex:page>
Actual Output:
, , Method2,

But I am expecting output : , , Method2,Method2

Why so? Why is cString value not retained though it is being set in getStringMethod2 method?