0

I'm trying to get data between 2 dates with chart everything works fin but when I'm using Ajax update the second date disappeared there is my code

<p:calendar value="#{bean.date}">
<p:ajax event=”dateSelect” listener=”#{bean.handleDateSelect}” update=”dateEnd” />
 </p:calendar>
<p:calendar id="dateEnd" value="#{calendarBean.date2}"
mindate="#{bean.date}"></p:calendar> 
<p:chart type="pie" model="#{bean.model}" />

if I remove the Ajax it works but I need it for mindate.

  • If you update the second calendar what you see is the value stored server-side, so since you aren't processing all changes of it you lose that value. Try to add an ajax to the second calendar, with `process="@this"` and pay attention, in `handleDateSelect`, to manage all scenario, according the `mindate` check. Read this [BalusC Guide](https://stackoverflow.com/questions/25339056/understanding-primefaces-process-update-and-jsf-fajax-execute-render-attributes) for more info. – WoAiNii May 14 '20 at 19:29
  • I'm talking about disappearing of calendar the second one disappeare completely from my page – Mehdi Bekkouche May 14 '20 at 21:32
  • Ok, always or sometimes? Have you checked for error / raised log level (try with f5, the page should break, and don't use production as the stage if you want to see this kind of error)? – WoAiNii May 15 '20 at 16:14

1 Answers1

0

Finally i got to solve the problem,so I have to init the chartSerie for exemple :

ChartSeries serie = new ChartSeries();

for (Object o : list
        ) {
            serie.set(o.getLabel(), o.getValue());
        }
// This line what i was missing
if (serie.size() == 0)
            serie.set(0, 0);