0

I have two pages for registration. On one I get the user data into a request scoped bean and on the next one I display the data gathered. On the second page there is a button to redirect the user to log in.

Here is the button action for the register.xhtml. The result of the regUser.register is reg_success, which is the name of the second page, where I display the user data.

        <p>
            <h:commandButton value="#{msgs.regButtonText}" action="#{regUser.register}"/>
        </p>

In the reg_success.xhtml I have this code for the button:

        <p>
            <h:commandButton value="#{msgs.regToLogin}" action="login"/>
        </p>

My login page has the name login.xhtml.

Even if I insert this navigation rule into my faces-config.xml the forward does not happen. Indeed from the register.xhtml the user is forwarded and the url does not change on the second page.

<navigation-rule>
        <from-view-id>/reg_success.xhtml</from-view-id>
    <navigation-case>
        <from-outcome>login</from-outcome>
        <to-view-id>/login.xhtml</to-view-id>
        <redirect/>
    </navigation-case>
</navigation-rule>
Pio
  • 4,044
  • 11
  • 46
  • 81

1 Answers1

2

The <h:commandButton> only works when it's inside a <h:form>. See also the first point of commandButton/commandLink/ajax action/listener method not invoked or input value not updated.

But in this particular case you don't seem to need a POST request. Just use <h:button> then. This creates a GET request without the need for a <h:form>.

<h:button value="#{msgs.regToLogin}" outcome="login" />
Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555