0

I copied someone elses JSF project since I could not get the IntelliJ maven archetypes to download. Anyways that projects was functioning but did not contain a faces-config so I added it manually into the project folder:

+
+-WebContent
+--WEB-INF
+---faces-config.xml
+---web.xml

The faces config looks like this:

<?xml version='1.0' encoding='UTF-8'?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
              version="2.0">

    <navigation-rule>
        <from-view-id>/index.xhtml</from-view-id>
        <navigation-case>
            <from-action>#{loginBean.performLogin}</from-action>
            <from-outcome>success</from-outcome>
            <to-view-id>/home.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>
</faces-config>

That is the web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>Primefaces-Dashboard-Sample</display-name>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
    <listener>
        <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>
    <welcome-file-list>
        <welcome-file>/faces/index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>

And this is the button within the form:

<p:commandButton id="loginButton" action="#{loginBean.performLogin}"
                                     value="send" ajax="true" style="float: right;">
                    </p:commandButton>

However I get the weird behavior that the page is not redirect rather the form content gets replaced by the content of home.xhtml. Using the standard commandButton however everything works as expected.

Is there any way to get this to work with primefaces?

jonjon1
  • 103
  • 1
  • 9
  • Try googling for "difference h:commandButton p:commandButton"... One of the links is this: https://forum.primefaces.org/viewtopic.php?t=6217, does that answer your question? – Kukeltje Sep 18 '18 at 14:46
  • And please improve your title. It now contains 'tags' (jsf primefaces) and some thing that might be related (navigation rules) but nothing about the actual problem. See [ask] – Kukeltje Sep 18 '18 at 15:33
  • Possible duplicate of [How to navigate in JSF? How to make URL reflect current page (and not previous one)](https://stackoverflow.com/questions/15521451/how-to-navigate-in-jsf-how-to-make-url-reflect-current-page-and-not-previous-o) – Vsevolod Golovanov Sep 18 '18 at 20:21
  • Add `` to your navigation rule. – Vsevolod Golovanov Sep 18 '18 at 20:22
  • JSF2 has more options and is liberal. Read doc – Jacek Cz Sep 18 '18 at 21:33
  • @VsevolodGolovanov that did the trick – jonjon1 Sep 19 '18 at 14:51

0 Answers0