Results 1 to 6 of 6

Thread: command object in referenceData??

  1. #1
    Join Date
    Apr 2005
    Location
    North Carolina
    Posts
    3

    Default 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. #2
    Join Date
    May 2005
    Posts
    5

    Default

    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.

  3. #3
    Join Date
    Aug 2004
    Location
    Sydney
    Posts
    503

    Default

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

  4. #4
    Join Date
    May 2005
    Posts
    5

    Default

    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?

  5. #5
    Join Date
    Aug 2004
    Location
    Sydney
    Posts
    503

    Default

    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.

  6. #6
    Join Date
    Aug 2004
    Posts
    9

    Default

    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"

Similar Threads

  1. Replies: 5
    Last Post: Jan 27th, 2009, 07:07 AM
  2. Replies: 2
    Last Post: Oct 10th, 2005, 04:02 AM
  3. ReferenceData Binding problem
    By kermie5000 in forum Web
    Replies: 7
    Last Post: Sep 19th, 2005, 11:12 AM
  4. about referenceData
    By thenakedsingularity in forum Web
    Replies: 3
    Last Post: Apr 14th, 2005, 12:57 PM
  5. Replies: 2
    Last Post: Sep 2nd, 2004, 08:18 AM

Posting Permissions

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