gpt4 book ai didi

jsf - 单击 primefaces 中的字段集后如何调用方法?

转载 作者:行者123 更新时间:2023-12-02 00:58:11 26 4
gpt4 key购买 nike

这是我的 .xhtml 文件中的代码,我在字段集下添加了

index.xhtml

    <p:fieldset legend="BPS Listener Method" toggleable="true" collapsed="#{bpsFrontBean.bpsListenerSwitch}" toggleSpeed="500" style="width: 920px;margin: 0 auto; text-align: left">
<p:ajax listener="#{bpsFrontBean.onToggleBpsListenerSwitch}" update="parametersGrid"/>
.........
</p:fieldset>

如果我在页面显示之前运行上面的代码,则会出现错误消息:

    javax.faces.view.facelets.TagException: <p:ajax> Event attribute could not be determined: null

我想在可切换字段集被点击时触发一个方法。

最佳答案

Primefaces 用户指南 (http://www.primefaces.org/showcase/ui/panel/fieldset.xhtml) 的第 205-206 页说:

Ajax Behavior Events

toggle is the default and only ajax behaviorevent provided by fieldset that is processed when the content istoggled. In case you have a listener defined, it will be invoked bypassing an instance of org.primefaces.event.ToggleEvent.

Here is an example that adds a facesmessage and updates growlcomponent when fieldset is toggled.

<p:growld id="messages" />
<p:fieldset legend="Toggleable Fieldset" toggleable="true">
<p:ajax listener="#{bean.onToggle}" update="messages"/>
//content
</p:fieldset>

关于 bean :

public void onToggle(ToggleEvent event) {
Visibility visibility = event.getVisibility();
FacesMessage msg = new FacesMessage();
msg.setSummary("Fieldset " + event.getId() + " toggled");
msg.setDetail("Visibility: " + visibility);
FacesContext.getCurrentInstance().addMessage(null, msg);
}

关于jsf - 单击 primefaces 中的字段集后如何调用方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32089760/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com