gpt4 book ai didi

java - 在 Liferay 中获取自定义用户字段值 (expando)

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:04:27 29 4
gpt4 key购买 nike

我在 Liferay 中添加了一个自定义用户字段,并为特定用户设置了一个值。

如何以编程方式访问此值?

如果我尝试这样做,我总是得到 null:

String customAttr = (String)user.getExpandoBridge().getAttribute("customAttr");

user.getExpandoBridge().getAttribute("customAttr") 返回 java.IO.Serializable 类型的值。

也许这里的 Actor 是错误的?

但自定义属性确实存在(以下代码打印出属性键):

for (Enumeration<String> attrs = user.getExpandoBridge().getAttributeNames(); attrs.hasMoreElements();)
_log.info("elem: '" + attrs.nextElement() + "'");

不知何故我错过了这里的重点....

最佳答案

这是一个安全问题......

com.liferay.portlet.expando.service.impl.ExpandoValueServiceImpl.getData(String className, String tableName, String columnName, long classPK)中:

    if (ExpandoColumnPermission.contains(
getPermissionChecker(), column, ActionKeys.VIEW)) {

return expandoValueLocalService.getData(
className, tableName, columnName, classPK);
}
else {
return null;
}

我只需要在自定义 expando 值上设置查看权限,一切正常。

关于java - 在 Liferay 中获取自定义用户字段值 (expando),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1130958/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com