Results 1 to 3 of 3

Thread: doSubmitAction() ignores referenceData()

  1. #1
    Join Date
    Jul 2005
    Location
    Munich, Germany
    Posts
    153

    Default doSubmitAction() ignores referenceData()

    Hallo,

    I'd like to use doSubmitAction() instead of onSubmit() in a simple controller, but obviously my referenceData() is called but the returned Map isn't merged with the ModelAndView.

    Code that work:

    Code:
        @Override
        protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors)
        throws Exception
        {
            // ... my save methods ...
            
            return showForm(request, response, errors);
        }

    Code that doesnt' work:

    Code:
        @Override
        protected void doSubmitAction(Object command)
        throws Exception
        {
            // ... my save methods ...
        }

    In the latter case the form is correctly redisplayed, but all data set by referenceData() is missing.


    Any hints?



    Best
    Oliver

  2. #2
    Join Date
    Oct 2005
    Location
    Arlington, VA
    Posts
    14

    Default

    The doSubmitAction does not call referenceData because it is expected that after a succesful form submission, you would forward to a "success" page and not back to the form.

    The Form controller is handles 2 types of requests:
    • The Request to get the form page for the user to enter data.
      (This needs to be an HTTP "GET" request). The Form Controller will internally use the "showForm", which will call "referenceData", the idea being that a Form probably has drop down lists, radio buttons, etc. and referenceData can be used to supply values for these things.

    • The use fills out the form and submits back to the form controller (This needs to be an HTTP "POST" request). The "doSubmitAction" will handle the form submit, update a database or do whatever with the data the user entered. It is then expected that the user will be forwarded to some kind of "success" page, where there would be no need for the form reference data, hence "referenceData" is not called.

    If you really need to send the user back to the form after a successful form submission, then I think calling "showForm" yourself is a good idea (like your first code snippet does).

  3. #3
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    you might also find it useful to know that SFC will call isFormSubmission to determine whether it is a "get" or a "post".

Similar Threads

  1. ReferenceData Binding problem
    By kermie5000 in forum Web
    Replies: 7
    Last Post: Sep 19th, 2005, 11:12 AM
  2. referenceData equivalent
    By Aro in forum Web Flow
    Replies: 1
    Last Post: Aug 29th, 2005, 08:54 AM
  3. command object in referenceData??
    By smithabr in forum Web
    Replies: 5
    Last Post: Jul 12th, 2005, 06:11 PM
  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
  •