Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How to pass data from asset-categories-selector-web module to liferay-a
hi,
when use taglib liferay-asset:asset-categories-selector to select categories.
the taglib call the module of asset-categories-selector-web to fires item selector save event on selected node change.
selectedNodeChange_(event) {
let newVal = event.newVal;
let selectedNodes = this.selectedNodes_;
if (!selectedNodes) {
selectedNodes = [];
}
if (newVal) {
let data = {};
newVal.forEach(
(node) => {
data[node.name] = {
categoryId: node.vocabulary ? 0 : node.id,
value: node.name,
vocabularyId: node.vocabulary ? node.id : 0
};
}
);
selectedNodes.forEach(
(node) => {
if (newVal.indexOf(node) === -1) {
data[node.name] = {
categoryId: node.vocabulary ? 0 : node.id,
unchecked: true,
value: node.name,
vocabularyId: node.vocabulary ? node.id : 0
};
}
}
);
selectedNodes = [];
newVal.forEach(
(node) => {
selectedNodes.push(node);
}
);
this.selectedNodes_ = selectedNodes;
Liferay.Util.getOpener().Liferay.fire(
this.itemSelectorSaveEvent,
{
data: data
}
);
}
}
Liferay.fire trigger the itemSelectorSaveEvent and data.
and in the taglib liferay-asset:asset-categories-selector
_showSelectPopup: function(event) {
var instance = this;
event.domEvent.preventDefault();
instance.set('categoryIds', instance.entries.keys);
var uri = Lang.sub(
decodeURIComponent(instance.get('portletURL')),
{
selectedCategories: instance.get('categoryIds'),
singleSelect: instance.get('singleSelect'),
vocabularyIds: instance.get('vocabularyIds')
}
);
var itemSelectorDialog = new A.LiferayItemSelectorDialog(
{
eventName: instance.get('eventName'),
on: {
selectedItemChange: function(event) {
var data = event.newVal;
if (data) {
for (var key in data) {
var found = false;
instance.entries.each(
function(item) {
if (key === item.value) {
found = true;
}
if (key === item.value && data[key].unchecked) {
instance.entries.remove(item);
}
}
);
data[key][0] = key;
if (!found && !data[key].unchecked) {
instance.entries.add(data[key]);
}
}
}
instance.set('categoryIds', instance.entries.keys);
instance._updateInputHidden();
}
},
'strings.add': Liferay.Language.get('done'),
title: Liferay.Language.get('categories'),
url: uri
}
);
itemSelectorDialog.open();
},
In general, relative to Liferay.fire is Liferay.on. but i could not find Liferay.on
Does the following code have the same functionality as liferay.on, whether it has received the passed data? How to pass data from asset-categories-selector-web module to taglib liferay-asset:asset-categories-selector.
thank you very much.
A.LiferayItemSelectorDialog(
{
eventName: instance.get('eventName'),
on: {
....
}
Hi,
Use this tag <liferay-asset:asset-categories-selector> and you controller add belowline to get the selected categoriesString catIds =ParamUtil.getString(actionRequest,"assetCategoryIds");
My requirement is to include and exclude some asset categories in single submit.I am using <liferay-asset:asset-categories-selector> this tag to get the asset categories.Using this i can able to include or exclude any one operation only in single action.Can any one help me to solve this issue
Regards,Saleem.
Use this tag <liferay-asset:asset-categories-selector> and you controller add belowline to get the selected categoriesString catIds =ParamUtil.getString(actionRequest,"assetCategoryIds");
My requirement is to include and exclude some asset categories in single submit.I am using <liferay-asset:asset-categories-selector> this tag to get the asset categories.Using this i can able to include or exclude any one operation only in single action.Can any one help me to solve this issue
Regards,Saleem.