views:

64

answers:

1

Hi all.

My Tapestry5 application generate dynamically images with jFreeChart every day. My problem is that i don't know how to show.

I have tried to save them into the webapp folder, but it seems impossible, no file is created inside.

I have tried a solution with StreamResponse without result.

Another one is about IEngineService but it seems to be only available for T4.

So, i would appreciate some help. Thanks.

+2  A: 

Ok i find where was the problem, here the solution, for the other class, please see Tapestry5: How To Stream An Existing Binary File.

public StreamResponse onImage() {
    StreamResponse result = null;
    if (graphic != null && graphic.getImage() != null) {
        try {
            InputStream input = new FileInputStream(graphic.getImage());
            result = new PngInline(input, "test");
        } catch (FileNotFoundException e) {
            logger.error("Loading graphic image", e);
        }
    }
    return result;
}
@Inject
private ComponentResources resources;

public Link getLink() {
    return resources.createEventLink("image", new Object[]{});
}
alex
Reformatted code please revert if incorrect.
trashgod