• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DynaForm

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are the advnatages and disadvantages of using DynaForms in struts.
Please can you give me an example
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
advantages:

* you don't have to write subclasses of ActionForm. You define all your form beans and their properties in the struts-config.xml file.

disadvantages:

* It's more verbose and not as intuitive to extract properties
* the compiler will not catch your errors if you misspell a property name.

For example, if you have a proerty "name" in the form, here's how you get it using the a subclass of Action form:

String name = myForm.getName();

and here's how you get it using DynaActionForm:

String name = (String) dynaActionForm.get("name");

If you have to write code to get 25 different properties, which one would you rather use?


I personally seldom use DynaActionform. If you're using an IDE that has automatic generation of getters and setters, you can write an ActionForm class just as easily as you can write the XML for a DynaActionForm. Plus you get help from the compiler in checking the correctness of property names, as well as the use of your IDE's auto-completion function.
reply
    Bookmark Topic Watch Topic
  • New Topic