2010-08-16 112 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