예제 #1
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());
    }
  }
예제 #2
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());
    }
  }