Announcement Announcement Module
Collapse
No announcement yet.
command object in referenceData?? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • command object in referenceData??

    I need to access command object in referenceData in WizardController as the third page data is actually dependent on the first page data which I added in.
    I have the request attribute, but how do I access the command object?
    Is it stored in session or in request itself and in what name??

  • #2
    hi

    Don't know if I can help you, but are you knowing the method below?
    Code:
    protected Object formBackingObject(HttpServletRequest request) throws Exception
    This method will be called before the site is displayed ant the Object you can return is your command object.

    I'm using both methods. For data outside my command, i fill in a map in the method referenceData and for the other data, i use the method formBackingObject.

    Don't know if this is the right way but it works for me. And perhaps I can help you with this information.

    Comment


    • #3
      There are 3 overloaded version of referenceData. 2 of them contain the command Object.

      Comment


      • #4
        Is be behavior the same as the method formBackingObject has? Can I modify the command object and the values will be set on my site?

        Comment


        • #5
          You can modify the command object at any time, which will affect the 'values ... set on my site'

          referenceData is called for every request.

          formBackingObject is called to create the command object, either
          a) for every request, if you're not using sessions, or
          b) the first time the page is displayed if you are using sessions.

          Is it stored in session or in request itself and in what name??
          You can configure both of these things. Try reading through the source for BaseCommandController.

          Comment


          • #6
            Just so everyone knows if you alter the command object in referenceData(..., Object command, ...) it will not be passed down to the view. This is because the showNewForm is called after referenceData and it gets a new command object with all of its fields set to null. That is to say, if you want to pass down data in the command object to pre-populate a form in your view you will HAVE TO override formBackingObject!

            It's a pain since you have to manage your reference data in both referenceData and formBackingObject if you want to pre-populate your form. Also make sure to check for isFormSubmission(...) in your implementation of formBackingObject(). Another thing to watch out for is that the current implementation of isFormSubmission only handles POST request so make sure you specify <form method="POST"> since a form without a method attribute defaults to "GET"

            Comment

            Working...
            X