我需要顯示一個Grails頁面上四個圖表與位置11,12,21和22的網格佈局每個圖表的建立與類似代碼:如何使用多一個的OutputStream
<img src="${createLink(controller:'paretoChart', action:'buildParetoChart11')}"/>
圖表建築物操作的代碼是:
def buildParetoChart11 = {
def PlotService p11 = PlotService.getInstance()
def poList = paretoChartService.getParetoidPO()
def listCounter = 0
def idPO = poList[listCounter]
idPO.toString()
def String idPOvalue = idPO
def out = response.outputStream
out = p11.paretoPlot(out, idPOvalue)
response.setContentType("image/jpg")
session["idPOList11"] = poList
}
Java的p11.paretoPlot(出,idPOvalue)返回的OutputStream裏面圖表的BufferedImage,但它僅適用於一個圖表。其他三個圖表根據每次所有傾倒操作的順序而有所不同。
PlotService是我寫的,是的。在這個實現中,我將OutputStream從response.outputStream和String idPOvalue傳遞給了Java方法。 plotPareto的實現如下:
public OutputStream paretoPlot(OutputStream out, String po) throws IOException {
chart = buildParetoChart(po);// here the chart is actually built
bufferedImage = chart.createBufferedImage(350, 275);
ChartUtilities.writeBufferedImageAsJPEG(out, bufferedImage);
}
那麼,有沒有辦法確保在啓動下一個動作之前完成一個動作?
在此先感謝!
你也可能想嘗試刷新輸出流。 – hvgotcodes 2010-12-07 16:48:40