2016-06-13 76 views
0

我有一个名为Skills in liferay 6.2用户配置文件的自定义字段(即当您单击我的帐户 - >详细信息部分时)。目前,此技能字段接受多个文本值并显示为纯文本条目。我想要显示作为标签输入的每项技能。是否有任何可用的UI组件来执行此任务?我检查了Liferay文档上的标签管理。他们建议从Admin-> content部分添加标签。不过,我想在用户输入技能值时即时创建标签。在Liferay用户portlet中添加自定义字段值作为标签

回答

0

我的方法是使用liferay ui资产标签选择器。它提供了UI组件分配和显示标签

<label>Skills</label> 
     <liferay-ui:asset-tags-selector 
      className="<%= User.class.getName() %>" 
      classPK="<%= selUser != null ? selUser.getUserId() : 0 %>" 
     /> 
1

如果我得到你的权利,你希望用户输入的技能要创建作为门户网站的标签。

为此,您需要创建用于创建用户帐户的自定义CreateAccountAction

这是通过使用Liferay Extension Plugin项目在Liferay中扩展addUser()方法完成的。

则扩展addUser()方法里面添加逻辑来创建AssetCategoryAssetVocabulary和标签

这里是一个可能的方法来创建技能标签的例子

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)serviceContext.setAddGuestPermissions(true)在调用方法之前确保获得适当的权限

+1

创建ServiceContext像这样 'ServiceContext serviceContext = ServiceContextFactory.getInstance(BlogsEntry.class.getName(),portletRequest);' –

+0

其实我使用Bootstrap标签输入插件来解决当时的这些问题。感谢这些评论,如果我们再次需要这些要求,我会再检查它 – user596502

+0

没问题。很高兴能贡献。 –

相关问题