<p:commandbutton> 不工作

<p:commandbutton> not working

提问人:hina abbasi 提问时间:3/13/2014 更新时间:3/14/2014 访问量:949

问:

我是 JSF 和 primefaces 的新手。.我写了一个小代码......我得到了我想用“H:CommandButton”做的事情,但同样的事情不适用于“P:CommandButton”。这两件事的功能有什么区别吗?

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

我已经尝试了很多方法,但是newjsfmanagedbean.show()尚未从P:CommandButton调用,但是H:CommandButton工作正常。原因是什么:-( ?

JSF-2 Primefaces 命令按钮

评论

0赞 Ioan 3/13/2014
它必须在表单中。
0赞 hina abbasi 3/13/2014
它在“h:form”里面。
0赞 Ioan 3/13/2014
然后向我们展示整个代码(html + backing bean)
0赞 leostiw 3/13/2014
尝试使用 action 而不是 actionListener。您也可以尝试ajax=“false”。
0赞 maozturk 3/13/2014
您能否也分享一下您的 show() 函数?

答:

0赞 Srikanth Ganji 3/13/2014 #1

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

希望这会有所帮助

0赞 maozturk 3/13/2014 #2

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

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

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

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

否则,它会查找没有任何参数的 show 方法。

1赞 hina abbasi 3/14/2014 #3

*嘿,它奏效了:-) * thanxmates

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