aspose file tools*
The moose likes Struts and the fly likes How To Code When Work With DynaValidatorForm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How To Code When Work With DynaValidatorForm" Watch "How To Code When Work With DynaValidatorForm" New topic
Author

How To Code When Work With DynaValidatorForm

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
Please help me in learning how to code when I am working with DynaValidatorForm.
1. in my struts-config.xml, I have:

2. My PostForm.java is like:

3. in my action class (see the code below)
3.1. do I cast the form to DynaActionForm? or I should cast the form to DynaValidatorForm?
3.2. Can I use the copyProperties() method of the BeanUtils to convert the form to a bean?
BeanUtils.copyProperties( threadBean, postForm );

4. the action mapping in my struts-config.xml is like:

Thank you.
Rick Hightower
Author
Ranch Hand

Joined: Feb 20, 2002
Posts: 350
It seems like you are mixing your metaphors. Why are you redefining the property in both the Java class version of the ActionForm and the properties file.
You either want to do one or the other.
If you are using DynaActionForms or DynaValidatorForms you do not need a class that subclasses DynaValidatorForm.


Rick Hightower is CTO of Mammatus which focuses on Cloud Computing, EC2, etc. Rick is invovled in Java CDI and Java EE as well. linkedin,twitter,blog
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
I do not quite get the idea. Please help with the drafted code for the PostForm, which is of type="org.apache.struts.validator.DynaValidatorForm"
1. which class should be imported?
2. how do I code the reset( ... )?

Thank you.
Rick Hightower
Author
Ranch Hand

Joined: Feb 20, 2002
Posts: 350
Do this:

(Notice form not dynamic)
With this:
<form-bean
name="postForm"
type="yourpackage.PostForm"/>

OR THIS:


BUT.... Not both
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
Allow me to ask three more questions:
1. If I want to reset some specific text fields when the JSP is re-displayed, do I code the PostForm.java like this (please confirm):

2. if I want to reset all the text fields when the JSP is re-displayed, do I code like this (please confirm):

3. What is the difference between

AND
Rick Hightower
Author
Ranch Hand

Joined: Feb 20, 2002
Posts: 350
Hey.... I answered this in a lot of detail (same question from the same person) in detail on the Struts mailing list.
I'll add a link to the archive as I hate doing....UBB
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How To Code When Work With DynaValidatorForm