Do the DB validation in:
controllers.submits.LoginAction (execute) method.
The error handling should be:
If DB validation fails, create Action Error or Message and then pass it
back to the JSP as a failure.
The Error tags should be able to display it. If you use <html:errors/> you
dont have to manage individual <html:error> tags.
Thanks and regards,
Pazhanikanthan. P (Paz)
Consultant for AXA,
Senior Software Engineer,
HCL Australia Services Pty. Ltd.
Off : +61-3-9618-4085
Mob : +61-0411-354-838
"Thomas Thomas" <[EMAIL PROTECTED]>
30/11/2006 08:52 AM
Please respond to "Struts Users Mailing List"
To: "Struts Users Mailing List" <[email protected]>
cc:
Subject: validate question ...
Hi,
My web-application allows a user to authenticate to the website.
I check for login and password with the Validator Framework (correct
length,
correct carachters, ...)
Then display with <html:errors property="login"/> and <html:errors
property="password"/> in my jsp.
This work ok.
If he the fields are valid, I need to check in my DB if the user is really
subscribed.
1) Where should I do the DB validation ?
2) How do I return the errors to JSP, how do I display the errors in my
jsp
?
can I have something similar like : <html:errors property="dberror"/> or
something like that ?
what's best ?
I have for this a "DynaValidatorForm" and an Action "LoginAction" if
fields
are correct for the validator :
<form-beans>
<form-bean name="loginForm" type="
org.apache.struts.validator.DynaValidatorForm">
<form-property name="login" type="java.lang.String" />
<form-property name="password" type="java.lang.String" />
</form-bean>
[...]
<action
path="/Login"
type="controllers.submits.LoginAction"
name="loginForm"
input="/Error.do"
validate="true"
scope="request">
<forward name="index" path="/index.jsp"/>
<forward name="chat" path="/chat_form.jsp"/>
</action>
And my JSP :
login :
<br/>
<html:text property="login" size="10"/>
<!-- <span id="txtUsernameMsg">
Le login spécifié est invalide !
</span>-->
<html:errors property="login"/> <--- DISPLAY error if
login is empty
<!--
I WANT TO DISPLAY A MESSAGE HERE IF USER DOESNT EXIST IN
DATABASE, how ?
-->
<br/>
mot de passe :
<br/>
<html:password property="password" size="10"/>
<!-- <span id="txtPasswordMsg">
Le mot de passe spécifié est invalide !
</span>
-->
<html:errors property="password"/> <--- DISPLAY error
if
password is empty
<br/>
_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed
Scanning Services - powered by MessageLabs. For further information
visit http://www.mci.com
*********************************************************************************
Important Note
This email (including any attachments) contains information which is
confidential and may be subject to legal privilege. If you are not
the intended recipient you must not use, distribute or copy this
email. If you have received this email in error please notify the
sender immediately and delete this email. Any views expressed in this
email are not necessarily the views of AXA. Thank you.
**********************************************************************************