您如何将值传递给 ajax 侦听器primefaces
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9472212/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 11:08:12 来源:igfitidea点击:
How do you pass a value into an ajax listener primefaces
提问by Landister
So I have
所以我有
<p:ajax event="tabChange" listener="#{refriedBean.onTabChange}" />
But I want to pass in the tabChange event AND an extra value that is stored on the page
但我想传入 tabChange 事件和存储在页面上的额外值
public void onTabChange(TabChangeEvent event, Object obj)
How would one go about doing this?
怎么做呢?
采纳答案by Mikita Belahlazau
You can replace argument objwith additional property in bean and set needed value to this property on ajax request:
您可以obj使用 bean 中的附加属性替换参数,并在 ajax 请求中为该属性设置所需的值:
<p:ajax event="tabChange" listener="#{refriedBean.onTabChange}">
<f:setPropertyActionListener target="#{refriedBean.additionalProperty}" value="value_here"/>
</p:ajax>

