JSF PrimeFaces p: commandLink will not be redirected to a new page?

I am using JSF2 and GlassFish, PrimeFaces 2.1.

This works, the showCreateProfile () method gets hit, and the method returns "profileForm", and the browser redirects to this page:

<h:commandLink action="#{profileHandler.showCreateProfile}" value="#{msg.menu_createNewProfile}" /> 

However, this does not work, the showCreateProfile () method receives calls, and the method returns "profileForm", but the browser does not redirect the page. I tried three different things with no luck:

 <p:commandLink action="#{profileHandler.showCreateProfile}" value="#{msg.menu_createNewProfile}" /> <p:commandLink action="#{profileHandler.showCreateProfile}" value="#{msg.menu_createNewProfile}" ajax="false" /> <p:commandLink action="#{profileHandler.showCreateProfile}" value="#{msg.menu_createNewProfile}" ajax="false" immediate="true"/> 

Any ideas what I'm doing wrong?

Rob

+7
source share
2 answers

The surface ' p:commandLink by default starts an ajax request. It does not return the entire HTTP response, but only a partial HTTP response that needs to be updated in the JS HTML DOM tree.

You have basically two options:

  • Disable ajax using the ajax="false" attribute. Then it will run a regular HTTP request.

  • Update (repeat visualization) the partial content (on the same page!) update="clientid" attribute update="clientid" . You can use the rendered attribute to control the rendering of content.

If none of them work, then the problem lies elsewhere. Since h:commandLink works and the p:commandLink action method also executes, then this may mean that you are not using the code that you think you are using when trying ajax="false" . Check, save, rebuild, reinstall, restart.

+13
source

PrimeFaces does not support forwarding based navigation, you need to use redirection instead of forwarding if you want to navigate on ajax request or set ajax to false as BalusC said.

+4
source

All Articles