• 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 vs ActionForm

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All

I would like to know the difference between DynaForm and ActionForm and also about the resources which tell me in details about the new features in Struts 1.1 compared to 1.0

Thanks in advance.
 
Author
Posts: 93
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ankur,

An ActionForm holds form data submitted from a request. As a developer you extend the ActionForm class and provide your own implementation of it. You have to physically write get()/set() methods for each of the attributes you are collecting from the form.

A DynaActionForm is a declarative model. With a DynaActionForm you declare the attributes you are collecting from the web form as an XML declaration in the struts-config.xml. DynaActionForms work well if you are just collecting data and using the basic validation rules that come with the Validator framework.

They are easy to setup and you can add/remove attributes without having to modify your code. I hope that answers your question.

Thanks,
John
 
Ankur Srivastava
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi John,

Ya that has very much answered my question. Thanks for the prompt reply. But can you tell me is the validation framework also declarative, that is I do not have to write the validate method.

Surely it must be otherwise where will we write a validate method as we are not writing the ActionForm classes. But then does it support Regular Expressions and what about complex validations.

Thanks again
Ankur
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ankur Srivastava:
can you tell me is the validation framework also declarative, that is I do not have to write the validate method.

Surely it must be otherwise where will we write a validate method as we are not writing the ActionForm classes. But then does it support Regular Expressions and what about complex validations.


There's a method
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request);
defined in the ActionForm base class, which you can override in order to implement form validation.

However, there's also the Struts Validator which is a declarative validation framework (with validations specified in an XML file).

You can read more about the Struts Validator in the Struts Validator Guide.
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I should add that dyna forms seems to be a bit more prone to trouble with your IDE.

If you're using Eclipse and JBoss they can sometimes cause errors for no real reason .

In my case, everytime I change a dynaform, I have to delete several xml files, shut down Eclipse, start it back up, and run XDoclet.

If I don't do that, I'll keep getting "Invalid Property Name" errors.

I suggest that you start with dyna's and if they give you problems, test out the same form as an ActionForm.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This will given me the basic difference between both the type of forms. Can any one suggest where we can use each of one? If any one explains with some example it is more clear.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic