Exactly what I was looking for...
returning null was a good practice in Struts 1 when there were no
resulttypes, dunno if there's not a better way to do it in S2... One thing
one could do is write a null-return method for each kind of byte-result
which can be placed in the ActionSupport class so that all the actions can
pass a byte-array and/or resulttype to this supporter-method.
On the other hand, this is pretty much what the struts 2 reults do... but
the trouble here is passing parameters.
Theoretically speaking(havent tried it yet) I would think that a <Striing,
byte[]>-Map in the actionsupport class could be very handy. This way you'd
just have to pass a String-key to the result(hardcoded <param> in the
struts.xml), the result gets the actioncontext, gets the Map and eventually
the byte[]. 



Sarr, Nathan wrote:
> 
> Excellent,
> 
>    Thanks for the help musachy - much appreciated.
> 
> -Nate
> 
> -----Original Message-----
> From: Musachy Barroso [mailto:[EMAIL PROTECTED] 
> Sent: Friday, March 30, 2007 10:27 AM
> To: Struts Users Mailing List
> Subject: Re: Struts 2 - Action writing to response output stream
> 
> You can just write to the outputstream, and return null from execute,
> and
> you won't need a NoOp result. I also wrote my own NoOp result when i
> started
> using S2 ;). Maybe this should be on the FAQs.
> 
> musachy
> 
> On 3/30/07, Sarr, Nathan <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>> Hello,
>>
>>
>>
>>    We are using some actions to write directly to the stream for some
>> ajax based functionality.  To do this I wrote a
>>
>> NoOp result type that does nothing.
>>
>>
>>
>> [code]
>>
>> public class NoOp extends StrutsResultSupport {
>>
>>
>>
>>
>>
>>     public NoOp() {
>>
>>         super();
>>
>>     }
>>
>>
>>
>>     protected void doExecute(String finalLocation, ActionInvocation
>> invocation) throws Exception {
>>
>>         //no op
>>
>>     }
>>
>> }
>>
>>
>>
>> [/code]
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> This allows the action to write the content using:
>>
>>
>>
>>     response.getOutputStream().write(contents)
>>
>>
>>
>>
>>
>> I am looking for best practices.  Is this an acceptable way to do this
>> or is there a better way to allow an action to return content that I
>> would like placed as only part of the page?
>>
>>
>>
>> Thanks for the help,
>>
>> Nathan Sarr
>>
>>
>>
>>
> 
> 
> -- 
> "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Struts-2---Action-writing-to-response-output-stream-tf3492429.html#a9766683
Sent from the Struts - User mailing list archive at Nabble.com.


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

Reply via email to