通过liferay.expando以编程方式向用户添加自定义字段 [英] Adding custom field to User programmatically through liferay.expando

查看:212
本文介绍了通过liferay.expando以编程方式向用户添加自定义字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将字段添加到com.liferay.portal.model.User中,这是使用Expando的额外属性.有人可以向我解释一下这种方法是如何添加字段的,因为文档没有太多描述.

I am trying to add fields to com.liferay.portal.model.User, an extra attribute using Expando. Can someone explain to me how this method is adding a field because docs don't have much description.

private void addUserCustomAttribute(long companyId, ExpandoTable userExpandoTable, String attributeName, int type) throws PortalException, SystemException {

    ExpandoColumnLocalServiceUtil.getColumn(userExpandoTable.getTableId(), attributeName); //should be addColumn(long tableId, String name, int type) ???

} //and where can find type description couse i have very specific type, Map(String,Object) couse in ExpandoColumnConstants didn't see it

我从Liferay中摘录了 Expando Wiki的添加用户自定义属性.

I have taken this from Liferay Expando Wiki's Adding User Custom Attributes.

我什么时候应该全部称呼它?在我的项目中放在哪里?需要进行什么更改,或者需要进行任何更改才能调用它.

When should I call this all? Where to put this in my project? What change is required or everything needs to be changed to call it.

一些好的教程会很不错,因为很难找到从0到结尾的内容,总是只找到没有解释的部分.

Some good tutorial will be nice because it's hard to find something from 0 to end, always found only some part with no explanation.

推荐答案

问题不是很清楚.但是,如果您只是想为User添加自定义属性,则可以在此处引用我的答案,并复制到您的参考:

The question is not very clear. But if you simply want to add a custom attribute for your User then you can refer to my answer here and reproduced for your reference:

可以通过以下方式创建用户实体的自定义字段:
控制面板 -> 门户网站 -> 自定义字段 -> 用户.

Custom field for the user-entity can be created through:
Control Panel -> Portal -> Custom Fields -> User.

并且可以以编程方式创建如下:

And programmatically can be created as follows:

user.getExpandoBridge().addAttribute("yourCustomFieldKey");

然后将值设置为:

user.getExpandoBridge().setAttribute("yourCustomFieldKey", "valueForCustomField");

如果您的自定义字段已经存在,则可以像这样检查:

If your custom field is already present you can check like this:

if (user.getExpandoBridge().hasAttribute("yourCustomFieldKey")) { ... };

数据存储在以"EXPANDO" 为前缀的表中:

The data is stored in tables prefixed with "EXPANDO":

  • EXPANDOCOLUMN:存储自定义字段键和其他设置 (包含tableId引用)
  • EXPANDODATA :存储键的自定义字段值(包含 columnId和tableId刷新)
  • EXPANDOTABLE:存储要为其添加Liferay实体(用户)的商店 自定义字段
  • EXPANDOROW :存储用户及其值之间的链接信息 (包含tableId和userId引用)
  • EXPANDOCOLUMN: stores the custom field key and other settings (contains the tableId refrences)
  • EXPANDODATA: stores the custom field value for the key (contains the columnId and tableId refrences)
  • EXPANDOTABLE: stores for which liferay entity (user) are you adding the custom field
  • EXPANDOROW: stores linking information between a user and its values (contains tableId and userId refrences)

希望这会有所帮助.

这篇关于通过liferay.expando以编程方式向用户添加自定义字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