@SuppressWarnings("unchecked")
 public void execute(
     Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
     throws TemplateException, IOException {
   Website web = getWeb(env, params, websiteMng);
   Integer count = this.getCount(params);
   List<Object[]> oiList = orderItemMng.getOrderItem();
   List<Product> productList = new ArrayList<Product>();
   for (int i = 0; i < oiList.size(); i++) {
     Object[] o = oiList.get(i);
     productList.add(((OrderItem) o[0]).getProduct());
     if (i == count - 1) {
       break;
     }
   }
   Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>(params);
   paramWrap.put(OUT_LIST, ObjectWrapper.DEFAULT_WRAPPER.wrap(productList));
   Map<String, TemplateModel> origMap = DirectiveUtils.addParamsToVariable(env, paramWrap);
   if (isInvokeTpl(params)) {
     includeTpl(SHOP_SYS, TPL_NAME, web, params, env);
   } else {
     renderBody(env, loopVars, body);
   }
   DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap);
 }
Exemplo n.º 2
0
  @Override
  public void execute(Environment e, Map map, TemplateModel[] tms, TemplateDirectiveBody tdb)
      throws TemplateException, IOException {
    HttpServletRequest request = (HttpServletRequest) e.getCustomAttribute("request");
    URLQueryHandler urlSetter = (URLQueryHandler) e.getCustomAttribute("urlSetter");

    String controllerName = map.get("provider").toString();
    String actionName = map.get("method").toString();
    String dataname = map.get("name").toString();

    HashMap<String, Object> ct = (HashMap<String, Object>) map;

    try {
      String className = JpageController.get().getClassName(controllerName);
      if (className != null && className.length() > 0) {
        Object x = Class.forName(className).newInstance();
        HashMap<String, Object> mapx = new HashMap<String, Object>();
        mapx.put("out", e.getOut());
        mapx.put("request", request);
        mapx.put("parameters", ct);
        mapx.put("urlSetter", urlSetter);

        ObjectSnooper obj = ObjectSnooper.snoop(x);
        obj.sett(mapx);
        obj.set(this._get(request));
        Object result = obj.trigger(actionName);
        obj.triggerr("close");

        HashMap<String, Object> xxtmap = new HashMap<String, Object>();
        Object xtt = obj.gett("local");
        if (xtt != null) {
          xxtmap = (HashMap<String, Object>) xtt;
        }
        e.setVariable(dataname, ObjectWrapper.DEFAULT_WRAPPER.wrap(result));
        e.setVariable(dataname + "_local", ObjectWrapper.DEFAULT_WRAPPER.wrap(xxtmap));
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    if (tdb != null) {
      tdb.render(e.getOut());
    }
  }
Exemplo n.º 3
0
 /*    */ public void execute(
     Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
     /*    */ throws TemplateException, IOException
       /*    */ {
   /* 32 */ Site site = ViewTools.getSite(env);
   /* 33 */ Integer parentId = TagModelTools.getInt("parentId", params);
   /* 34 */ List industryList = new ArrayList();
   /* 35 */ if (parentId != null)
     /* 36 */ industryList = this.industryService.getIndustryChild(parentId);
   /*    */ else {
     /* 38 */ industryList = this.industryService.getIndustryList(null);
     /*    */ }
   /* 40 */ env.setVariable("list", ObjectWrapper.DEFAULT_WRAPPER.wrap(industryList));
   /* 41 */ body.render(env.getOut());
   /* 42 */ ViewTools.includePagination(site, params, env);
   /*    */ }
Exemplo n.º 4
0
  @Override
  public void execute(Environment e, Map map, TemplateModel[] tms, TemplateDirectiveBody tdb)
      throws TemplateException, IOException {
    tagParameter = map;
    request = (HttpServletRequest) e.getCustomAttribute("request");
    urlSetter = (URLQueryHandler) e.getCustomAttribute("urlSetter");
    out = e.getOut();

    HashMap<String, Object> mapx = this.doService();
    if (mapx != null) {
      for (Entry<String, Object> c : mapx.entrySet()) {
        e.setVariable(c.getKey(), ObjectWrapper.DEFAULT_WRAPPER.wrap(c.getValue()));
      }
    }

    if (tdb != null) {
      tdb.render(e.getOut());
    }
  }
Exemplo n.º 5
0
  @Override
  public void execute(
      Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
      throws TemplateException, IOException {

    String sql = params.get("sql").toString();
    System.out.println(loopVars.length);
    System.out.println(sql);
    Channel r = new Channel();
    r.setName("dsadsadasd");
    List a = new ArrayList();
    a.add(r);
    a.add(r);
    a.add(r);
    a.add(r);
    a.add(r);
    env.setVariable("userlist", ObjectWrapper.DEFAULT_WRAPPER.wrap(a));

    env.getOut().write("3424234234");
    body.render(env.getOut());
  }