<%@page import="com.edeal.frontline.helper.custom.RequesterHelper"%> <% /****************************************************************************** * Copyright (c) 2000-2005 e-Deal * * e-Deal S.A. * 55 rue Brillat Savarin * 75013 Paris * France * * T: +33 (0)1 53 80 80 30 * F: +33 (0)1 73 01 69 77 * http://www.e-deal.com * * La diffusion de ce code source sous quelque forme que ce soit sans * l'autorisation de E-DEAL est interdite. * * Vous êtes autorisés à modifier ce code source uniquement pour votre usage * propre et sous réserve que les mentions de copyright demeurent intactes. * * Ce code est fourni en l'état. Aucune garantie d'aucune sorte, explicite ou * implicite n'est donnée. En aucun cas E-DEAL ne pourra être tenu pour * responsable des dommages pouvant résulter de l'utilisation de ce code * source. ******************************************************************************/ %><%@page session="true"%> <%@ page import="com.edeal.frontline.navigation.*" %> <%@ page import="java.io.*" %> <%@ page import="java.sql.*" %> <%@ page import="java.util.*" %> <%@ page import="com.edeal.frontline.*" %> <%@page import="java.text.DecimalFormat"%> <%@page import="java.text.NumberFormat"%> <%@page import="com.edeal.frontline.controller.actions.ForwardAction"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %><% final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(getClass()); FlRequest flRequest = new FlRequest(request); FlContext context = flRequest.getContext(); DataDictionary dico = context.getDataDictionary(); String id; try { id = flRequest.getParameter("id"); } catch (Exception e) { id = ""; } ForwardAction.throwExceptionIfNotFromForward(flRequest); RequesterBean Requester; try { Requester = new RequesterBean(id, context); } catch (Exception e) { Requester = null; } String pFormat = flRequest.getParameter("format"); String pSepChoice = flRequest.getParameter("sepChoice"); String pDelChoice = flRequest.getParameter("delChoice"); String separator = flRequest.getParameter("sepValue"); String delimiter = flRequest.getParameter("delValue"); String pHeaders = flRequest.getParameter("headers"); if("SEMICOL".equalsIgnoreCase(pSepChoice)) { separator = ";"; } else if("TAB".equalsIgnoreCase(pSepChoice)) { separator = "\t"; } if("QUOTE".equalsIgnoreCase(pDelChoice)) { delimiter = "\""; } String strErrMsg = null; Vector vectParams = null; try { vectParams = Requester.getQueryParameters(); } catch (Throwable ex) { strErrMsg = ex.getMessage(); } Connection cx = null; Statement stmt = null; ResultSet rs = null; if(strErrMsg == null) { try { String[] args = null; if(vectParams != null && !vectParams.isEmpty()) { args = new String[vectParams.size()]; for(int i = 0; i < vectParams.size(); i++) { Hashtable row = (Hashtable)vectParams.elementAt(i); String[] values = Utils.translateParameterValues(context, request.getParameterValues( "Param" + (String)row.get("num"))); if(values == null) { args[i] = ""; } else if(values.length == 1) { args[i] = values[0]; } else { args[i] = Utils.implodeList(values, ";"); } } } RequesterHelper requesterHelper = new RequesterHelper(Requester); Hashtable hash = requesterHelper.execute(args); cx = (Connection)hash.get("Connection"); stmt = (Statement)hash.get("Statement"); rs = (ResultSet)hash.get("ResultSet"); } catch (Throwable ex) { strErrMsg = ex.getMessage(); } } try { if(strErrMsg == null) { try { if("viewhtml".equalsIgnoreCase(pFormat)) { response.setContentType("text/html"); %> <fl:getMessage code="L2025" alt="E-DEAL"/> CRM <% ResultSetMetaData meta = rs.getMetaData(); for(int i = 0; i < meta.getColumnCount(); i++) { String name = meta.getColumnLabel(i + 1); String disp = null; try { FieldBean fldBean = dico.getFieldByName(name); disp = fldBean.getFldDisplay(); } catch (Exception ex) { disp = name; } String borderLeft = ""; if (i == 0) borderLeft = "borderLineTree"; %> <% } %> <% boolean rowColor = false; while(rs.next()) { %> "> <% for (int i = 0; i < meta.getColumnCount(); i++) { Object value = rs.getObject(i + 1); String name = meta.getColumnLabel(i + 1); String borderLeft = ""; if (i == 0) borderLeft = "borderLineTree"; String align = "left"; int type = meta.getColumnType(i + 1); if (type == Types.FLOAT || type == Types.DOUBLE || type == Types.BIT || type == Types.INTEGER || type == Types.NUMERIC || type == Types.NUMERIC || type == Types.TINYINT || type == Types.REAL) { align ="right"; java.text.NumberFormat numFormat=NumberFormat.getNumberInstance(FlLocale.getInstance(session).getLocale()); numFormat.setMinimumFractionDigits(2); if (value!=null) { try { value=numFormat.format(value); } catch (Exception e) { logger.error("cannot format value "+value); } } else { value=""; } } %> <% } %> <% rowColor = !rowColor; } %>
<%= Utils.formatToWeb(disp, false) %>
<%= Utils.formatToWeb(session,value, false) %>
 
<% } else { String defOutEnc = null; try { defOutEnc = context.getContextParameter("DefaultOutputEncoding"); } catch (FrontlineException fex) { } response.setContentType("text/plain; filename=data.csv" + (defOutEnc != null ? "; charset=" + defOutEnc : "")); if("dlcsv".equalsIgnoreCase(pFormat)) { response.setHeader("Content-Disposition", "attachment; filename=data.csv"); } PrintWriter writer = response.getWriter(); RequesterBean.writeTo(context, session, writer, rs, separator, delimiter, "1".equals(pHeaders)); writer.flush(); writer.close(); } } catch (Throwable ex) { strErrMsg = ex.getMessage(); logger.error("STACK TRACE",ex); } } else { %> <fl:getMessage code="L2025" alt="E-DEAL"/> CRM <%= Utils.formatToWeb(strErrMsg, false) %> <% } } finally { try { rs.close(); } catch (Exception ex) {} try { stmt.close(); } catch (Exception ex) {} try { cx.close(); } catch (Exception ex) {} } %>