Ticket #306 (closed defect: fixed)
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.