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

Learning WPF nowadays. Found something new today with .Net dependency properties. What they bring
Learning from my last question , most member names seem to get included in
While learning different languages, I've often seen objects allocated on the fly, most often
Learning a little about T-SQL, and thought an interesting exercise would be to generate
Will learning C++ help me build native applications with good speed? Will it help
For learning and demonstrating, I need a macro which prints its parameter and evaluates
Im learning lisp and im pretty new at this so i was wondering... if
I'm learning about table design in SQL and I'm wonder how to create a
I remember first learning about vectors in the STL and after some time, I
I am learning Python for a class now, and we just covered tuples as

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.