postCreate方法在aikau中多次调用

时间:2017-03-14 10:07:48

标签: alfresco-share aikau

我们在分面搜索屏幕5.1 + aikau(100.0.1)中的“选定项目”菜单中添加了一些自定义操作;

但是当我加载页面时,在自定义窗口小部件中,postCreate方法调用两次,当我选择“编辑属性”时,还会调用onSelectedDocumentsAction函数两次。

如果我在selectedItemsActionsGroup中再推送一个额外的项目,那么多次(3次)调用它。

var selectedItemsActionsGroup = widgetUtils.findObject(model.jsonModel.widgets,"id", "SELECTED_ITEMS_ACTIONS_GROUP");


    selectedItemsActionsGroup.config.widgets.push(
                    {
                        id : "OnActionEditProperties",
                        name : "faceted-search/CustomBulkSelectItems/CustomBulkSelectItems",
                        config : {
                            label : "Edit",
                            iconImage : url.context
                                    + "/res/components/documentlibrary/actions/y-16.png",
                            type : "action-link",
                            permission : "",
                            asset : "",
                            href : "",
                            hasAspect : "",
                            notAspect : "",
                            publishTopic : "BULK_OPS",
                            publishPayload : {
                                action : "onActionEditProperties",
                            }
                        }
                    },
                    {
                        id : "OnActionManaged",
                        name : "faceted-search/CustomBulkSelectItems/CustomBulkSelectItems",
                        config : {
                            label : "Managed",
                            iconImage : url.context
                                    + "/res/components/documentlibrary/actions/x-16.png",
                            type : "action-link",
                            permission : "",
                            asset : "",
                            href : "",
                            hasAspect : "",
                            notAspect : "",
                            publishTopic : "BULK_OPS",
                            publishPayload : {
                                action : "OnActionManaged",
                            }
                        }
                    });

*****************
CustomBulkSelectItems.js
**********************

            define(["dojo/_base/declare",
        "alfresco/services/FormsRuntimeService",
        "alfresco/core/UrlUtilsMixin",
         "alfresco/enums/urlTypes",
        "alfresco/core/Core",
        "alfresco/menus/AlfFilteringMenuItem",
        "alfresco/documentlibrary/_AlfDocumentListTopicMixin",
        "alfresco/core/CoreXhr",
        "dojo/_base/lang",
        "dojo/dom-class",
        "dojo/_base/array",
        "service/constants/Default","alfresco/core/topics"], 
        function(declare,FormsRuntimeService, UrlUtilsMixin,urlTypes,AlfCore ,AlfFilteringMenuItem, _AlfDocumentListTopicMixin,AlfCoreXhr, lang, domClass, 
                array, AlfConstants,topics) {

   return declare([FormsRuntimeService,UrlUtilsMixin,AlfCore,AlfFilteringMenuItem,_AlfDocumentListTopicMixin,AlfCoreXhr], {


       i18nRequirements: [ {i18nFile: "./CustomBulkSeledtItems.properties"} ],


      postCreate: function alfresco_documentlibrary_CustomBulkSelectItems__postCreate() {
         console.log(" bulkops postCreate************.");
         this.alfSubscribe("BULK_OPS", lang.hitch(this, this.onSelectedDocumentsAction));
         this.inherited(arguments);
      } ,

      /**
       * This function handles requests to perform actions on the currently selected documents. It takes the 
       * provided payload and updates it with the 
       *
       * @instance
       * @param {object} payload The payload containing the details of the action being requested
       * @fires alfresco/core/topics#MULTIPLE_ITEM_ACTION_REQUEST
       */
      onSelectedDocumentsAction: function alfresco_documentlibrary_CustomBulkSelectItems__onSelectedDocumentsAction(payload) {  
 console.log(" bulkops onSelectedDocumentsAction************.");

}
});
});

1 个答案:

答案 0 :(得分:0)

我认为你要两次调用同一个小部件faceted-search/CustomBulkSelectItems/CustomBulkSelectItems,而publishTopic也会从get.js文件调用两次。 更改了get.js中的小部件后,它对我来说很好。

分享你的想法。

我改变了下面的内容,输出就是这样。

enter image description here

enter image description here

var selectedItemsActionsGroup = widgetUtils.findObject(model.jsonModel.widgets,"id", "SELECTED_ITEMS_ACTIONS_GROUP");

selectedItemsActionsGroup.config.widgets.push(
                    {
                        id : "OnActionEditProperties",
                        name : "faceted-search/CustomBulkSelectItems/CustomBulkSelectItems",
                        config : {
                            label : "Edit",
                            iconImage : url.context
                                    + "/res/components/documentlibrary/actions/y-16.png",
                            type : "action-link",
                            permission : "",
                            asset : "",
                            href : "",
                            hasAspect : "",
                            notAspect : "",
                            publishTopic : "BULK_OPS",
                            publishPayload : {
                                action : "onActionEditProperties",
                            }
                        }
                    },
                    {
                        id : "OnActionManaged",
                        name : "faceted-search/CustomBulkSelectItems/CustomBulkSelect",
                        config : {
                            label : "Managed",
                            iconImage : url.context
                                    + "/res/components/documentlibrary/actions/x-16.png",
                            type : "action-link",
                            permission : "",
                            asset : "",
                            href : "",
                            hasAspect : "",
                            notAspect : "",
                            publishTopic : "BULK_OPS_1",
                            publishPayload : {
                                action : "OnActionManaged",
                            }
                        }
                    });
  

