At the time I still have not received any feedback about my previous question so I went ahead with a different approach to my problem. Bare with me part of my problem might be because of how I changed my approach along the way.
Basically I have two custom components
- Widget (which uses
Widget.cls
as its controller) - Series of metric components (which uses
{Type}Controller.cls
as their controllers
Previously I tried to use the Widget as a subcomponent of each metric component so that I could reuse the attributes and other elements. Based on the lack of answers on my previous post I don't think that is possible. So instead, I now use the Widget component on the VFP and then it uses one of the metric components based on the widget-type
attribute given. For example:
<c:Widget data-controller="{!dashboard}" widget-type="Chart-Comparison" widget-title="Some Title">
The widget then contains all the attributes that each metric component would need and it passes those by passing the instance of itself like so:
<c:MetricType widget="{!this}" rendered="{!IF(Component=='chart',TRUE,FALSE)}" />
This works great, now each metric component just contains the following line:
<!-- Widget Instance Attributes -->
<apex:attribute name="widget" assignTo="{!component}" description="Widget component controller used"
type="Widget" required="true"/>
Now the problem begins...
The metric component controller extends the Widget.cls
which worked fine before but now even though I can still execute all the shared widget methods, all of the instance variables are missing (not set). So although they were set when the Widget was constructed, by the time my {MetricController}.cls
gets constructed the Widget instance it has is empty making it useless.
I've tried to pass the instance into the controller like so:
public class MetricController extends Widget {
//========= SETUP GETTERS/SETTERS ============//
/* Although we are extending the Widget's methods, the widget instance data
is passed through this component variable and therefore needs to be used to setup
all instance data */
public Widget component { get;
set {
component = value;
setupWidgetInstance();
}
}
}
Problem is although I can set any given variable with something like:
void setupWidgetInstance(){
params = component.params;
}
it seems I would need to set do that for every variable on each of these controllers and that is not going to work. I've killed many hours today narrowing this problem down to this and could really use some help to bring it home (also so I can go home :P #deadlines)