Results 1 to 3 of 3

Thread: SimpleFormController with multiple bean

Hybrid View

  1. #1
    Join Date
    Aug 2004
    Location
    Paris
    Posts
    43

    Default SimpleFormController with multiple bean

    Hi, my application need to post a form with one bean, to bind the parameters in the request to this bean, and then to retrieve another instance of this bean to pass it back to the view.
    The issue I have been having here, is that from my understanding, in a SimpleFormController, the bean retrieved by the formBackingObject method, will be the same one than the one spring will use to bind the parameters and pass back to the form in the showForm method after a submit.
    I solved my issue, by overriding the referenceData since this method is executed after the bind process and before the showForm. I add the following code line :
    Code:
    MyNewBean bean= manager.getBean(myNewID);
    BindException bind = new BindException(bean,getCommandName());
    model.put(getCommandName(),bean);
    model.put(BindException.class.getName()+"."+getCommandName(),bind);
    It worked but look for me like a hack more than a standard use of the SimpleFormController. What do the spring team will recommand ?

    Thanks

    Olivier

  2. #2
    Join Date
    Aug 2004
    Location
    Warsaw, Poland
    Posts
    33

    Default Re: SimpleFormController with multiple bean

    Quote Originally Posted by olivier
    Hi, my application need to post a form with one bean, to bind the parameters in the request to this bean, and then to retrieve another instance of this bean to pass it back to the view.
    The issue I have been having here, is that from my understanding, in a SimpleFormController, the bean retrieved by the formBackingObject method, will be the same one than the one spring will use to bind the parameters and pass back to the form in the showForm method after a submit.
    That's true. SimpleFormController is very specialized controller and is supposed to work with the same bean. You retrieve bean in formBackingObject, controller saves it in the session and repopulates it on form submission.

    If I were You I would prefer to implement my own sublcass of AbstractFormController or even one of CommandControlers. Of course what You did above works - but indeed it's IMHO a hack.

    BTW: Could you tell what do you do such a uncommon thing, why do You need another instance of the form command bean?

    Artur

  3. #3
    Join Date
    Aug 2004
    Location
    Paris
    Posts
    43

    Default

    Thanks, I was thinking about doing my own implementation of the controller, but most of the code, will be a pure copy of the SimpleFormController.

    Basically, the application, is used to describe several objects of the same type, using one controller and one form. For exemple, I have 4 cars to describe. My controller, show first a init page, where I can input the number of cars, and then for each car, I show the same form that need to be inputed and finally finish by displaying the successView.

    Olivier

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM

Posting Permissions

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