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

  • referenceData problem

    If I use referenceData in my SimpleFormController then I get the dreaded
    Neither Errors instance nor plain target object for bean name 'adminForm' available as request attribute
    The only way I've figured out how to get rid of this is to not use referenceData and instead have a showForm method and in it create a ModelAndView with 3 args:
    Code:
    ModelAndView mav = new ModelAndView(getFormView(), "adminForm",
                                                new AdminForm());
    My constructor is setting the command class:
    Code:
    public
    AdminCtlr() {
        setCommandClass(AdminForm.class);
    
        setFormView("admin");
        setSuccessView("redirect:admin_history.html");
    }
    What am I doing wrong?

  • #2
    Oops; I forgot the
    Code:
    setCommandName("adminForm");

    Comment


    • #3
      you should use formBackingObject() method for the creation of your command class instance

      Comment


      • #4
        Originally posted by EndlessWinter
        you should use formBackingObject() method for the creation of your command class instance
        Ok, thanks.

        So what's happening when I do
        Code:
        ModelAndView mav = new ModelAndView(getFormView(), "adminForm",
                                                    new AdminForm());
        Why does that cause my command object to not get its data added to it on the form submit?

        I feel like I'm writing code on Perl, where there are 25 different ways to do the same thing, but unlike Perl, only 1 way (or a few ways) works. But figuring out the one true way is like solving a puzzle.

        Comment


        • #5
          because prior onSubmit Spring binds to the object, that was created in formBackingObject() method. This object is different from the one you created yourself here:
          ModelAndView mav = new ModelAndView(getFormView(), "adminForm",
          new AdminForm());

          by default formBackingObject creates your command's class instance using reflection.
          There is quite a decent method flow description in Spring javadoc

          Comment


          • #6
            Ah, ok. Thanks.

            Comment

            Working...
            X