You need to sign in to do that
Don't have an account?
Share list variable between two controller (page and component)
Hello all,
I want to ask if it possible or not to share/pass a list variable between two controller.Scenario is something like this:
I have one page named Page1 which is using StandardController Account and extension named Extension1.
In this Extension1, I defined one list variable that contain all element which I used to contruct tab in Page1.
Then I created one component named Component1 with controller named Controller1.In this component, I put all the content that I want to display for every tab that constructed in Page1, to do this I just pass one list element as string .
So I have Page1 and inside it contain Component1.Now, where the issue come out. In the Controller1, I need to know all the element in the list variable that I defined in Extension1 in order to do some processing/ mathematical calculation. In order word, I need to retrieve the list from Extension1 in Controller1.
Is it possible to do this? Any Idea?
Yes, this is possible. It works like this:
Of course, this code doesn't DO anything, but when you look at the view state, component's "data" value will show "reference to data", meaning the extension's value. Altering the value in either case will result in both elements seeing the data changes. As you can imagine, this mechanism can allow components to share data across instances of the component on the same page.
All Answers
Yes, this is possible. It works like this:
Of course, this code doesn't DO anything, but when you look at the view state, component's "data" value will show "reference to data", meaning the extension's value. Altering the value in either case will result in both elements seeing the data changes. As you can imagine, this mechanism can allow components to share data across instances of the component on the same page.
But I have one doubt here, why it throw me Attempt to de-reference a null object . We already define get set in Comp1 and set the data in Ext1?