Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 2 <;p:commandbutton>;不起作用_Jsf 2_Primefaces_Commandbutton - Fatal编程技术网

Jsf 2 <;p:commandbutton>;不起作用

Jsf 2 <;p:commandbutton>;不起作用,jsf-2,primefaces,commandbutton,Jsf 2,Primefaces,Commandbutton,我是JSF和primefaces的新手。。我写了一个小代码。。。我得到了我想用“h:commandbutton”做的东西,但是samething不能用“p:commandbutton”。这两个东西的功能有什么不同吗 <h:commandButton value= "enter" actionListener= "#{newJSFManagedBean.show()}"/><br/> <p:commandButton value= "enter" actionList

我是JSF和primefaces的新手。。我写了一个小代码。。。我得到了我想用“h:commandbutton”做的东西,但是samething不能用“p:commandbutton”。这两个东西的功能有什么不同吗

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



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

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

希望这对您有所帮助

您没有共享show()函数,但我可以猜它如下所示:

public void show(ActionEvent event) {
    // some stuff here
}
如果您想将EL语言中的括号用于primefaces,只需删除括号即可:

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

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

*嘿,它工作了:-)* 桑克斯马特

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


它必须在一个表单中。它在“h:form”中。然后向我们展示整个代码(html+支持bean),尝试使用action而不是actionListener。你也可以试试ajax=“false”。你能不能也分享一下你的show()函数?