Reputation: 427
I have a custom field called Skills in liferay 6.2 user profile (i.e when you click on My Account->Details section). For now this Skills field accepts multiple text values and shown as a plain text entry. I want to show each skill being entered as a Tag. Is there any available UI component to perform this task? I checked on Tags management on Liferay documentation. They suggest to add tags from Admin->content section. However i want to create tags on the fly as user enter values on Skills.
Upvotes: 0
Views: 401
Reputation: 82
If I get you right you want the Skills the user enter to be created as tags in the portal.
For that you would need to create a Custom CreateAccountAction
for creating user accounts.
This is done using Liferay Extension Plugin project too extend the addUser()
method in liferay.
then inside the extended addUser()
method you add logic to create AssetCategory
, AssetVocabulary
and Tags
here is an example of a possible method to create the Skill tag
protected AssetCategory addAssetCategory(long userId,
long parentCategoryId, String title, long vocabularyId,
ServiceContext serviceContext) throws Exception {
Map<Locale, String> titleMap = new HashMap<Locale, String>();
setLocalizedValue(titleMap, title);
return AssetCategoryLocalServiceUtil.addCategory(userId,
parentCategoryId, titleMap, null, vocabularyId, null,
serviceContext);
}
protected AssetVocabulary addAssetVocabulary(long userId, String title,
ServiceContext serviceContext) throws Exception {
Map<Locale, String> titleMap = new HashMap<Locale, String>();
setLocalizedValue(titleMap, title);
return AssetVocabularyLocalServiceUtil.addVocabulary(userId,
StringPool.BLANK, titleMap, null, null, serviceContext);
}
Make sure you use serviceContext.setAddGroupPermissions(true)
and serviceContext.setAddGuestPermissions(true)
before calling the methods to ensure that the proper permissions are gotten
Upvotes: 1
Reputation: 427
my approach is to use liferay ui asset tag selector. It provides UI component to assign and display tags
<label>Skills</label>
<liferay-ui:asset-tags-selector
className="<%= User.class.getName() %>"
classPK="<%= selUser != null ? selUser.getUserId() : 0 %>"
/>
Upvotes: 0