日志文章

2007年08月30日 17:11:06

flex.开发.框架

java类,控制层,类似Action(但依赖于ASObject) -------------------------------------------------- import flex.messaging.io.amf.ASObject;

public ASObject search_tree(ASObject aso) {
    ASObject rtt = new ASObject();
// Invoke.getForm
String userid = (String) aso.get("userid");
rtt.put("arrlist", xml);
rtt.put("asoobj", aso);
return rtt;
} ---------------------------------------------------反射:类似struts的总控:serverletAction。

public Object execute(ArrayCollection arrc) {       ASObject vo = null;
    try {
        vo = (ASObject) Invoke.getASObject(arrc);
    }
    catch (IllegalAccessException ex) {
    }
    catch (InstantiationException ex) {
    }
    try {
        return executeASO(vo);
    }
    catch (Exception ex1) {
        return ex1.getMessage();
    }
  }

  public Object executeASO(ASObject vo) throws Exception{
    Class cls = getClass();
    /**
      * @todo get the strMethodName
      */
    String functionname = (String)vo.get("functionname");
    vo.remove("functionname");
    Method [] methods = cls.getMethods();
    Object ret = null;
    for (int i=0;i<methods.length;i++) {
        if (methods.getName().equals(functionname)) {
          //Class[] clss = methods.getParameterTypes();
          Object[] arglist = new Object[1];
          arglist[0] = vo;
          ret = methods.invoke(cls.newInstance(),arglist);
        }
    }
    return ret;
  }

-----------------------------------------
mxml页面:
自己封装:
public function init():void
{
  //searchshowed=false;
  var formo:ArrayCollection=new ArrayCollection();
  formo=submit.additem(formo, "functionname", "search_list_all");
  view_list.execute(formo);
}


返回:
  datas1_user=ArrayUtil.toArray(result.arrlist_user);
  userslist.dataProvider= datas1_user;
 



Tags: JAVA  

类别: flex/AJAX |  评论(0) |  浏览(785) |  收藏
发表评论
看不清楚,换一张