<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世界暢談 閱讀(314) 評論(0)  編輯  收藏 所屬分類: WEBWORK

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


    網站導航:
     
    主站蜘蛛池模板: 午夜免费福利片观看| 国产成人精品免费大全| 69av免费观看| 亚洲综合在线观看视频| 成年女人A毛片免费视频| 亚洲线精品一区二区三区影音先锋| 国产成人精品免费视频大全| 国产亚洲AV手机在线观看 | 中文字幕人成人乱码亚洲电影| 国产精品久久久久久亚洲影视| 日韩电影免费在线| 亚洲精品日韩一区二区小说| 波多野结衣久久高清免费| 国产成人高清亚洲一区91| 亚洲人成无码网WWW| 中文字幕av无码不卡免费| 亚洲AV无码一区二区乱孑伦AS | 亚洲午夜精品久久久久久浪潮 | 亚洲人成网77777色在线播放| 人与动性xxxxx免费| 久久久久久久尹人综合网亚洲| 久久精品成人免费看| 亚洲国产精品白丝在线观看| 成人免费无码大片A毛片抽搐 | 久久不见久久见中文字幕免费| 亚洲精品无码专区| heyzo亚洲精品日韩| 最新国产乱人伦偷精品免费网站| 亚洲图片一区二区| 在线观看人成网站深夜免费| 日本特黄特色AAA大片免费| 亚洲VA成无码人在线观看天堂| 久草视频在线免费| 男女猛烈无遮掩视频免费软件| 亚洲国产精华液网站w| 无码一区二区三区AV免费| 国产亚洲精品91| 国产亚洲婷婷香蕉久久精品 | 亚洲欧美aⅴ在线资源| 国产一精品一aⅴ一免费| a级在线观看免费|