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

Why use DynaActionForm?

 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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");
 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Merill! I think I'll stick with ActionForm/ValidatorForm then... Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic