Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3403562
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:16:34+00:00 2026-05-18T05:16:34+00:00

i am learning struts2 from the book struts-2 in action. they say that for

  • 0

i am learning struts2 from the book struts-2 in action. they say that for transferring data onto objects model-driven actions is preferred over object-backed beans properties.

can some1 explain me why they say so?

does the reason have something to do with the need to mention reference name in the view layer

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T05:16:35+00:00Added an answer on May 18, 2026 at 5:16 am

    In cases where you are dealing with several properties, the book advocates using an object to hold those properties, rather than having them directly on the action to make things easier for you. Consider the following examples:

    public class CreateNewWidgetAction extends ActionSupport {
        private String property1;
        private String property2;
        private Long property3;
        ...
    
        public String execute() throws Exception {
            Widget widget = new Widget();
            // set properties on widget
        }
    
        // getters and setters for properties here
    }
    
    public class CreateNewWidgetAction extends ActionSupport {
        private Widget widget;
    
        public String execute() throws Exception {
            // sub properties for widget were already set, less work to do here
        }
    
        // getter and setter for widget here (or the
        // getModel method if you are using the Model Driven approach)
    }
    

    In the second example, we set the properties directly on Widget (assuming that widget has a property1, property2, and property3).

    Hopefully you can see how this would simplify your code in examples where you are dealing with a lot of properties.

    Updated:
    If you choose to implement ModelDriven, then you would reference the properties above in your form as property1, property2, property3, etc. Additionally, since your action is driven by a single model, all form parameters are considered to be children of the model.

    If you choose not to implement ModelDriven then you would reference the properties above in your form as widget.property1, widget.property2, widget.property3, etc. The upside to this approach is that you can have other properties on the action which don’t correspond to properties on widget.

    Aside from that, there is no difference. In fact, the book even says as much:

    Like the object-backed JavaBeans property, the ModelDriven action also allows us to use a complex Java object to receive our data. The differences between these two methods are slight, and there are no functional consequences to choosing one over the other.

    – Struts 2 in Action, Chapter 3. Working with Struts 2 actions > Transferring data onto objects – Pg. 62

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Coming from PHP with some Java Struts 2.0 experience any tips/tricks on learning GWT?
i have done some learning on struts based on one project that i got.Now
Learning Objective-C and reading sample code, I notice that objects are usually created using
I have just started learning struts 2. I have purchased the book named Struts
i have done self study on learning struts 2. i have used one code
Learning a lot in my few years of programming that the best projects are
Learning xml, Can anyone help me? I have following XML code: **<book lang=en>name of
I am currently in the process of learning Struts 2 and I am currently
BACKGROUND I am learning Java and currently on JSF. I come from an ASP.NET
BACKGROUND I am learning Struts 1.x and currently on the validation framework. PROBLEM I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.