0
votes

i am new to JSF and primefaces.. i wrote a small code... i am getting what i want to do with "h:commandbutton" but samething is not working with "p:commandbutton". is there any difference between the functionality of these two things.

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

i have tried alot of things, but newjsfmanagedbean.show() havenot been called from p:commandbutton but h:commandbutton is working fine. what is the reason :-( ?

3
It has to be inside a form. - Ioan
it is inside "h:form" . - hina abbasi
Then show us the entire code (html + backing bean) - Ioan
Try with action instead of actionListener. You could also try ajax="false". - leostiw
Could you please share your show() function as well? - Maozturk

3 Answers

1
votes

*hey it worked :-) * thanxmates

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

You didn't share your show() function but I can guess that it looks like below :

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

Well, just delete your brackets in your EL language if you want to use it with primefaces :

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

Otherwise it looks for a show method which does not have any parameters.

0
votes

You should add process="@this" to p:commandButton to get its action invoked. If you want to process any other components add process="@this,id1,id2" like this.

Hope this helps