2010-08-16 114 views
2

我的Tapestry5应用程序每天都会使用jFreeChart动态生成图像。 我的问题是,我不知道如何显示。Tapestry动态生成图像

我试图将它们保存到webapp文件夹,但它似乎不可能,里面没有创建文件。

我试过了StreamResponse的解决方案,但没有结果。

另一个是关于IEngineService,但它似乎只适用于T4。

所以,我将不胜感激一些帮助。 谢谢。

回答

3

好吧,我找到问题的地方,这里的解决方案,为其他类,请参阅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[]{}); 
} 
+0

重新格式化代码& link;如果不正确请恢复。 – trashgod 2010-08-16 15:08:38