On Fri, 2002-02-01 at 08:45, Gareth Coltman wrote: > > Ok. Basic problem is what to do if I need to return content to the user > (such as a generated image) as a result of my action. > > At the moment the target valve always attempts to set the content type and > then render the response. If I have already opened the response writer in my > action, the target valve will throw an exception when it tries to set the > content type (this is part of the J2EE spec I believe). > > One work around is the echo template described by James. This is a bit of a > nasty hack IMHO.
Agreed. Also, for binary data it certainly will not work since DefaultTargetValve buffers the template merge result in a string. > Second idea is to disable to the target completely, so no rendering would > take place. This could be achieved by setting the target to null and then > having the valve check handle this gracefully. As Jason has said this > doesn't really fit the design, but does give lots of flexibility about how > the response is generated. Yup, and I agree with Jason that _doing_ this is a bad idea. Actions and Modules should build contexts, and templates render them. However, I believe having the valves gracefully handle a null target (treating it as a noop) is a good thing since it lets us cope with this even though in most cases it is a bad design choice at the application level. > Third idea is to generate the data in the action. Store it somewhere in the > rundata, (perhaps responseBody object) and then retrieve the data at the > point of rendering within the target valve. This I really dislike. RunData already has more crap in it than it should. > This is going to be a common problem as far as I can see. In our case we > want to return a PDF (actually an FDF with an internal PDF hyperlink) as the > result of a form fill. So I need to use the action to parse the form data > and generate the FDF. When I actually write it onto the output stream is > obviously the point here. jt -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
