You need to sign in to do that
Don't have an account?
Lawrence PrivCo
How do variables get from the controller to the VisualForce page?
I am confused. If I look here:
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_repeat.htm
Then I see:
<apex:repeat value="{!strings}" var="string" id="theRepeat">
And yet no variable called "strings" is ever defined in the controller:
public class repeatCon {
public String[] getStrings() {
return new String[]{'ONE','TWO','THREE'};
}
}
In Ruby On Rails I would have to declare an instance variable in the controller, or I would get an error if I tried to use it in the view.
Where does {!strings} come from? The controller has no variable called "strings", so how can we use a variable called {strings}
I would have expected {!getStrings}. That would have made sense.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_repeat.htm
Then I see:
<apex:repeat value="{!strings}" var="string" id="theRepeat">
And yet no variable called "strings" is ever defined in the controller:
public class repeatCon {
public String[] getStrings() {
return new String[]{'ONE','TWO','THREE'};
}
}
In Ruby On Rails I would have to declare an instance variable in the controller, or I would get an error if I tried to use it in the view.
Where does {!strings} come from? The controller has no variable called "strings", so how can we use a variable called {strings}
I would have expected {!getStrings}. That would have made sense.
That was confusing to me when I first began developing in VisualForce/Apex. The "get" prefix just indicates that the method is a "getter" method. Here's an article that talks about "getter" methods: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_controller_getter_methods.htm
Best of luck,
Jason Flippen