function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AK-2AK-2 

Opportunity page with component and then saving the opportunity record

I am writing a custom VF page that has tabbed input for different types of related records input. To streamline the coding, I was thinking of moving each tab into a custom VF component with a custom controller. There is only one form on the page that includes all the visible tabs and the related input and only one "SAVE" button on the form. The tabs don't have individual save button.

So, the question is, how do I call save on the custom controller of the components to save the input in the custom tabs?

Thank you.
bob_buzzardbob_buzzard
Do you absolutely have to have a custom controller for each component?  If you can manage all of the business logic from the page controller its a lot more straightforward, as you only have to execute the save method for the page.  The page can pass the new record instance to be populated as an attribute of the component.

If you can't do that, you'll need to register the custom controllers with the page controller somehow - I usually pass an instance of the page controller as an attribute and have a method that the component controller can invoke to add itself to a list. Then when the page save method is executed it iterates all of the registered component controllers and executes theirs.  
AK-2AK-2
Thanks. I decided to pass the main controller to the component and then access the records from the main controller in the component controller. I am still using only one save button.