This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Struts and the fly likes DynaForm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "DynaForm" Watch "DynaForm" New topic


raj joe
Ranch Hand

Joined: Mar 17, 2005
Posts: 99
What are the advnatages and disadvantages of using DynaForms in struts.
Please can you give me an example
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864

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


* 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.

Consultant, Sima Solutions
I agree. Here's the link:
subject: DynaForm
It's not a secret anymore!