This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Validation fetching rules from Database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validation fetching rules from Database" Watch "Validation fetching rules from Database" New topic

Validation fetching rules from Database

Rammohan Bandakunta

Joined: Aug 17, 2005
Posts: 9
I have some javascript Functions which are for basic validations like length ,numeric but I have some set of Rules that I need to Fetch in, when a dropdown is selected in the Front End,thus the length rules changes with mask and other parameters.

1>should i store these Rules in the Database and Fetch using DAO in to Action Form and the Front End.
2>should i Hardcode all the Function in the Front end and validate onChange submit with the Dropdown.

or Can I use the Validaation Framework which struts seems to offer,I am not sure how the validation Framework really works.

Suggest please..
Kerry Wilson
Ranch Hand

Joined: Oct 29, 2003
Posts: 254
Definitely use validation framework, storing code in a database (javascript or otherwise) is never a good idea. Here is a good tutorial:
SCJP 1.4
Rammohan Bandakunta

Joined: Aug 17, 2005
Posts: 9
Thanks kerry,
I have an working project developed so far with jsp's,Action,FormBean's and DAO suggest me the best way of approachin validation's through Frame work so that i need not have much of cleanin..
Rammohan Bandakunta

Joined: Aug 17, 2005
Posts: 9

I made the required changes in struts-config ,validation and validation-rules.xml

issue is when i change the value in the drop down for a perticular field the Min and Max length value should change and the field should validate against the updated value.
ex:if for a perticular value (a) in the Dropdown the length against which a serial number field is validated is 10,on changing or selecting the value in the dropdown to (b) the length against which serialnumber field should be validated is 20,

Any thoughts about how i need to submit the value on change in to the validation.xml

In struts validation whats the best way to implement this
<TD height="39" width="106">ApplicationType</TD>
<TD height="39" width="179"><html:select name="micrtoolhomeCBForm"
onchange="javascript ocument.forms[0].submit()">
<html ptions collection="applicationTypeList" property="value"
labelProperty="label" />
if (decknumber==null || decknumber.length==0){

alert("Please enter DeckName ")
return false;
else if(decknumber.length>10) {
alert("Please enter deckname < 10 char...")
return false;
else if (serialnumber==null || serialnumber.length==0)
alert("please enter SerialNumber.")
return false;
else if(serialnumber.length>10 ) {
alert("Please enter serialnumber < Serial Length Rule For Selected AppType")
return false;
Don't get me started about those stupid light bulbs.
subject: Validation fetching rules from Database
Similar Threads
Spring Validation
Populating DropDown in javascript
issue with Validation
retreive value after validation error
front-end validation in struts jsp page