I think my problem is related to BalusC's answer here: Evaluation of EL during view build time
I am trying to display a series of Primefaces BarCharts using a JSF2 composite component, passing in a custom Chart object as an attribute. The Chart object contains the charts name, title and a call to a DAO object to retrieve the data model. Here's my composite component.
<composite:interface>
<composite:attribute name="chart" />
</composite:interface>
<composite:implementation>
<p:barChart id="#{cc.attrs.chart.name}" title="#{cc.attrs.chart.title}" value="#{cc.attrs.chart.model}"
style="width:300px" legendPosition="ne" xaxisAngle="45"/>
</composite:implementation>
As Primefaces renders the barchart object, it makes three calls to getValue() for the barchart object, and as explained in the link above, only the EL expression "#{cc.attrs.chart.model}" has been stored. This results in a new model evaluation every time getValue is called internally by Primefaces and so three round trips to the database.
Is there some way to evaluate cc.attrs.chart.model once and use it as the value attribute of the chart?
I think I could use a chart UI component and binding but I wanted as many of the chart properties to be defined in my view as possible so this feels wrong?