IBM 内容导航器 - 等待服务回调 return 值影响全局操作中的 isVisible()

Ibm content navigator - wait service callback return value to effect isVisible() inside global action

我使用服务从服务器端获取当前用户的广告列表,

我在全局工具栏上创建了一个新操作,如果用户不属于相关广告,我会尝试隐藏该操作,

我正在使用 Action isVisible() 函数,但我无法让 isVisible() 等到服务回答 return,我做错了什么?


define([ "dojo/_base/declare","dojo/_base/lang", "ecm/model/Request", "ecm/model/Action","ecm/widget/dialog/AddContentItemDialog"],

function(declare,lang,

Request,Action,AddContentItemDialog) {

      return declare("OpenEntryTemplatePluginDojo.OpenMyEntryTemplateAction",[ Action ], {

           

isUserBelogToSpecificADgroup:null,

isVisible:function(repository,listType){

                 

if(!this.isUserBelogToSpecificADgroup){

Request.invokePluginService("OpenEntryTemplatePlugin","CheckIfCurrentUserHaveSpecificADgroupService",{//to know if the user is belong to the relevant AD group 

                       

requestCompleteCallback : dojo.hitch(this, function(response) {                      

if(response.success) {return response.success;}
else {
this.isUserBelogToSpecificADgroup = false;
return this.isUserBelogToSpecificADgroup ;

                             

}

                       

})

                 

});

}else{
return false;
}

           

},```

方法invokePluginService()是异步的,不会等待请求完成。您可以使用同步方法 invokePluginServiceSynchronous() 代替此方法。这将等待请求完成并直接 returns 响应:

    var response = Request.invokePluginServiceSynchronous("OpenEntryTemplatePlugin",
        "CheckIfCurrentUserHaveSpecificADgroupService",{} );