aspose file tools*
The moose likes Struts and the fly likes Struts and Vlidation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts and Vlidation" Watch "Struts and Vlidation" New topic
Author

Struts and Vlidation

Aash Patel
Greenhorn

Joined: Sep 14, 2005
Posts: 24
I have designed a fully function struts application. I am at the point of implemeneting Validation for my application.

So for starters this is what I would like to do:

The entry point into my application is a logon page that prompts the user to enter a username, password, and database name (automatically populated in a drop down menu). The user then clicks on a Connect button that opens a database connection to the specified database. Everything works fine if the user enters valid data.

I now need to implement validation as below:
1. If the user doesn't enter anything for username or password.
2. If the user enters an invalid username or password.

I can do 1 using the validate method in my ActionForm. However I don't understand how the control flow for this works - as in how and what I need to change in my struts-config.xml and my JSP page and my properties file.

I don't know where to start from for 2.

I'd greatly appreciate any assistance on 1 or 2 or both,
Pranav Sharma
Ranch Hand

Joined: Oct 27, 2003
Posts: 258
go through the struts validation documentation here.
That should clear up most of your doubts
Aash Patel
Greenhorn

Joined: Sep 14, 2005
Posts: 24
I went through the documentation for Struts Validation. Thank you mannu.

I am however having problems with my validation.xml and validation-rules.xml. Firstly, I'm not sure if these files are being deployed. Secondly, when I try to validate them (in JBuilder X), I get this error:

IOException: jakarta.apache.org: jakarta.apache.org for both files.

validator-rules.xml is automatically generated by JBuilder when the validation option in struts is selected. I don't know why this doesn't work and this is how my validation.xml looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE form-validation PUBLIC "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN" "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">
<form-validation>
<global>
<formset>
<form name="logonActionForm">
<field property="dbName"
depends="required">
<arg0 key="validateform.username"/>
</field>
<field property="dbPassword"
depends="required,mask">
<arg0 key="validateform.password"/>
<var>
<var-name>mask</var-name>
<var-value>^[0-9a-zA-Z]*$</var-value>
</var>
</field>
</form>
</formset>
</global>
<form-validation>

What am I missing? Please assist. Thanks.
Aash Patel
Greenhorn

Joined: Sep 14, 2005
Posts: 24
OK. I figured out why my validation.xml was not valid - My formset tag was not closed properly at the end. However I still cant get my validator-rules.xml to validate. I'm still getting the IO Exception (previously defined). Please assist. I think it has to do with the DTD definition but I'm not sure.

Thanks.
 
Don't get me started about those stupid light bulbs.
 
subject: Struts and Vlidation