I modified the code this way with no success:
I used the viewParam feature and i removed the old style parameter declaration in the faces-config:
Code: Select all
<f:metadata>
<f:viewParam name="selectedPeriodId" value="#{perioddetail.selectedPeriodId}"/>
</f:metadata>
Code: Select all
public void setSelectedPeriodId(String selectedPeriodId) {
this.selectedPeriodId = selectedPeriodId;
System.err.println("set id " + selectedPeriodId);
if(selectedPeriodId == null) {
return;
}
try {
String ss[] = selectedPeriodId.split("\\.");
if("shift".equals(ss[0])) {
selectedPeriod = dBHelperBean.find(Shift.class, ss[1]);
}
if("lot".equals(ss[0])) {
selectedPeriod = dBHelperBean.find(Lot.class, ss[1]);
}
if("product".equals(ss[0])) {
selectedPeriod = dBHelperBean.find(Product.class, ss[1]);
}
scPeriodYieldChart = createPeriodYieldChart();
scPeriodUPHChart = createPeriodUPHChart();
StreamedContent sc[] = createPeriodInactivitiesChart();
scPeriodInactivitiesChart = sc[0];
scPeriodInactivitiesDurationChart = sc[1];
} catch(PTrackException ex) {
//FIXME
ex.printStackTrace();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(Utils.fullStacktraceToHtml(ex)));
}
}
This way the above setter is called exactly once with a NON null parameter.
In the same method i put the graph generation that before i had in the getter of the graph linked to the graphicImage tag, i also removed the null test
Code: Select all
<p:panel header="Grafici">
<p:graphicImage value="#{perioddetail.periodYieldChart}"/>
</p:panel>
The getter is now very simple as it should be:
Code: Select all
public StreamedContent getPeriodYieldChart() {
System.err.println("get chart " + selectedPeriodId);
return scPeriodYieldChart;
}
As you see i put some println in the setter and getter to see what happens and here it is:
Code: Select all
GRAVE: set id shift.c6816dce-c063-407b-86ad-431757c33a36
GRAVE: get chart shift.c6816dce-c063-407b-86ad-431757c33a36
GRAVE: get chart shift.c6816dce-c063-407b-86ad-431757c33a36
GRAVE: get chart shift.c6816dce-c063-407b-86ad-431757c33a36
GRAVE: get chart null
GRAVE: get chart null
Again i have calls on the getter and the value of the id i use to generate the graphics is null.
The result is a broken image in the generated page.