如何通过点击刷新

问题描述:

您好我在改变时间方面存在问题,但是知道点击xhtml页面内容的buttone没有改变。如何通过点击<p:commandButton>刷新<p:graphicImage>


<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; 
} 

尝试使用这一个:

<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标签。

+0

我测试过但不是结果pleeez帮助我.. – 2014-11-03 14:57:35