my dog learned polymorphism*
The moose likes Struts and the fly likes Validate of Form data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validate of Form data" Watch "Validate of Form data" New topic
Author

Validate of Form data

Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
I am currently add the validation rules to:
1. the method validate() of the ActionForm
2. the pattern matching rules inside validate.xml

However, I found something interesting.

Before I add the checking, when I put my data inside the JSP, the form captures the data, and they display correctly in the textfields (Many add/drop actions are done and redirect back to the original page).

In these cases, I will not do anything for checking.

However, when the user clicks submit, I will let the form be checked by validate(), as well as the validate.xml.

If there is no errors, that's fine, the data can be saved inside the DB.

But if there is errors, the form data is reset to the original value!!! All updates are lost!

How should I solve this problem?

Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Insert a statement that prints to your logger or console. It should print the values of some of your fields.
Place the statement in various places along the path where the fields are getting lost.

This should help you to pinpoint where in the chain of command your data is being lost.


A good workman is known by his tools.
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
So far as I know, if the Form cannot be validated, the Struts action will not be reached. And thus, the only method call should be validate() and super.validate().

I have checked that the values of the Form are same as the user input inside the validate() method, however, when the data backs to the frontend, the values have been reset.

Any ideas?

Nick
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Some possibilities:

1) The jsp uses regular html tags and not struts for creating form input fields - only struts tags will prepopulate
2) The reset() of ActionForm is clearing everything out
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validate of Form data
 
Similar Threads
Checkbox/Multibox validation in Struts
Validation of Struts Forms
Advice for Struts forms with validation
form-bean with DynaValidatorForm
Javascript error in range validation