I wish I had more time to explain; I don't right now.  Here's a chunk of
code from our project that might help you along.

It's a tapestry page that loads a document (a "background material") from a
DAO and then displays it to the user.

public class Background {

@Inject
private BackgroundMaterialDao dao;

@Inject
private RequestGlobals requestGlobals;

 private String backgroundId;

public void beginRender(MarkupWriter writer) {
 requestGlobals.getHTTPServletResponse().setStatus(
HttpServletResponse.SC_NOT_FOUND);
 writer.element("p");
writer.write("No pre-read material found with id " + backgroundId);
 writer.end();
}

public Object onActivate(String backgroundId) throws SQLException,
MalformedURLException {
 BackgroundMaterial background = dao.get(backgroundId);
if (background != null) {
 if (background instanceof AssetBackgroundMaterial) {
return streamAsset((AssetBackgroundMaterial) background);
 } else if (background instanceof UrlBackgroundMaterial) {
return redirectTo((UrlBackgroundMaterial) background);
 }
}
return notFound(backgroundId);
 }

private URL redirectTo(UrlBackgroundMaterial background) throws
MalformedURLException {
 return new URL(background.getUrl());
}

private StreamResponse streamAsset(AssetBackgroundMaterial background)
throws SQLException {
 return new SimpleStreamResponse(background.getContentType(), background
.getMaterial().getBinaryStream());
 }

private Object notFound(String backgroundId) {
this.backgroundId = backgroundId;
 return null;
}
}

On 17 July 2012 16:33, gonzalomp87 <gonzalom...@gmail.com> wrote:

> Sorry, I dont understand.
>
> I have a BufferedImage type variable in my .tml can not show, but I can
> convert into a variable of type InputStream.
> Suppose I call that variable myImage
>
> I was looking at that page but do not quite understand. I'm supposed to use
> the last paragraph "Creating a page for streaming files" but I have some
> questions.
>
> 1. function getuploadfile should  return  Link instead of a string?
> 2. I do not understand that I would have to put in the variable "final
> String uuid" or in this call ".... getUploadedFile (" SOMEUUID ")"
> 3. At these points would have to enter some code? return new StreamResponse
> () {... }
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/BufferedImage-in-Tapestry-tp5714465p5714522.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

Reply via email to