I'am using Primefaces to make my app a little bit more beautiful. I noticed that p:commandButton
and h:commandButton
don't work the same way.
The p:commandButton
calls the method and nothing else hapens. The h:commandButton
calls the method and returns a navigation.
I have got trouble with redirecting after pressing the login button when using p:commandButton
. How to deal with that?
I do have an update parameter:
<p:commandButton value="Login" action="#{login.login}" type="submit" update="msgs" />
I am having a similar problem.
I am using primefaces and primefaces mobile and the navigation fails in Firefox when using
<p:commandButton>
with ajax="false" and action="find.xhtml?faces-redirect=true".The only way I could make it work also in Firefox was by using
<h:commandButton>
:none of the above solution worked for me. You can still go for simple javascript
<p:commandButton>
needs one of the following to work correctly:update
attribute to list id's of components to re-render (for AJAX requests)ajax="false"
to make a normal, non-ajax submit.If you have neither, the button does per default an AJAX request with no UI feedback.
Additionally, I've had problems with neither option working when the surrounding
<h:form>
had anenctype
attribute.I think what Cagatay ment was:
Does not navigate the page:
Works (redirects the page):
Works (redirects the page)
if .xhtml is your default postfix defined in web.xml:
More info can be found in the primefaces forum, for example in this discussion about navigation
I hope that helped a bit...
You must use redirect if you are doing navigation and request is done with ajax.
I used the commandbutton to navigate to profile page, and its working fine for me.