예제 #1
0
 public Object getProviderData(String providerName, String methodName) throws Exception {
   String className = JpageController.get().getClassName(providerName);
   ObjectSnooper snooper = ObjectSnooper.snoop(className);
   Object c = snooper.object();
   if (c instanceof JpageProviderBase) {
     HashMap<String, Object> mapx = new HashMap<String, Object>();
     mapx.put("out", out);
     mapx.put("request", request);
     mapx.put("parameters", tagParameter);
     mapx.put("urlSetter", urlSetter);
     snooper.sett(mapx).set(this._get(request));
     Object result = null;
     try {
       result = snooper.trigger(methodName);
     } catch (Exception e) {
       e.printStackTrace();
     }
     snooper.trigger("close");
     return result;
   } else {
     throw new Exception("[JpageTag:Provider can not find.]");
   }
 }
예제 #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());
    }
  }