日期:2014-05-20 浏览次数:21023 次
public final class ViewProcessOrderAction extends Action{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
DynaActionForm searchForm = (DynaActionForm) form;
String keyword = (String)searchForm.get("keyword");
Integer pageId = (Integer)searchForm.get("pageId");
HttpSession session = request.getSession(true);
List processOrdertList=new DBOperate().getMatchProcessOrders(keyword);
if (processOrdertList.size()==0){
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_MESSAGE,
new ActionError("errors.noMatch"));
if (!errors.isEmpty()) {
saveErrors(request, errors);
}
return mapping.findForward("toWrong");
}
else{
response.setContentType("text/html;charset=GBK");
PrintWriter out = response.getWriter();
DefaultPieDataset data = new DefaultPieDataset();
for(int i=0;i<processOrdertList.size();i++){
Order order = (Order)processOrdertList.get(i);
data.setValue(order.getTime(), order.getPrice());
}
PiePlot3D plot = new PiePlot3D(data);//3D饼图
plot.setURLGenerator(new StandardPieURLGenerator("barview.jsp"));//设定链接
JFreeChart chart = new JFreeChart("",JFreeChart.DEFAULT_TITLE_FONT, plot, true);
chart.setBackgroundPaint(java.awt.Color.white);//可选,设置图片背景色
chart.setTitle("订单调查表");//可选,设置图片标题
plot.setToolTipGenerator(new StandardPieToolTipGenerator());
StandardEntityCollection sec = new StandardEntityCollection();
ChartRenderingInfo info = new ChartRenderingInfo(sec);
PrintWriter w = new PrintWriter(out);//输出MAP信息
//500是图片长度,300是图片高度
ChartUtilities.writeImageMap(w, "map0", info, false);
String filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, info, session);
String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;
request.setAttribute("filename", filename);
request.setAttribute("graphURL", graphURL);
ViewList viewList=new ViewList();
viewList.display (processOrdertList,session,pageId,keyword) ;
return (mapping.findForward("toListProcessOrder"));
}
}
}
<P ALIGN="CENTER">
<%Object graphURL=request.getAttribute("graphURL"); %>
<%Object filename=request.getAttribute("filename"); %>
<img src="<%= graphURL.toString() %>" width=500 height=300 border=0 usemap="#map0">
<%= graphURL.toString()%>
</P>