Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How To Code When Work With DynaValidatorForm

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do this:

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

OR THIS:


BUT.... Not both
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic