论坛首页 编程语言技术论坛

flex spring struts 结合 part1

浏览 1611 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2009-03-05   最后修改:2009-03-05
  一直对flex的工作机制理解不透,所以走了几天的弯路...学习啊学习,就是理论加实践的迭代.
  flex与spring结合,使用的是blazeds,它的价值在于在服务端构建了一个特殊的层...hmm,这么来解释它的作用,例如使用flex在eclipse下的插件新建一个mxml文件之后,会自动创建一个相同名字的html文件(还有在.actionScriptProperties下也会加入对应mxml文件的配置),在这个生成的html中(以后会拷进struts redirect的页面中)
AC_FL_RunContent(
			"src", "/flex/shipmentSummaryByRegion",
			"width", "100%",
			"height", "100%",
			"align", "middle",
			"id", "shipmentSummaryByRegion",

在服务器端,当解析到上面这段代码时,就会找到系统中的mxml文件,(这个时候blazeds还没有起作用),找到了mxml文件之后,flex会编译这个文件成为一个swf文件.
下面是mxml文件
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="initData();" applicationComplete="loadData()">
<mx:RemoteObject id="cs" destination="chartService">
	<mx:method name="viewSales" fault="Alert.show('error')" />
</mx:RemoteObject>

当flex解析这段mxml的时候,才是blazeds开始它的工作,调用spring实例好的对象
 public function initData():void {
            // Create the data provider for the DataGrid control.
            dgProvider = new ArrayCollection;
            
            viewName = Application.application.parameters.viewName;
			locale = Application.application.parameters.locale;
			strStartDate = Application.application.parameters.startDate;
			strEndDate = Application.application.parameters.endDate;
			startDate = new Date(new Number(strStartDate.substring(0, 4)), new Number(strStartDate.substring(5, 7)) - 1, new Number(strStartDate.substring(8, 10)));
			endDate = new Date(new Number(strEndDate.substring(0, 4)), new Number(strEndDate.substring(5, 7)) - 1, new Number(strEndDate.substring(8, 10)));
        	customerId = Application.application.parameters.customerId;
        	args = [startDate,endDate];
        	
        }

        public function loadData():void {
			// call serveric, load data
			var operation:AbstractOperation = cs.getOperation(viewName);
			operation.arguments=args;
			operation.addEventListener(ResultEvent.RESULT, loadData_back);
			operation.send();
        }

论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics