Hi Jean-Philippe,
Technically speaking, to return a representation from a PUT/POST you can just
access to the response's entity from the
store/acceptRepresentation method:
getResponse().setEntity(myEntity);
Best regards,
Jérôme Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
-----Message d'origine-----
De : Karel Vervaeke [mailto:[email protected]]
Envoyé : vendredi 16 janvier 2009 09:25
À : [email protected]
Objet : Re: Returning data after PUT/POST
I'm not sure if this will help you, but in case of a PUT, you already
know the url, issuing a GET to the same url
should (by your implementation) return the same entity body you
presented in the PUT. If you want to retrieve a 'more informative'
representation (i.e. including the 'internal' id), you could add a
query parameter to the url.
Alternatively (more appropriate in case of a POST) you can return a
201 Created status code [1] (with Location headers and url's in the
entity body) or a 202 Accepted status code
[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.2
HTH,
Karel
On Fri, Jan 16, 2009 at 2:37 AM, Jean-Philippe Steinmetz
<[email protected]> wrote:
> Hello everyone,
>
> I'm currently working on my first restlet application and have one big
> question. Typically when I want to persist some data I will not know certain
> information about it (i.e. the ID of the data). Instead of creating the
> object and searching for it I usually design my DAO to return the same
> object with the missing information filled in once it's been submitted to
> the persistence layer.
>
> I have noticed in building my restlet app that the storeRepresentation
> method does not return any type of data, only a status. Some of the clients
> that will be using the service would greatly benefit from the DAO style of
> data creation. So, how can I mimick this behavior in restlet so that a
> successful PUT returns the data back to the client as representation?
>
> Thanks for your time,
>
> Jean-Philippe
>
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1028170