【问题标题】:How to refresh a <p:graphicImage> from clicking a <p:commandButton>如何通过单击 <p:commandButton> 刷新 <p:graphicImage>
【发布时间】:2014-12-30 02:35:35
【问题描述】:

你好我在更改时有问题知道buttone点击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;
}

【问题讨论】:

    标签: jsf primefaces ejb-3.0


    【解决方案1】:

    试试这个:

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

    【讨论】:

      猜你喜欢
      • 2014-01-17
      • 1970-01-01
      • 2014-02-14
      • 2014-02-14
      • 1970-01-01
      • 2016-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多