Ticket #306 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

Empty message is sent to server when posting a form without values

Reported by: sdm Owned by: mpo
Priority: minor Milestone: 0.4
Component: modules/kauri-forms Version: trunk
Keywords: post empty form Cc:

Description (last modified by jgou) (diff)

Suppose you have a Kauri form with the following fconf:

var fconf = {
          "createURI": "${publicUri('service:/data/contact/')}",
          type: {
              members: {
                  'name': 'string',
                  'email': {
                      base: 'string'
                  },
                  'birthday': {
                      base: 'date'
                  },
                  'description': {
                      base: 'string'
                  }
              }
          }};

Nothing is required, so it's possible to post the form without entering values. I would expect an empty JSON array {} to be sent to the server, but instead nothing is sent: the header of the POST message has no content-length.

When the post is handled by a JAX-RS resource method like the following:

@POST
@Consumes("application/json")
public void handlePost(String data)
{}

, this method is not called because there is no post data.

This behaviour is only seen in IE and FF, in Chrome 'undefined' is sent (the same behaviour as in #302)

To reproduce this, edit the kauri-forms-sample basic controls page with an fconf as specified and submit an empty form. This causes the following error:

net.sf.json.JSONException: Invalid JSON String
        at net.sf.json.JSONSerializer.toJSON(JSONSerializer.java:143)
        at net.sf.json.JSONSerializer.toJSON(JSONSerializer.java:103)
        at net.sf.json.JSONSerializer.toJSON(JSONSerializer.java:84)
        at org.kauriproject.dbresources.mock.DbMockResource.handlePost(DbMockResource.java:196)
        at org.restlet.resource.Finder.handle(Finder.java:476)

This issue is related to #302, but the difference here is that the form does have members, but no values are specified.

Change History

comment:1 Changed 3 years ago by jgou

  • Description modified (diff)

comment:2 Changed 3 years ago by freya

can you please verify in r1573?

comment:3 Changed 3 years ago by sdm

Works for me!

comment:4 Changed 3 years ago by freya

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.