Originally I wanted to attempt using the interface
notation as an added layer of abstraction for this project for the time being I'm going with what I believed to be a simpler solution, unfortunately I'm having issues.
The problem is my getter/setter variables are not working properly (at least as I understand them to work). Here's the code breakdown:
Visualforce Page:
<c:Gauge widget-type="Number" report="Report Name" data-key="T!T" />
Visualforce Component:
<apex:component controller="GaugeController">
<!-- Define Component Attributes -->
<apex:attribute name="widget-type" assignTo="{!type}" description="Type of gauge to be used" type="String" required="true"/>
<apex:attribute name="report" assignTo="{!reportName}" description="Name report data to be used" type="String" required="true"/>
<apex:attribute name="data-key" assignTo="{!key}" description="Field or column key used from the DataDetail" type="String" required="true"/>
<!-- Define Component Body Variables -->
<apex:variable var="result" value="{!reportName}"/>
<!-- Define Component -->
<apex:outputPanel>
<apex:outputText>{!result}</apex:outputText>
</apex:outputPanel>
<apex:componentBody />
</apex:component>
Component Controller:
public class GaugeController extends Widget{
public String key { get; set; }
/* Construtor */
public GaugeController() {
System.debug(reportName); //returns NULL
}
}
Abstract Base Class:
public abstract class Widget implements Data{
//========= SETUP GETTERS/SETTERS ============//
public String title { get; set; }
public String type { get; set; }
public String reportName { get; set; }
public Widget() {
System.debug(reportName); // returns NULL
}
}
I don't understand why my System.debugs
show NULL
values yet the page gives me the String result I passed as expected. I think I need to be enlightened a little. Any and all help is much appreciated :)