0

I use container managed security in my JSF app so I have a login page with below default setup.

Now in the login page, I wanted to add a button beside the login button to allow the user to register.

But how do I forward it to my register.xhtml page from my register button? I tried it with this code:

<form method="post" action="j_security_check">
    <div id="login-content">
        <p>Login to access secure pages:</p>
        <p:panelGrid columns="2">
            <h:outputLabel for="j_username" value="Username" />
            <input type="text" name="j_username" id="j_username" />

            <h:outputLabel for="j_password" value="Password" />
            <input type="password" name="j_password" id="j_password" />

            <f:facet name="footer">
                <input type="submit" name="submit" value="Login" />
                <input type="button" name="register" 
                    value="#{request.contextPath}/pages/public/register.xhtml" />
            </f:facet>
        </p:panelGrid>
    </div>
</form>

I tried changing also the form to h:form so that I could use the p:commandButton but as I notice, my login page is not working and nothing is happening when I click the submit button.

How to achieve what I want to do?

Mark Estrada
  • 9,013
  • 37
  • 119
  • 186
  • Why do you need to have both the login process and register buttons in the same form? Put your login form in a regular html `
    ` and stick the registration in a JSF `` and you can redirect to your registration page using a regular ``. You just style them to sit next to each other. That OK by you?
    – kolossus Nov 13 '12 at 07:26
  • Looks like this is the option that I have for now.. I will just leave the question for some time.. maybe somebody has some other ideas..Thanks! – Mark Estrada Nov 13 '12 at 10:31

1 Answers1

1

Just use <h:button> or <p:button> to create a GET button.

<h:button value="register" outcome="/pages/public/register.xhtml" />
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555