protected boolean preTemplateProcess(Template template, TemplateModel model) throws IOException {
    Object attrContentType = template.getCustomAttribute("content_type");

    if (attrContentType != null) {
      ServletActionContext.getResponse().setContentType(attrContentType.toString());
    } else {
      String contentType = getContentType();

      if (contentType == null) {
        contentType = "text/html";
      }

      // webwork:
      //            String encoding = template.getEncoding();

      String encoding = template.getOutputEncoding();

      if (encoding != null) {
        contentType = contentType + "; charset=" + encoding;
      }

      ServletActionContext.getResponse().setContentType(contentType);
    }

    return true;
  }
コード例 #2
0
ファイル: TousuAction.java プロジェクト: zgyq/kzpw
  /**
   * 添加消息反馈信息
   *
   * @return 赵晓晓
   */
  public void getreturnmessage() {

    try {
      // 获得投诉内容
      tousu.setComment(content);
      // 获得添加时间
      tousu.setCreatetime(new Timestamp(System.currentTimeMillis()));
      // 获得登录人编号从session中获得
      HttpSession session = ServletActionContext.getRequest().getSession();
      Customeruser customer = new Customeruser();
      customer = (Customeruser) session.getAttribute("loginuser");
      Long id = customer.getId();
      tousu.setUsername(id.toString());
      // 获得代理编号
      Customeragent customeragent = new Customeragent();
      customeragent = (Customeragent) session.getAttribute("loginagent");
      Long Agentid = customeragent.getId();
      tousu.setDainame(Agentid.toString());
      Server.getInstance().getMemberService().createTousu(tousu);
      System.out.println("添加投诉信息成功!");
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      System.out.println("添加失败!");
    }
  }
コード例 #3
0
 public void execute(ActionInvocation invocation) throws Exception {
   LatestVersionSource source = (LatestVersionSource) invocation.getAction();
   double latestVersion = source.getLatestVersion();
   HttpServletResponse response = ServletActionContext.getResponse();
   response.setContentType("text/xml");
   OutputStream out = response.getOutputStream();
   out.write(String.valueOf(latestVersion).getBytes());
   out.close();
 }
コード例 #4
0
  @Override
  protected final String doExecute() {

    configFilePath =
        ServletActionContext.getServletContext()
            .getInitParameter("configFilePath")
            .replaceAll("\\\\", "/");

    String result = ERROR;
    result = doExecuteAdmin();

    return result;
  }
コード例 #5
0
ファイル: IntegralAction.java プロジェクト: zgyq/kzpw
  /** 编辑积分管理 */
  public String edit() throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    String where = " where 1=1 ";
    List list =
        Server.getInstance()
            .getMemberService()
            .findAllIntegralForPageinfo(where, " ORDER BY ID ", pageinfo);
    pageinfo = (PageInfo) list.remove(0);
    listIntegral = list;
    if (pageinfo.getTotalrow() > 0 && listIntegral.size() == 0) {
      pageinfo.setPagenum(1);
      list =
          Server.getInstance()
              .getMemberService()
              .findAllIntegralForPageinfo(where, " ORDER BY ID ", pageinfo);
      pageinfo = (PageInfo) list.remove(0);
      listIntegral = list;
    }

    int register = Integer.valueOf(converNull(request.getParameter("register5"), "0"));
    int punish = Integer.valueOf(converNull(request.getParameter("punish5"), "0"));
    int backorder = Integer.valueOf(converNull(request.getParameter("backorder5"), "0"));
    int weborder = Integer.valueOf(converNull(request.getParameter("weborder5"), "0"));

    for (Integral integral : listIntegral) {
      long type = integral.getAgenttype();
      System.out.println(request.getParameter("aircoeft" + type));
      float aircoeft = Float.valueOf(converNull(request.getParameter("aircoeft" + type), "0"));
      // float hotelcoeft=Float.valueOf(converNull(request.getParameter("hotelcoeft"+type),"0"));
      // float travelcoeft=Float.valueOf(converNull(request.getParameter("travelcoeft"+type),"0"));
      // float
      // carrentalcoeft=Float.valueOf(converNull(request.getParameter("carrentalcoeft"+type),"0"));
      // float
      // rechargecoeft=Float.valueOf(converNull(request.getParameter("rechargecoeft"+type),"0"));

      integral.setAircoeft(aircoeft);
      // integral.setHotelcoeft(hotelcoeft);
      // integral.setTravelcoeft(travelcoeft);
      // integral.setCarrentalcoeft(carrentalcoeft);
      // integral.setRechargecoeft(rechargecoeft);
      integral.setRegisterscore(register);
      integral.setPunishscore(punish);
      integral.setBackorderscore(backorder);
      integral.setWeborderscore(weborder);
      Server.getInstance().getMemberService().updateIntegralIgnoreNull(integral);
    }
    return this.execute();
  }
