I'm trying do develop a visualforce custom component which is an entity chooser. This custom component displays a UI which helps browsing some records. It's possible to select one record, and I'd like to get it from outside the component or its controller.
I've looked at the standard salesforce binding with assignTo bug it's not bidirectional...
Hope someone can help me.. Thanks
1 - Declare a static variable in the outside class (can be the VF page controller)
Something like :
public static apexType myRecordOutside;
2 -When you Make your choice from records in the method within the custom component controller
Do something like this :
OutsideClass.myRecordOutside = chosenRecord; //notice that when its static you can access it without instantiating the outside class.
3- then, declare in your Visual force
<c:myCustomComponent userSelectedAccount = {!myRecordOutside}></c:myCustomComponent>
this will get myRecordOutside not from the component's controller class, but from the outside class
If you have any question about a part of my answer let me know :)
Are you passing an object into the component? Objects are passed by reference, so if your component has an attribute that takes an object and does something to it, your outer page controller will be able to access the changed values.
If you were to pass in a shell object, ie. if your UI is allowing a user to select an Account.
Component:
Component Controller:
Page Using the Component:
This would allow you to assign the user selected account into the instance of wrapper object which is owned by the outer controller. You can then reference:
from your main Visualforce Pages controller.