Announcement Announcement Module
Collapse
No announcement yet.
about controller commands Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • about controller commands

    this could be a silly question but I am new to this and need some guidance. What is the proper scenerio to bind controllers to a command (btw, there is no way to use multiple commands right?)

    I have seen Spring examples that use both the controller command and the request.get() to retrieve user inputs.

    So,
    1) is command best suited to accept inputs when the input business model? like an account object?
    2) if that is the case, the command object sometimes is insufficient to capture all user inputs. Is it proper to utilize request.get() at the same time?
    3) or, is command simply the same as a formBean, and should be constructed to map all possible user inputs nad not to be confused with a real business model object?

    Thanks!

    yan

  • #2
    These are just my opinions but....

    1) is command best suited to accept inputs when the input business model? like an account object?
    Yes. (Well a command can be anything, but if you mean is it the right approach to use a business object - yes)

    2) if that is the case, the command object sometimes is insufficient to capture all user inputs. Is it proper to utilize request.get() at the same time?
    Yes.

    3) or, is command simply the same as a formBean, and should be constructed to map all possible user inputs nad not to be confused with a real business model object?
    Not usually, although sometimes it may be necessary to create a command object to simply to capture form data. This should be a second choice to directly bind to a domain object (or a combination of points 1 and 2).

    Comment


    • #3
      if the best approach is combining one and two, which is:

      1) bind a form(view) to a business model object as much as possible
      2) for all user inputs outside of the business model object, use request.get etc...

      I see a couple of problems

      a) what if the form (view) is capturing multiple model objects? As far as I know Spring's controller can only bind to one command object
      b) it seem to me to be a little awkward to get user inputs two different ways. developers have to be very concious of where those inputs are coming from, command object or request scope ...
      c) doesn't that tie the implementation of Spring controllers to the implementation specifics, web app in this example, things like HttpRequest objects?

      thanks!

      Comment


      • #4
        what if the form (view) is capturing multiple model objects?
        You can always combine command objects into a single containing object and using nesting.

        it seem to me to be a little awkward to get user inputs two different ways
        The choice is yours.

        doesn't that tie the implementation of Spring controllers to the implementation specifics, web app in this example, things like HttpRequest objects?
        Yes. If your concern is testing, it's pretty eay to mock request objects with parameters. Again, the choice is yours.

        Comment

        Working...
        X