【问题标题】:<p:commandbutton> not working<p:commandbutton> 不工作
【发布时间】:2014-03-12 18:15:33
【问题描述】:

我是 JSF 和 primefaces 的新手……我写了一个小代码……我得到了我想要用“h:commandbutton”做的事情,但同样的事情不适用于“p:commandbutton”。这两个东西的功能有什么区别吗?

<h:commandButton value= "enter" actionListener= "#{newJSFManagedBean.show()}"/><br/>
<p:commandButton value= "enter" actionListener= "#{newJSFManagedBean.show()}"/><br/>

我已经尝试了很多东西,但是没有从 p:commandbutton 调用 newjsfmanagedbean.show() 但 h:commandbutton 工作正常。原因是什么:-(?

【问题讨论】:

  • 必须在表单内。
  • 它在 "h:form" 里面。
  • 然后向我们展示整个代码(html + backing bean)
  • 尝试使用 action 而不是 actionListener。你也可以试试 ajax="false"。
  • 能否请您也分享一下您的 show() 函数?

标签: jsf-2 primefaces commandbutton


【解决方案1】:

*嘿,它成功了 :-) * 谢谢各位

<p:commandButton process="@this" value= "enter"  ajax="false" actionListener= "#{newJSFManagedBean.show}" /><br/>

【讨论】:

    【解决方案2】:

    你没有分享你的 show() 函数,但我猜它看起来像下面这样:

    public void show(ActionEvent event) {
        // some stuff here
    }
    

    好吧,如果你想将它与 primefaces 一起使用,只需删除你的 EL 语言中的括号:

    <p:commandButton value= "enter" actionListener= "#{newJSFManagedBean.show}"/>
    

    否则它会寻找一个没有任何参数的 show 方法。

    【讨论】:

      【解决方案3】:

      您应该将process="@this" 添加到p:commandButton 以调用其操作。如果您想处理任何其他组件,请像这样添加process="@this,id1,id2"

      希望对你有帮助

      【讨论】:

        猜你喜欢
        • 2017-11-23
        • 1970-01-01
        • 2012-01-06
        • 2015-09-04
        • 2013-06-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多