Oups, sorry I misread your message.

This is what you want to do:

@Post
public Representation handlePost(Representation entity) throws
ResourceException {
  final Form form = new Form(entity);
  String param1 = form.getFirstValue("param1");
  String param2 = form.getFirstValue("param2", DEFAULT_VALUE_FOR_PARAM2_HERE);
  // rest of parameters gathering and processing here
}

if you want to make sure that 'entity' is a web form then you have two options:

@Post("form")
public Representation handlePost(Form webForm) ResourceException {
   String param1 = webForm.getFirstValue("param1");
   ...
}

or

@Post
public Representation handlerAcceptingMoreThanJustForms(Representation
entity) throws ResourceException {
  String param1;
  String param2;
  if (MediaType.APPLICATION_WWW_FORM.isCompatible(entity)) { // Got a web form
    final Form form = new Form(entity);
    param1 = form.getFirstValue("param1");
    ...
  } else if (MediaType.APPLICATION_JSON.isCompatible(entity)) { // Got JSON
     final JSONObject json = new JsonRepresentation(entity).getJsonObject();
     param1 = json.optString("param1");
     ...
  }
}

Hope this helps.

On Fri, Apr 29, 2011 at 1:38 PM, aquestion10
<[email protected]> wrote:
> This works only for GET requests right? My form does a post..
>
> ------------------------------------------------------
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2726229
>



-- 
Fabián Mandelbaum
IS Engineer

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2726368

Reply via email to