我们在分面搜索屏幕5.1+aikau(100.0.1)的Selected Items菜单中添加了一些自定义操作;
但是当我加载页面时,在自定义小部件中,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************.");
}
});
});发布于 2017-03-14 21:26:37
我认为您两次调用相同的小部件faceted-search/CustomBulkSelectItems/CustomBulkSelectItems,publishTopic也从get.js文件中调用了两次。在get.js中更改小部件后,我觉得它看起来很好。
分享你的想法。
我像下面这样更改了你的东西,输出是这样的。


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************.");
}
});
});更新的信息
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)的东西。希望你现在清楚了。

https://stackoverflow.com/questions/42782982
复制相似问题