Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validate of Form data

 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic