Announcement Announcement Module
Collapse
No announcement yet.
Controller can't handle Entity creation with multiple parameters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Controller can't handle Entity creation with multiple parameters

    Hi,

    I am currently developing an application which lets users create clients
    and associate one or more emails to them.

    Here’s the Spring Roo script which I wrote to generate the application:

    ---------------------------------------------------------------------------------------
    # Email Table
    entity jpa --class ~.model.Email --testAutomatically
    field string --fieldName email --notNull --sizeMin 1 --sizeMax 30

    # Note Table
    entity jpa --class ~.model.Note --testAutomatically
    field string --fieldName note

    # Client Table
    entity jpa --class ~.model.Client --testAutomatically
    field string --fieldName name --notNull --sizeMin 1 --sizeMax 30
    field set --fieldName emails --type ~.model.Email --cardinality ONE_TO_MANY --mappedBy client
    field set --fieldName notes --type ~.model.Note --cardinality ONE_TO_MANY --mappedBy client

    # Email Table
    focus --class ~.model.Email
    field reference --fieldName client --type ~.model.Client --cardinality MANY_TO_ONE

    # Note Table
    focus --class ~.model.Note
    field reference --fieldName client --type ~.model.Client --cardinality MANY_TO_ONE

    # MVC
    # change project type to web application and output war artifact
    web mvc setup
    # Generate Controller, etc.
    web mvc all --package ~.web
    ----------------------------------------------------------------


    Whenever I create new e-mails in my running application, I get a
    Status 400 error stating that
    “the request sent by the client was syntactically incorrect”.

    The data sent over the network by my browser to the application are the following:

    POST /myapplication/emails

    and

    Email=email1&&client=client1

    in the POST’s BODY.

    So it would seems as though the application can't handle /emails queries
    with parameter values.

    I have added breakpoints all over the EmailController.....aj (Aspect J) class and run my application
    in debugging mode to see where it lands in the code when I click the Save Button on the
    Email Creation Page.

    What I have discovered is that it lands nowhere, not even in the

    @RequestMapping(method=RequestMethod.POST, produces="text/html")
    public String EmailController.create(@Valid Email email, BindingResult...

    method as one would expect.

    How should I handle POST queries sent by the email-create form,
    with two parameters (client and email), in the EmailController or elsewhere?

    Many thanks.

    Philroc
Working...
X