You don't need to put a media type if you're using void (although, you could potentially have more than one @Post handler, for several media types, to be used depending on the expectation of a media type from the client...).


But, you do need to disable conditional mode:

@Post
public void handlePost(Representation rep) { ... }

@Override
protected void init()
{
    setConditional(false);
}


Why? I'm still a bit in the dark about this. My current instinct tells me that there's a bug in how the preferred variant is calculated for conditional mode, in that it doesn't gather variants for the particular method. Thus, I suspect (I haven't tested this) that if you had a @Get with a particular media type (say, @Get("txt")) then there would be a preferred variant and your @Post would be called, even in conditional mode.


Please take that last paragraph with a truckload of salt. :)


-Tal


David Fogel wrote:

Hi Tal-

I will definitely take a look at your script extension, thanks for the
suggestion!

I think I understand the general deal with the mediatype annotation
argument.  But like I said, I was trying to define a Post method that
doesn't return content (and which therefore wouldn't make sense to
declare a mediatype for.  So what's the right annotation argument for
this method?

@Post("[what goes here?]")
public void handlePost(Representation rep) { ... }

what I found was that I had to put a return type or a mediatype, or
else ServerResource refuses to call the method, due to the lack of a
"preferredVariant".

-Dave

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

Reply via email to