平台默认提供了checkPermissionAction(验证是否拥有权限)这个action
如果需要通过判断某具体的功能是否有权限对页面进行控制,可以自己在js中调用checkPermissionAction,具体的参数设置参考如下:
Model.prototype.button6Click = function(event) { var process = "/appdemo/test/process/attachment/attachmentProcess";//要判断的功能的process路径 var activity = "mainActivity";//要判断的功能的activity var param = new biz.Request.ListParam();//定义checkPermissionAction需要的list参数 var item1 = new biz.Request.MapParam();//定义map参数,把要判断的proces和activity放到Map中 item1.put("process", new biz.Request.SimpleParam(process, XML.Namespaces.XMLSCHEMA_STRING)); item1.put("activity", new biz.Request.SimpleParam(activity, XML.Namespaces.XMLSCHEMA_STRING)); param.add(item1);//把Map参数添加到list中可以添加多个功能的Map var actiomParam = new biz.Request.ActionParam(); actiomParam.setList('permissions', param);//给action设置参数调用action biz.Request.sendBizRequest({ "context" : this.getContext(), "action" : "checkPermissionAction", "parameters" : actiomParam, "callback" : function(callbackData) { if (callbackData.state) { //action调用成功,从返回值中获取权限判断的结果 var items = callbackData.response; for (var i = 0; i < items.length; i++) { if (items[i].hasPermission == "false") { alert("没有此功能的权限"); } else alert("有功能权限"); } } else { alert("action调用失败"); } } }); };
评一波