コード例 #6
0
ファイル: XmlResult.java プロジェクト: mscheidnes/wforms
 public void execute(ActionInvocation invocation) throws Exception {
   XmlProducer producer = (XmlProducer) invocation.getAction();
   XmlRenderable xmlRenderable = producer.getXmlRenderable();
   Element element = xmlRenderable.asXml();
   Document document = new Document(element);
   String xmlString = XmlUtility.asString(document);
   HttpServletResponse response = ServletActionContext.getResponse();
   response.setContentType("text/xml");
   try {
     OutputStream out = response.getOutputStream();
     BufferedOutputStream bufferedOut = new BufferedOutputStream(out);
     bufferedOut.write(xmlString.getBytes());
     bufferedOut.close();
   } catch (IOException e) {
     logger.warning("Failed to write result XML response to browser: " + e.toString());
   }
 }
コード例 #7
0
ファイル: SelectPageAction.java プロジェクト: jielen/gmap52
  public String doExecute() {
    String cond = condition;
    String searCond = this.searchCond;
    if (!type.equalsIgnoreCase(ADVANCED_SEARCH) && !type.equalsIgnoreCase(ADVANCED_PAGINATION)) {
      if (searCond != null && !searCond.equals("")) {
        if (cond.equals("")) {
          cond = searCond;
        } else {
          cond += ";" + searCond;
        }
      }
    }

    Map paramsMap = new HashMap();
    DBHelper.parseParamsSimpleForSql(cond, paramsMap);

    if (userid == null) userid = (String) paramsMap.get("userid");

    // System.out.println("######################################################");
    // System.out.println("userId:" + userid);
    String userNumLimCondition = "";

    if (masterTableName != null
        && masterTableName.length() > 0
        && masterCompoName != null
        && masterCompoName.length() > 0) {
      if (masterTableName.equals(MetaManager.getCompoMeta(masterCompoName).getMasterTable())) {
        String realFieldName = request.getParameter("realFieldName");
        List realFieldNameList = java.util.Arrays.asList(realFieldName.split(","));

        TableMeta tableMeta = MetaManager.getTableMeta(masterTableName);
        if (masterSelectField != null && masterSelectField.length() > 0) {
          String[] sTemp = masterSelectField.split(",");
          for (int i = 0; i < sTemp.length; i++) {
            Field field = tableMeta.getField(sTemp[i]);
            if (field == null
                || !realFieldNameList.contains(
                    field.getRefField())) { // 主表选择字段对应的外部实体字段与外部实体的实际选择字段比较
              continue;
            }
            if (!field.isSave()) { // 非保存字段,查询此外部实体对应的其他保存字段的数值权限
              List fields = ((Foreign) tableMeta.getForeign(field.getRefName())).getFields();
              for (int j = 0; j < fields.size(); j++) {
                Field tField = (Field) fields.get(i);
                String fieldName = tField.getName();
                if (sTemp[i].equals(fieldName) || !tField.isSave()) continue;

                String refFieldName = tField.getRefField();

                String iCond = getListUserLimCondition(refFieldName, fieldName);
                if (iCond != null && iCond.length() > 0) {
                  if (userNumLimCondition.length() > 0) {
                    userNumLimCondition += " and " + iCond;
                  } else {
                    userNumLimCondition = iCond;
                  }
                }
              }
            } else { // 保存字段,添加数值权限
              String iCond = getListUserLimCondition(field.getRefField(), sTemp[i]);
              if (iCond != null && iCond.length() > 0) {
                if (userNumLimCondition.length() > 0) {
                  userNumLimCondition += " and " + iCond;
                } else {
                  userNumLimCondition = iCond;
                }
              }
            }
          }
        }
      }
    }

    String quotUserNumLim =
        RightUtil.getUserNumLimCondition(
            ServletActionContext.getRequest(), userid, "fquote", componame, null, null);
    // System.out.println("svCoCode:" + SessionUtils.getAttribute(request, "svCoCode"));
    // System.out.println("quotUserNumLim:" + quotUserNumLim);
    if (userNumLimCondition != null && userNumLimCondition.length() > 0) {
      if (quotUserNumLim != null && quotUserNumLim.length() > 0) {
        userNumLimCondition += " and ";
        userNumLimCondition += quotUserNumLim;
      }
    } else {
      if (quotUserNumLim != null && quotUserNumLim.length() > 0) {
        userNumLimCondition = quotUserNumLim;
      }
    }

    if (type.equalsIgnoreCase(ADVANCED_SEARCH)
        || type.equalsIgnoreCase(ADVANCED_PAGINATION)) { // 搜索类型为高级搜索时,将搜索条件附加上;
      if (userNumLimCondition != null && userNumLimCondition.length() > 0)
        userNumLimCondition += " and ";
      searCond = searCond.replaceAll(";", " and "); // 将;替换为and
      userNumLimCondition += searCond;
    }
    provider.setUserNumLimCondition(userNumLimCondition);

    // System.out.println("userNumLimCondition:" + userNumLimCondition);

    int pageIndex = Pub.calcPageIndex(currentpage, direction, pagesize, totalcount);
    if (pageIndex <= 0) pageIndex = 1;
    int rowmin = (pageIndex - 1) * pagesize + 1;
    int rowmax = pageIndex * pagesize;

    Datum datum = null;
    if (isFromSql && (sqlid == null || sqlid.length() == 0)) { // sqlid为空直接查询表
      DBSupport support = (DBSupport) ApplusContext.getBean("dbSupport");
      List newParams = new ArrayList();

      String matchCond = (String) paramsMap.get("matchCond"); // 仅添加搜索框的条件
      paramsMap = new HashMap();

      if (matchCond != null) {
        List saveFieldNames = MetaManager.getTableMeta(tablename).getSaveFieldNames();
        for (int i = 0; i < saveFieldNames.size(); i++)
          paramsMap.put(saveFieldNames.get(i), matchCond);
      }

      String sql = support.wrapSqlByTableName(tablename, paramsMap, newParams);

      if (matchCond != null) {
        sql = sql.replaceAll("[=]", "like");
        sql = sql.replaceAll("and", "or");
      }

      StringBuffer orderStr = new StringBuffer(""); // 排序和年度
      TableMeta tableMeta = MetaManager.getTableMeta(tablename);
      List keyFieldNames = tableMeta.getKeyFieldNames();
      if (keyFieldNames != null) {
        orderStr.append(" order by ");
        for (int i = 0; i < keyFieldNames.size(); i++) {
          orderStr.append(keyFieldNames.get(i) + ",");
          if ("ND".equalsIgnoreCase((String) keyFieldNames.get(i))) {
            sql =
                support.wrapSqlByCondtion(sql, "ND=" + SessionUtils.getAttribute(request, "svNd"));
          }
        }
      }

      if (orderStr.toString().endsWith(",")) {
        sql += orderStr.substring(0, orderStr.length() - 1);
      }

      if (totalcount < 0)
        totalcount = provider.getTotalCount(support.wrapSqlForCount(sql), newParams);
      if (totalcount <= 0) { // 没有数据
        return SUCCESS;
      }

      // System.out.println("sql:" + sql);
      paramsMap.put("rownum", rowmax + "");
      paramsMap.put("rn", rowmin + "");
      newParams.add(rowmax + "");
      newParams.add(rowmin + "");
      if (userNumLimCondition != null && userNumLimCondition.length() > 0) {
        sql = support.wrapSqlByCondtion(sql, userNumLimCondition);
      }
      sql = support.wrapPaginationSql(sql);
      datum =
          provider.getPaginationData(
              pageIndex, totalcount, pagesize, tablename, sql, newParams, false);
    } else {
      if (totalcount < 0) { // 取总条数
        totalcount = provider.getTotalCount(sqlid, paramsMap);
      }
      if (totalcount <= 0) { // 没有数据
        return SUCCESS;
      }

      paramsMap.put("rownum", rowmax + "");
      paramsMap.put("rn", rowmin + "");

      // 取分页数据
      datum =
          provider.getPaginationData(
              pageIndex, totalcount, pagesize, tablename, sqlid, paramsMap, false);
    }

    int totalPage = totalcount % pagesize == 0 ? totalcount / pagesize : totalcount / pagesize + 1;
    StringBuffer sb = new StringBuffer();
    sb.append("<?xml version=\"1.0\" encoding=\"GBK\"?>\n");
    List data = datum.getData();
    if (data != null) {
      sb.append(
          "<delta totalCount=\""
              + totalcount
              + "\" totalPage=\""
              + totalPage
              + "\" currentPage=\""
              + pageIndex
              + "\" pageSize=\""
              + pagesize
              + "\">\n");
      for (int i = 0; i < data.size(); i++) {
        sb.append("<entity name=\"null\">\n");
        Map map = (Map) data.get(i);
        Set entrySet = map.entrySet();
        Iterator itera = entrySet.iterator();
        while (itera.hasNext()) {
          Entry entry = (Entry) itera.next();
          sb.append("<field name=\"");
          sb.append(entry.getKey());
          sb.append("\" value=\"");
          sb.append(
              entry.getValue() == null
                  ? ""
                  : XMLTools.getValidStringForXML(entry.getValue().toString()));
          sb.append("\"/>\n");
        }
        sb.append("</entity>\n");
      }
      sb.append("</delta>\n");
    }

    // System.out.println("######################################################");

    resultstring = sb.toString();
    return SUCCESS;
  }