File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Why use DynaActionForm? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Why use DynaActionForm?" Watch "Why use DynaActionForm?" New topic

Why use DynaActionForm?

Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 751
I've read an article about DynaActionForm... However... I could not grasp its usefulness in my application... If I use it instead of ValidatorForm... Will I still be able to perform automated validation? What's the essence of it? Thanks!

SCJP 1.5
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
With a DynaActionForm, instead of writing classes that extend ActionForm, you define all your form beans as DynaActionForm, and define the properties for each form in the struts-config.xml file. If you want to use this functionality AND still use the Struts Validator framework, you will use DynaValidatorForm instead of DynaActionForm.

Some developers prefer defining things in XML to writing javaBeans. I happen to prefer writing beans that extend ActionForm to using DynaActionForm. Using an IDE such as Eclipse, they're very easy to write, thanks to automatic getter and setter code generation. Another big advantage they have over DynaActionForm is that if you spell one of the properties wrong in your Action class, the compiler will tell you. That is not the case with a DynaActionForm.

Also, to me, writing myBean.getLastName() is much simpler and more intuitive than writing (String)myDynaForm.get("lastName");

Consultant, Sima Solutions
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 751
Thanks Merill! I think I'll stick with ActionForm/ValidatorForm then... Thanks!
I agree. Here's the link:
subject: Why use DynaActionForm?
It's not a secret anymore!