+ Start a Discussion
Ritika SinghRitika Singh 

Custom controller and VFP

A developer creates a customer controller and custom Visualforce page by using the following code block:
public class myController { public String myString;
public String getMyString() { return 'getMyString';
}
public String getStringMethod1() { return myString;
}
public String getStringMethod2() { if (myString == null)
myString = 'Method2'; return myString;
}
}

<apex:page controller="myController">

{!myString}, {!StringMethod1}, {!StringMethod2}, {!myString}

</apex:page>


What does the user see when accessing the custom page?

a.    getMysString, , Method2, getMyString
b.    , , Method2, getMyString
c.    , , Method2,
d.    getMyString, , ,
 
Best Answer chosen by Ritika Singh
Santosh Kumar 348Santosh Kumar 348
Hi Ritika,
The answer is :
a.    getMyString, , Method2, getMyString

As first when you called 
{!myString} : getMyString() is called and value is 'getMyString'.
{!StringMethod1} : it calls getStringMethod1() and value is blank or ''.
{!StringMethod2} : it calls getStringMethod2() and value is 'Method2'.
{!myString} : getMyString() is called and value is 'getMyString'.

Do let me know if it helps you and close your query by marking it as solved.

Regards,
Santosh

All Answers

Santosh Kumar 348Santosh Kumar 348
Hi Ritika,
The answer is :
a.    getMyString, , Method2, getMyString

As first when you called 
{!myString} : getMyString() is called and value is 'getMyString'.
{!StringMethod1} : it calls getStringMethod1() and value is blank or ''.
{!StringMethod2} : it calls getStringMethod2() and value is 'Method2'.
{!myString} : getMyString() is called and value is 'getMyString'.

Do let me know if it helps you and close your query by marking it as solved.

Regards,
Santosh
This was selected as the best answer
Ritika SinghRitika Singh
Hi Santosh,

Thanks for the response. It was helpful.