Results 1 to 3 of 3

Thread: What should be inside a command object.

  1. #1
    Join Date
    Feb 2007
    Posts
    291

    Default What should be inside a command object.

    My concept of a command object should contain only input value that would be binded.

    1.) Now here are some question. Should command object hold read only value that would not get persisted into session (like hold list of replies from a post).

    2.) Should command object hold submit value (this allows us to choose what to validate base on submit value).

    MyCommand command;

    if (command.getSubmitValue().equals("submit 1")
    {
    // validate submit 1.
    }
    else if (command.getSubmitValue().equals("submit 2")
    {
    // validate submit 2
    }


    3.) What is a good command object?

  2. #2

    Default

    Having a little difficulty in understanding your question, but I'll try and come up with suggestions.

    Keeping things simple, a Command object's main purpose is to represent user input in an object oriented form. It makes it easier to work with data using objects (similar to mapping data to Entity objects) within the Java program (such as updating the database, validation, etc.).

    In the given scenario, if you were to hold a list of replies for a post, then that would be held as a Value object. So this would be separate to the Command object. Override the referenceData(HttpServletRequest request) method to assign Value objects to the page when it loads.

    I hope I've understood some of your questions. Now for my question. Why is a Command object called a "Command" object? Is it derived from the Command pattern that is used by these Controllers? I just wanted to know why it is named like this.

    Many thanks.


    Shah.

    (Btw, I cannot provide an answer to question 2).

  3. #3

    Default

    Thanks stephenpeter. But I don't think that is the answer.

    The Command object you suggested is related to .NET's ADO.NET framework, which relates to querying data sources.

    The Command object that is referred to the original post is related to Spring MVC (it is also known as a Form object). Please refer to the 2nd paragraph under http://static.springframework.org/sp...rence/mvc.html.

    Hope this helps.


    Shah.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •