File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using a form with Struts 2

 
m pa
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am familiar with struts 1.3 where in the struts.xml file you can define a form that contains beans, lists of beans etc and then that form can be used by different actions.
example in struts 1.3

The examples I have found is having a Person bean and then importing into the action class, see http://struts.apache.org/release/2.3.x/docs/processing-forms.html

If I wanted to have a form like that above in Struts 2, am I correct in thinking I would define a class e.g. CustInfoForm, have getters/setters for all the properties and then include the form in whatever class it is needed?

In other words, is there no equivalent of the DynaActionForm in struts 2 that allows forms to be defined in the struts.xml file?
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts 2 does away with forms beans (thank goodness!). It uses Plain Old Java Objects (POJO's), so instead of creating a form bean, you'd just create a POJO for your customer information and create it or populate it in your action class. Since the action has a direct reference to it, there's no need to configure it in an XML file.
DynaActionForm was a work-around for having to create a form bean for each form. Since we don't have form beans, we don't need DynaActionForm.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic