2014-11-03 55 views
0

您好我在改變時間方面存在問題,但是知道點擊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; 
} 

回答

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標籤。

+0

我測試過但不是結果pleeez幫助我.. – 2014-11-03 14:57:35