Controller Component Communication will be useful if you are having different visualforce components and you wanted to communicate with them.
You can find more details here:-
Ref:
Controller Component Communication
The first step is to create a virtual class that every controller that needs to communicate with a component controller will extend.
public with sharing virtual class PageControllerBase {
private ComponentControllerBase myComponentController;
public virtual ComponentControllerBase getMyComponentController() {
return myComponentController;
}
public virtual void setComponentController(ComponentControllerBase compController) {
myComponentController = compController;
}
public PageControllerBase getThis() {
return this;
}
}
Basically we are declaring a field compController to hold a reference to the component controller instance. We also set up a getter to return the instance of the page controller. Finally, we create a virtual method to set the compController. It is useful to make these virtual so that you can simply extend this class in your page controller and, if required, cast the component controller to a specific type (assuming that your component controller extends the class below).
The next step is to create a virtual class for the ComponentController something like this:
public with sharing virtual class ComponentControllerBase {
public PageControllerBase pageController { get;
set {
if (value != null) {
pageController = value;
pageController.setComponentController(this);
}
}
}
}
This class simply defines a property to contain the page controller. This value will be passed by using an attribute on the component markup. Again, these methods are defined as virtual in case you need special handling or casting for the page controller.
Once you have created these two virtual classes you can now create component controllers and page controllers that extend these classes. This will imbue your controller implementations with the ability to communicate with each other.