<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Oracle神諭

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      284 隨筆 :: 9 文章 :: 106 評論 :: 0 Trackbacks

    Intro

    I am rendering a chart to the output stream. Instead of streaming it directly to the response.out, I create a ChartResult , and let webwork do the chaining for me.

    I generate the chart in one class, and I render it out in another class, efftectively decoupling the view from the actions. You can easily render it out to file or some view other than a web response.out if you wish.

    Configuration
    xwork.xml -result-types definitions
    <result-types>
    ?? <result-type name="chart" class="myapp.webwork.extensions.chartResult"/>
    </result-types>
    xwork.xml -action definitions
    <action name="viewModerationChart" class="myapp.webwork.actions.ViewModerationChartAction">
    ?? <result name="success" type="chart">
    ????? <param name="width">400</param>
    ????? <param name="height">300</param>
    ?? </result>
    </action>

    Source Codes
    My result class search for a "chart" in the ValueStack and renders it out...

    public class ChartResult implements? Result{
    ?? private int width;
    ?? private int height;
    ?? public void execute(ActionInvocation invocation)throws Exception{
    ?????? JFreeChart chart = (JFreeChart)invocation.getStack().findValue("chart");
    ?????? HttpServeletResponse response = ServeletActionContext.getResponse();
    ?????? OutputStream os = response.getOutputStream();
    ?????? ChartUtilities.writeChartAsPNG(os,chart,width,height);
    ?????? os.flush();
    ?? }
    ?????
    ?? public void setHeight(int height){
    ???? this.height=height;
    ?? }
    ??
    ?? public void setWidth(int width){
    ???? this.width=width;
    ?? }
    }

    public class ViewModerationChartAction extends ActionSupport{
    ?? private JFreeChart chart;
    ??
    ?? public String execute() throws Exception{
    ????? //chart creation logic ...
    ????? XYSeries dataSeries = new XYSeries(new Integer(1));
    ????? for(int i=0;i<=100;i++){
    ???????? dataSeries.add(i,RandomUtils.nextInt());
    ????? }
    ?????
    ????? XYSeriesCollection xyDataset = new XYSeriesCollection(dataSeries);
    ????? ValueAxis xAxis = new NumberAxis("Raw Marks");
    ????? ValueAxis yAxis = new NumberXxis("Moderated Marks");
    ?????
    ????? chart = new JFreeChart(
    ????????????????????? "Moderation Function",
    ????????????????????? JFreeChart.DEFAULT_TITLE_FONT,
    ????????????????????? new XYPlot(
    ??????????????????????????? xyDataset,
    ??????????????????????????? xAxis,
    ??????????????????????????? yXis,
    ??????????????????????????? new
    ?????????? StandardXYItemRenderer(StandardXYItemRender.LINES),
    ??????????????????????????? false????????????????
    ????????????????????? );
    ????????????????????? ...
    ????? )
    ?? }
    ??
    ?? public JFreeChart getChart(){
    ????? return chart;
    ?? }
    }

    posted on 2006-04-11 11:55 java世界暢談 閱讀(315) 評論(0)  編輯  收藏 所屬分類: WEBWORK

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲精品制服丝袜四区| 美女内射无套日韩免费播放| 国产免费久久精品99re丫y| 亚洲狠狠ady亚洲精品大秀| 国产精品偷伦视频观看免费| 亚洲真人无码永久在线| 国产福利在线观看永久免费| 亚洲裸男gv网站| 日批视频网址免费观看| 亚洲Av无码精品色午夜| 十八禁无码免费网站| 亚洲精品视频在线观看免费| 亚洲免费观看网站| 最新国产精品亚洲| 又粗又大又硬又爽的免费视频| 特级aaaaaaaaa毛片免费视频| 亚洲国产精品狼友中文久久久| 国产男女爽爽爽免费视频 | aⅴ免费在线观看| 波多野结衣亚洲一级| 日本免费v片一二三区| 有色视频在线观看免费高清在线直播| 亚洲一区二区三区在线播放| 国产在线观a免费观看| 亚洲精彩视频在线观看| 精品剧情v国产在免费线观看| 色费女人18女人毛片免费视频| 亚洲中文久久精品无码| 51在线视频免费观看视频| 亚洲欧美国产精品专区久久| 亚洲 国产 图片| 一级毛片免费观看| 亚洲日本成本人观看| 亚洲无码黄色网址| 免费观看激色视频网站bd | 亚洲欧美一区二区三区日产| 又粗又黄又猛又爽大片免费| 国产精品区免费视频| 亚洲av无码成人精品区一本二本| 区久久AAA片69亚洲| 免费无码AV片在线观看软件|