this.include("initScript") //脚本配置的名称、别名或id //如果需要引用其他应用的脚本配置,将options设置为JsonObject this.include({ type : "portal", //应用类型。可以为 portal process cms。如果没有该选项或者值为空字符串,则表示应用脚本和被应用的脚本配置类型相同;比如在门户的A应用脚本中引用门户B应用的脚本配置,则type可以省略。 application : "首页", // 门户、流程、CMS的名称、别名、id。 默认为当前应用 name : "initScript" // 脚本配置的名称、别名或id })
this.define("xxx",function(){}.bind(this))
//定义一个方法 this.define("getUserName", function(){ return ( layout.desktop.session.user || layout.user ).name }.bind(this))
接口地址:
http://hostip:20030/x_program_center/jest/list.html
this.action("xxx服务根")或者MWF.Actions.get("xxxx服务根");
例如:引入了cms的文档服务方法,删除,修改,取消发布等方法。
var action = new this.Action("x_cms_assemble_control", { "del":{"uri": "/jaxrs/document/{id}", "method": "DELETE"}, "change":{"uri": "/jaxrs/document/category/change", "method": "PUT"}, "cancel":{"uri": "/jaxrs/document/publish/{id}/cancel", "method": "PUT"} } );
定义方法调用服务
this.define("change",function(data,callback){ action.invoke({"name": "change","data":data,"parameter": {},"async": true, "success": function(json){ if(callback)callback(json); }.bind(this)}); }.bind(this)
或者也可以直接调用系统内置的方法例如
MWF.Actions.get("x_cms_assemble_control").getDocument(id,function(json){ //code }.bind(this))
getDocument是系统中已经定义的方法,具体可以查看服务调用文件o2_core/o2/xAction/service目录下的服务文件
var action = new this.Action("x_cms_assemble_control", { "del":{"uri": "/jaxrs/document/{id}", "method": "DELETE"}, "change":{"uri": "/jaxrs/document/category/change", "method": "PUT"}, "cancel":{"uri": "/jaxrs/document/publish/{id}/cancel", "method": "PUT"}, // 获取未读消息 "info":{"uri": "/jaxrs/viewrecord/unread", "method": "PUT"}, // 获取文档 "list":{"uri": "/jaxrs/document/filter/list/{id}/next/{count}", "method": "PUT"}, "publish":{"uri": "/jaxrs/document/publish/content", "method": "PUT"}, }); this.data.add("curid","(0)"); this.data.add("pageCount","10"); this.define("loadList",function(id,count,data,callback){ action.invoke({"name": "list","parameter":{"id":id,"count":count},"data":data,"async": true, "success": function(json){if(callback)callback(json);}.bind(this)}); }.bind(this)); this.define("showList",function(json){ //alert(JSON.stringify(json)); var content = this.form.get("content").node; json.data.each(function(data){ new Element("div",{text:data.title}).inject(content); }.bind(this)) }.bind(this))
o2.load("/o2_lib/jquery/jquery.min.js",function(){ var jq = jQuery.noConflict(true); //alert(jq("#aaa").find("input").val()) jq(document).ready(function(){ //window.setTimeout(function(){ var tab = jq("table"); var tr = tab.find("tr"); tr.mouseover(function(){ jq(this).css("background-color","#ff0") }); tr.mouseout(function(){ jq(this).css("background-color","") }) //},2000); }) }.bind(this))
1、门户页面跳转,参数传递
this.page.toPage("页面名称", {"keyword": “value”});
获取: var par = this.page.parameters; //par的内容:{"type": "my type"}
2、使用系统内置组件模板
MWF.xDesktop.requireApp("Template", "MTooltips", null, false); var tt = new Class({ Extends: MTooltips, _getHtml : function(){ var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" + "<tr><td width='70'>title:</td>" + " <td style=''>test</td></tr>" + "<tr><td >time:</td>" + " <td style=''>2019-08-21</td></tr>" + "</table>"; return html; }, }); var pc = new tt(this.form.getApp().content,this.target.node,this.form.app,{},{ axis : "x" }); pc.create();
上一篇:门户开发-页面部件设计
下一篇:门户开发-页面及元素组件介绍