Add the following code in jsp:
/*Asset Tags Selector tag*/
<liferay-ui:asset-tags-selector/>
/*Theme define object is mandatory for asset tag selector*/
<liferay-theme:defineObjects />
And In controller:
/*Create service context object for sample class*/
ServiceContext serviceContext = ServiceContextFactory.getInstance(Sample.class.getName(), actionRequest);
/*Calling the asset entry add method*/
AssetEntry assetEntry = AssetEntryLocalServiceUtil.updateEntry (serviceContext.getUserId(),serviceContext.getScopeGroupId(), Sample.class.getName(),sample.getId(),serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames());
AssetEntry assetEntry = AssetEntryLocalServiceUtil.updateEntry (serviceContext.getUserId(),serviceContext.getScopeGroupId(), Sample.class.getName(),sample.getId(),serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames());
Here I created service context object for my Sample entity.
And Using AssetEntryLocalServiceUtil.updateEntry() I am passing the required parameters.
And now you will find a new entry in AssetEntry and AssetEntry_AssetTag table.
And In the edit mode:
In jsp:
Get the tag names and make it as comma separated string.
And Pass it to curTags
/*Get your tag names*/
String tagNames = "tag1,tag2,tag3";
/*Give your tag names here*/
<liferay-ui:asset-tags-selector curTags="<%=tagNames %>"/>
Add,Edit and Delete can be easily done in liferay-ui:asset-tags-selector easily.
0 comments:
Post a Comment