• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Struts and Vlidation  RSS feed

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
go through the struts validation documentation here.
That should clear up most of your doubts
 
Aash Patel
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!