Hi Jeromy,

Thanks for the response, that's really helpful.

Could you possibly provide a little bit more detail though as I
haven't been able to get this working yet.

This might seem like a stupid question, but in your code snippet below
where you have: // create the stream
Where does the output go? Should I use ModelDriven and assign it to the model?

Also how do I get a handle on the StreamResult object so I can specify
attributes programmatically? All the samples I have seen do so
declaratively.

Thanks again for the tips!

Mike


2008/6/20 Jeromy Evans <[EMAIL PROTECTED]>:
> Mike Watson wrote:
>>
>> Hi Folks,
>>
>> I'm trying to figure out how to return binary data from the REST plugin.
>>
>> I'd like to be able to return images that are generated on the fly by
>> a REST request but looking at ContentTypeHandlerManager, it assumes
>> that we'll only ever want to return a string and so passes a
>> StringWriter as the output for implementers of
>> ContentTypeHandler.fromObject.
>>
>>
>
> At first, don't create a custom ContentTypeHander.
> Just have your Controller declare a StreamResult. The default
> ContentTypeHandler will drop through for result processing by XWork (as per
> a ServletRedirectResult).
>
> eg. GET /namespace/image/21
>
> @Result("stream", type = StreamResult.class, value="image")
> class ImageController {
>  public InputStream getImage() {}
>
>  public String show() {
>    // create the stream
>    return "stream";    }
> }
>
> See StreamResult for how to set the Content-type and other properties.
>
> One that works, you could (potentially) register a ContentTypeHandler for
> each image content type you want to return (eg. register the jpg and png
> extensions).  The ContentTypeHandler should do nothing except return a
> result name for XWork that is mapped to a StreamResult.  The image retrieval
> would have to be performed in the Controller rather than the Handler though.
>  There is probably a bit of work to do in the plugin to handle binary
> results better though.
>
> Hope that gets you started.
> Jeromy Evans
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to