[英]PrimeFaces CommandButton does not Update
I'm trieng to update a gridPanel by pressing a Button(the Pie/Bar chart should not be shown):我正在通过按按钮来更新 gridPanel(不应显示饼图/条形图):
<h:form>
<div class="ui-grid ui-grid-responsive">
<div class="ui-grid-row">
<div class="ui-grid-col-4">
<p:panelGrid columns="1" layout="grid"
styleClass="ui-panelgrid-blank">
...
<p:panelGrid columns="2" layout="grid" id="buttons"
styleClass="ui-panelgrid-blank">
<p:commandButton update="@form"
actionListener="#{buttonView.pieChart}" icon="ui-icon-disk"
title="Zeige Pie an" />
<p:commandButton update="@form"
actionListener="#{buttonView.barChart}" icon="ui-icon-disk"
title="Zeige Bar an" />
</p:panelGrid>
</p:panelGrid>
</div>
<div class="ui-grid-col-8">
<p>...</p>
<p:panelGrid columns="1" layout="grid"
styleClass="ui-panelgrid-blank" id="charts">
<p:chart id="pie" type="pie" model="#{userBean.model}"
responsive="true" />
<p:chart id="bar" type="bar" model="#{chartView.barModel}"
style="height:300px" responsive="true" />
</p:panelGrid>
</div>
</div>
</div>
</h:form>
My code somehow does not seem to work.我的代码不知何故似乎不起作用。
To hide and show the chart you have to define the rendered attribute rendered
.要隐藏和显示图表,您必须定义渲染属性
rendered
。 The rendered
attribute takes a boolean value. rendered
属性采用布尔值。
<p:panelGrid columns="1" layout="grid" styleClass="ui-panelgrid-blank" id="charts">
<p:chart id="pie" type="pie" rendered="#{buttonView.showPieChart}" model="#{userBean.model}" responsive="true" />
<p:chart id="bar" type="bar" rendered="#{buttonView.showBarChart}" model="#{chartView.barModel}" style="height:300px" responsive="true" />
</p:panelGrid>
The value should be set in your Backing Bean for example in buttonView
.该值应在您的 Backing Bean 中设置,例如在
buttonView
。
public class ButtonView {
...
private boolean isShowPieChart;
private boolean isShowBarChart;
...
}
Finally toggle the boolean values.最后切换布尔值。
<p:commandButton update="@form" actionListener="#{buttonView.pieChart}" icon="ui-icon-disk" title="Zeige Pie an" >
<f:setActionPropertyListener target="#{buttonView.showPieChart}" value="#{!buttonView.showPieChart}" />
</p:commandButton>
<p:commandButton update="@form" actionListener="#{buttonView.barChart}" icon="ui-icon-disk" title="Zeige Bar an" >
<f:setActionPropertyListener target="#{buttonView.showBarChart}" value="#{!buttonView.showBarChart}" />
</p:commandButton>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.