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

Struts Validation for non formdata

sivalingam balachandar
Greenhorn

Joined: Apr 20, 2007
Posts: 4
Hello

I have some idea about validation framework.

The project need is, I have to

1)fetch records from some tables
2)Validate the records against row(like date validat, required)
3)If record is correct insert, into one table
else insert into another table.

I have used struts validation to validate form fields using DynaValidatorForm.

In my scenario, no form is there(2nd part), . I have to do some validation against some strings, it may be in
the text or xml file.

Please guide me, this validation is possible using struts framework?


Thank you,
balachandar
Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
You have a couple of options:

1. Use the form's validate method to fetch the data from the xml file to check against.
2. Add a custom validator to the validator-rules.xml which can open the xml file to check against.
3. When your action calls your business layer, do the check in the business layer and throw any validation errors back to the action, which should handle to errors and forward to the input page.

I'd prefer method 3 if I had to do any validation against any dynamic content (i.e. does username already exist).

If you have any questions, if sure I or someone else will be able to help you further.
sivalingam balachandar
Greenhorn

Joined: Apr 20, 2007
Posts: 4
Thank you for the reply.

Sorry i did not tell the exact requirement. The project is not a web application.

1) At a particular time (schedular), We have to extract records from
collections of tables through JDBC.

2) Once records are fetched, we have to do validations ( data validation and business validation)

From this place i need guidance.

Assume, the records are in ResultSet. I need to do validation in the resultset records.

Please guide me Which is the good approach,

1) Extract record one by one from ResultSet and create POJO for that, and do validation against POJO using struts validation framework. Is it possible?

2) Extract record one by one from ResultSet and create XML file for that record, and do validation against XML file using struts validation framework. Is it possible?

If there is other ways, itself ok.

The final result should be, after the validation I have to store error record with error description and correct record in a seperate file.

I have used struts validation in web applications, not in others.

If you have any links and tutorials to use stuts validation for non web application, please share with me.

Thank you for the guidance.
balachandar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts Validation for non formdata