Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: Command object in the onSubmit method of SimpleFormController

  1. #1

    Post Command object in the onSubmit method of SimpleFormController

    Why the name of a bind object is named as command? I think command is a pattern and a bind object is a form.
    For example:

    Code:
    public class BlahblahController extends SimpleFormController {
    
        protected ModelAndView onSubmit(
            HttpServletRequest request,
            HttpServletResponse response,
            Object command,
            BindException errors) throws ServletException, IOException {
    ...
    Thanx.
    ..:: non compos mentis ::..

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Call me stupid but I really don't understand your question.

    In Spring commandObject and formBacking Object can be used accordingly. Is has nothing to do with the Command Pattern you mention.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Quote Originally Posted by mdeinum View Post
    Call me stupid but I really don't understand your question.

    In Spring commandObject and formBacking Object can be used accordingly. Is has nothing to do with the Command Pattern you mention.
    Why name of parameter is command?
    ..:: non compos mentis ::..

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Because the method is called formBackingObject and it returns a Command Object (not in anyway related to the Command Pattern you mentioned). In Spring the formBackingObject is named a command object and hence the name is command.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5

    Default

    Quote Originally Posted by mdeinum View Post
    Because the method is called formBackingObject and it returns a Command Object (not in anyway related to the Command Pattern you mentioned). In Spring the formBackingObject is named a command object and hence the name is command.
    Call me stupid but I think it's not a clear explanation.
    ..:: non compos mentis ::..

  6. #6
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Read this .

    The controller is a CommandController the root of all these controllers is the BaseCommandController. The method used to create the object which this Controller works on/with is getCommand.

    Basicly everything which extends BaseCommandController is a command controller. Hence the naming of the property.

    Although it might become confusing when looking at the AbstractFormController which is a sub class of the BaseCommandController. This delegates the creating of a command object to the formBackingObject. method. But still it is a command Controller.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  7. #7

    Default

    As I see the command is a simple JavaBean which can be shown on a jsp. Form is a JavaBean which can be shown on a jsp and submitted (according to http://static.springframework.org/sp...oller-command).

    For the avoidance of misunderstanding it should be a bit better to name a command parameter as anyObject or some else.
    ..:: non compos mentis ::..

  8. #8
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Why? It IS the command which represents the form. The command and form are the same there is no difference.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  9. #9

    Default

    Quote Originally Posted by mdeinum View Post
    Why? It IS the command which represents the form. The command and form are the same there is no difference.
    We're almost there...
    My main question is why the object named as command? This name is not meaning for programmers I think. Form is more convenient name.
    ..:: non compos mentis ::..

  10. #10
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    No it isn't because the command doesn't have to be a form.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

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