Netbeans tells “Unknown property” on <p:poll listener>

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 02:59:56

问题


I havent worked out how to call/invoke a method dynamically without using the @PostContruct method and initialising @ the page creation.

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);  
    }  
} 

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> 

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?


回答1:


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>

Also ensure that your html page/template is surrounded by the <f:view contentType="text/html"> tag

Hope this helps someone & thanks to BalusC for his help in debugging this.



来源:https://stackoverflow.com/questions/7432723/netbeans-tells-unknown-property-on-ppoll-listener

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!