Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Using a form with Struts 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Using a form with Struts 2" Watch "Using a form with Struts 2" New topic
Author

Using a form with Struts 2

m pa
Greenhorn

Joined: Apr 17, 2013
Posts: 17
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

Joined: Oct 29, 2001
Posts: 8839
    
    7

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using a form with Struts 2
 
Similar Threads
Cannot Retrieve Definition for Form Bean Null
Struts 1.3 Tiles not working
Struts Validator Plug-In Framework
Validation framework not working for multiple selections!!
Struts Validation of options box (java.lang.String[])