如何刷新<p:graphicimage>单击<p:commandbutton> </p:commandbutton> </p:graphicimage>

时间:2014-11-03 12:20:15

标签: jsf primefaces ejb-3.0

嗨,我在更改新按钮点击xhtml页面内容的时间方面遇到了问题。


<h:form id="f">
     <h:panelGrid columns="2" cellpadding="2">
          <p:commandButton value="Click " actionListener="#   {graphicImageView.test()}"  >
               <p:ajax update="img"   immediate="true"/>
          </p:commandButton>
          <p:graphicImage id="img" value="#{graphicImageView.chart}" cache="true" rendered="true" />
     </h:panelGrid>
</h:form>

public PieDataset test() throws ParseException, IOException {
    DefaultPieDataset dataset = new DefaultPieDataset();
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    Date datee1;
    Date datee2;
    String date1 = "2014-06-01";
    String date2 = "2014-10-05";
    datee1 = simpleDateFormat.parse(date1);
    datee2 = simpleDateFormat.parse(date2);
    dataset.setValue("corectif", ifl.countexterne(true, datee1, datee2));
    dataset.setValue("Preventif", ifl.countexterne(false, datee1, datee2));

    return dataset;
}

1 个答案:

答案 0 :(得分:0)

尝试使用这个:

<h:form id="f">
     <h:panelGrid columns="2" cellpadding="2">
          <p:commandButton value="Click " action="#{graphicImageView.test()}" update="img"></p:commandButton>
          <p:graphicImage id="img" value="#{graphicImageView.chart}" cache="true" rendered="true" />
     </h:panelGrid>
</h:form>

注意: commandButton在我们点击按钮时默认会ajax调用,因此无需使用其他p:ajax代码。