{"inframe":false,"title":"引用公共模块","hidden":false,"roles":{"demo":1,"dev":1},"children":[{"configs":{"importModules":"[\"m?xwl=examples/basic/import-module/common-module\"]","description":"如何导入：\n多选导入的子模块并拖动到module的importModules属性。\n\n用途：\n使用该属性导入的模块为闭包式引用，即主模块无法访问导入模块的成员（serverScript的app对象除外）。\n此方法主要是执行一些初始化或定义一些公共serverScript方法。\n具体见sub-module1, sub-module2中的设置。","serverScript":"//注：serverScript在importModules之后运行，initScript在importModules之前运行\nrequest.setAttribute('addedVal', Integer.toString(app.add(3, 5))); //app.add方法在子模块import-module的serverScript内定义","itemId":"module"},"events":{"initialize":"var minusVal = app.minus(7, 5); //app.minus方法在子模块import-module的initialize内定义\nWb.info('通过服务器端公共方法计算得到：{#addedVal#}，通过客户端公共方法计算得到：' + minusVal);"},"children":[{"configs":{"file":"m?xwl=examples/basic/import-module/control-module","itemId":"xwl1"},"children":[],"expanded":false,"type":"xwl"},{"configs":{"layout":"border","itemId":"viewport1"},"children":[{"configs":{"region":"north","itemId":"toolbar1"},"children":[{"configs":{"text":"动态加载非单例窗口","itemId":"dynamicInvoke"},"events":{"click":"Wb.run({\n  url: 'm?xwl=examples/basic/import-module/control-module',\n  success: function(app) {\n    var win = new Ext.window.Window(app._window1); //_window1为配置对象，window1为实例\n    win.show();\n  }\n});"},"children":[],"expanded":false,"type":"item"},{"configs":{"text":"动态加载单例窗口","itemId":"dynamicInvokeSingle"},"events":{"click":"if (!app.dynamicInvokedWin) {\n  var parentApp = app;\n  Wb.run({\n    url: 'm?xwl=examples/basic/import-module/dynamic-invoke',\n    //设置contextOwner可在contextOwner销毁时销毁被调用的资源（窗口）。如果无容器可使用contextOwner(contextOwner在单独打开页面时为null)\n    contextOwner: app.viewport1,\n    success: function(app) {\n      var win = parentApp.dynamicInvokedWin = app.instancedWin;\n      win.show(); //该窗口设置closeAction为hide，并在viewport1销毁时自动销毁该窗口\n    }\n  });\n} else app.dynamicInvokedWin.show();"},"children":[],"expanded":false,"type":"item"},{"configs":{"text":"打开窗口","itemId":"openWin"},"events":{"click":"var win = new Ext.window.Window(app.xwl1._window1); //_window1为配置对象，window1为实例\nwin.show(); //app.xwl1.window1==win\n//如果window1是自动生成的实例，由于该实例的contextOwner不是容器（是上级appScope对象），因此不会自动销毁（可在viewport的destroy事件中显式销毁）"},"children":[],"expanded":false,"type":"item"},{"configs":{"text":"添加页","itemId":"addPage"},"events":{"click":"var card, cardConfig = app.xwl1._panel1;\ncardConfig.itemId = Wb.getId(); //也可以根据业务规则标识itemId，以方便查找指定card\ncard = app.tab1.add(cardConfig); //control-module的panel1对象\napp.tab1.setActiveTab(card);"},"children":[],"expanded":false,"type":"item"},{"configs":{"text":"上传文件对话框","itemId":"uploadDialog"},"events":{"click":"Wb.run({\n  url: 'upload',\n  success: function(app) { //app为upload公共模块的命名空间\n    app.upload({\n      url: 'm?xwl=examples/basic/dynamic-load/upload-file-dialog', //上传的url，需要改为实际有效url\n      iconCls: 'import_icon',\n      title: '上传窗口的标题',\n      showProgress: false, //默认为显示上传进度条\n      params: {\n        foo: 'bar' //上传的参数列表\n      },\n      beforeUpload: function() {\n        //可选方法，在上传之前触发，return false阻止上传操作\n      },\n      success: function() {\n        //可选方法，完成后触发的事件\n      }\n    });\n  }\n});"},"children":[],"expanded":false,"type":"item"}],"expanded":true,"type":"toolbar"},{"configs":{"region":"center","itemId":"tab1"},"children":[{"configs":{"file":"m?xwl=examples/basic/import-module/as-sub-control","itemId":"xwl_page"},"children":[],"expanded":false,"type":"xwl"}],"expanded":true,"type":"tab"}],"expanded":true,"type":"viewport"}],"expanded":true,"type":"module"}],"pageLink":"","iconCls":""}