CustomBulkSelectItems.js

define(["dojo/_base/declare",
        "alfresco/services/FormsRuntimeService",
        "alfresco/core/UrlUtilsMixin",
         "alfresco/enums/urlTypes",
        "alfresco/core/Core",
        "alfresco/menus/AlfFilteringMenuItem",
        "alfresco/documentlibrary/_AlfDocumentListTopicMixin",
        "alfresco/core/CoreXhr",
        "dojo/_base/lang",
        "dojo/dom-class",
        "dojo/_base/array",
        "service/constants/Default","alfresco/core/topics"], 
        function(declare,FormsRuntimeService, UrlUtilsMixin,urlTypes,AlfCore ,AlfFilteringMenuItem, _AlfDocumentListTopicMixin,AlfCoreXhr, lang, domClass, 
                array, AlfConstants,topics) {

   return declare([FormsRuntimeService,UrlUtilsMixin,AlfCore,AlfFilteringMenuItem,_AlfDocumentListTopicMixin,AlfCoreXhr], {


       i18nRequirements: [ {i18nFile: "./CustomBulkSeledtItems.properties"} ],


      postCreate: function alfresco_documentlibrary_CustomBulkSelectItems__postCreate() {
         console.log(" bulkops postCreate************.");
         this.alfSubscribe("BULK_OPS", lang.hitch(this, this.onSelectedDocumentsAction));
         this.inherited(arguments);
      } ,

      /**
       * This function handles requests to perform actions on the currently selected documents. It takes the 
       * provided payload and updates it with the 
       *
       * @instance
       * @param {object} payload The payload containing the details of the action being requested
       * @fires alfresco/core/topics#MULTIPLE_ITEM_ACTION_REQUEST
       */
      onSelectedDocumentsAction: function alfresco_documentlibrary_CustomBulkSelectItems__onSelectedDocumentsAction(payload) {  
 console.log(" bulkops onSelectedDocumentsAction************.");

}
});
});
  

CustomBulkSelect.js

define(["dojo/_base/declare",
        "alfresco/services/FormsRuntimeService",
        "alfresco/core/UrlUtilsMixin",
         "alfresco/enums/urlTypes",
        "alfresco/core/Core",
        "alfresco/menus/AlfFilteringMenuItem",
        "alfresco/documentlibrary/_AlfDocumentListTopicMixin",
        "alfresco/core/CoreXhr",
        "dojo/_base/lang",
        "dojo/dom-class",
        "dojo/_base/array",
        "service/constants/Default","alfresco/core/topics"], 
        function(declare,FormsRuntimeService, UrlUtilsMixin,urlTypes,AlfCore ,AlfFilteringMenuItem, _AlfDocumentListTopicMixin,AlfCoreXhr, lang, domClass, 
                array, AlfConstants,topics) {

   return declare([FormsRuntimeService,UrlUtilsMixin,AlfCore,AlfFilteringMenuItem,_AlfDocumentListTopicMixin,AlfCoreXhr], {


       i18nRequirements: [ {i18nFile: "./CustomBulkSeledtItems.properties"} ],


      postCreate: function alfresco_documentlibrary_CustomBulkSelectItems__postCreate() {
         console.log(" CustomBulkSeledt bulkops postCreate************.");
         this.alfSubscribe("BULK_OPS_1", lang.hitch(this, this.onSelectedDocumentsAction));
         this.inherited(arguments);
      } ,

      /**
       * This function handles requests to perform actions on the currently selected documents. It takes the 
       * provided payload and updates it with the 
       *
       * @instance
       * @param {object} payload The payload containing the details of the action being requested
       * @fires alfresco/core/topics#MULTIPLE_ITEM_ACTION_REQUEST
       */
      onSelectedDocumentsAction: function alfresco_documentlibrary_CustomBulkSelectItems__onSelectedDocumentsAction(payload) {  
 console.log(" CustomBulkSeledt bulkops onSelectedDocumentsAction************.");

}
});
});

更新信息

请查看AlfFilteringMenuItem.js

postCreate: function alfresco_menus_AlfFilteringMenuItem____postCreate() {
         this.filterTopic && this.alfSubscribe(this.filterTopic, lang.hitch(this, this.filter));
         this.inherited(arguments);
      },

filter: function alfresco_menus_AlfFilteringMenuItem__filter(payload) {
         this.alfLog("warn", "No implementation of filtering extension point", payload);
      }

没有找到具体的实施方案。如果启用调试日志,则应该能够发出警告消息。

我查看了aikau日志,你可以看到默认行为也有多个请求(每个widger的每个请求)与你的类似。唯一的区别是,filter方法和publish (lang.hitch)内容。希望你现在清楚。 enter image description here