spring security validation

UI Components for JSF
Post Reply
nidheesh
Posts: 60
Joined: 24 Oct 2011, 13:21

15 Nov 2011, 14:50

If I use <h:form> ,I can't login when using j_username and j_password (Spring security+primefaces). If I uses simply the <form> the email validation is not working but can login. What is the solution. :oops:
Follow the code snippets.

Code: Select all

<form action="../../j_spring_security_check" method="post">

						<ul class="form">
							
                                                          <li><h:outputLabel for="j_username">Username</h:outputLabel>
								<p:inputText id="j_username" name="j_username" type="text"
									validatorMessage="Invalid Email ID" required="true"
									requiredMessage="Please enter your email">

									<f:validateRegex
										pattern="^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$" />

									<p:ajax event="blur" update="j_usernameId" />
								</p:inputText> <p:message id="j_usernameId" for="j_username" display="text"
									requiredMessage="email required" />
							</li>

							<li><h:outputLabel for="j_password">Password</h:outputLabel>

								<p:inputText type="password" value="#{j_password}"
									id="j_password" required="true" label="j_password"
									feedback="false" /></li>

							<li class="submit"><input type="submit" name="submit"
								value="Login" class="submitBtn" /></li>


						</ul>

					</form>
Thanks,
Nidheesh

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

15 Nov 2011, 15:13

You can't use JSF without h:form, use h:form with prependId false.

nidheesh
Posts: 60
Joined: 24 Oct 2011, 13:21

15 Nov 2011, 15:24

I tried using <h:form prependId="false">, then j_username is not passing properly to spring security , I guess, authentication fails, hence I can't login. But the validation is fine.
Thanks,
Nidheesh

yyq2009aa
Posts: 61
Joined: 18 Jun 2010, 21:39

04 Jun 2012, 16:01

nidheesh wrote:I tried using <h:form prependId="false">, then j_username is not passing properly to spring security , I guess, authentication fails, hence I can't login. But the validation is fine.

The primary problem is form action, spring login form aciton should be "j_spring_security_check", but jsf action is current page view id.
PF 3.5
JSF 2.1 (Mojarra 2.1.19)
Glassfish 3.1.2
FF 3.6, IE 8, Chrome 25
Windows 7
NetBeans IDE 7.3

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 56 guests