我在liferay 6.2 用户配置文件中有一个名为Skills 的自定义字段(即当您单击我的帐户-> 详细信息部分时)。目前,此技能字段接受多个文本值并显示为纯文本条目。我想显示作为标签输入的每个技能。是否有任何可用的 UI 组件来执行此任务?我检查了 Liferay 文档上的标签管理。他们建议从 Admin->content 部分添加标签。但是,当用户在技能上输入值时,我想即时创建标签。
问问题
328 次
2 回答
1
如果我猜对了,您希望将用户输入的技能创建为门户中的标签。
为此,您需要创建一个自定义CreateAccountAction
来创建用户帐户。
这是使用 Liferay Extension Plugin 项目完成的,它也扩展了addUser()
liferay 中的方法。
然后在扩展addUser()
方法中添加创建逻辑AssetCategory
和AssetVocabulary
标签
这是创建技能标签的可能方法的示例
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);
}
确保在调用方法之前使用serviceContext.setAddGroupPermissions(true)
andserviceContext.setAddGuestPermissions(true)
以确保获得正确的权限
于 2017-04-21T10:14:12.477 回答
0
我的方法是使用 liferay ui 资产标签选择器。它提供 UI 组件来分配和显示标签
<label>Skills</label>
<liferay-ui:asset-tags-selector
className="<%= User.class.getName() %>"
classPK="<%= selUser != null ? selUser.getUserId() : 0 %>"
/>
于 2016-06-16T08:33:42.920 回答