Netbeans告诉“未知属性"在< p:poll侦听器>上 [英] Netbeans tells "Unknown property" on <p:poll listener>
问题描述
我还没有弄清楚如何在不使用@PostContruct方法和初始化@页面创建的情况下动态调用/调用方法.
I havent worked out how to call/invoke a method dynamically without using the @PostContruct method and initialising @ the page creation.
此刻,我只是试图使Primeface p:poll示例正常工作.我现在将该方法放在自己的类中,以保持其清洁和简单.看起来像这样:
At the moment I am simply trying to get the primeface p:poll example working. I have placed the method in its own class for now to keep it clean and simple & looks like so:
@ManagedBean(name="counterBean")
@SessionScoped
public class CounterBean implements Serializable {
private int count;
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public void increment(ActionEvent actionEvent) {
setCount(getCount() + 1);
}
}
然后是xhtml代码:
And then the xhtml code:
<h:form>
<h:outputText id="txt_count" value="#{counterBean.count} " />
<p:poll interval="3" listener="#{counterBean.increment}" update="txt_count"/>
</h:form>
netbeans中的智能感知告诉我#{counterBean.increment}的增量"部分是未知属性",即找不到该方法.那么,如何让JSF识别并从xhtml调用此方法?
Intellisense within netbeans tells me that the "increment" part of #{counterBean.increment} is an "Unknown Property" i.e. it cant find the method. So how can I get JSF to recognise and invoke this method from the xhtml?
推荐答案
p:poll组件经过一番摸索之后,略微改写了primefaces demo&手动的.将p:poll侦听器更改为actionListener:
Well after a some head scratching the p:poll component started working after a slight adaptation from the primefaces demo & manual. Change the p:poll listener to actionListener:
<h:form>
<h:outputText id="txt_count" value="#{counterBean.count} " />
<p:poll interval="3" actionListener="#{counterBean.increment}" update="txt_count"/>
</h:form>
还要确保您的html页面/模板被<f:view contentType="text/html">
标记包围
Also ensure that your html page/template is surrounded by the <f:view contentType="text/html">
tag
希望这可以帮助某人&感谢BalusC在调试方面的帮助.
Hope this helps someone & thanks to BalusC for his help in debugging this.
这篇关于Netbeans告诉“未知属性"在< p:poll侦听器>上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!