I would like to print an array of results only under some conditions. In my bean, I have a method dataIsOk() which check the conditions and do the computation with data from a form. Computation is costly (around 5 seconds). The method dataIsOk() is called several times and then the total time is large (around 20 seconds).
I am new in JSF and I don't what to do for having a smaller total time (for instance dataIsOk() only called once).
my xhtml:
<p:outputPanel rendered="#{pBean.dataIsOk() eq true}">
<ui:include src="result.xhtml"/>
</p:outputPanel>
I have seen @PostContruct but I have the feeling that it won't be ok in my case, because my method needs data from the interface (and then can't be executed before the construction of the bean).
My function :
public boolean dataIsOk() {
if (profilIsOk()) {
Date dateEffet = rechercheDate();
Parametres param = rechercheParam();
FacesContext fc = FacesContext.getCurrentInstance();
EBean eBean = (EBean) fc.getViewRoot().getViewMap().get("eBean");
if (eBean !=null) {
Calcul calcul = new Calcul();
List<Tarif> tarifs = new ArrayList<Tarif>();
tarifs = calcul.calculTarif(dateEffet, param, eBean.getType());
return true;
} else return false;
}