views:

1574

answers:

1

I added a custom user field in Liferay, and set a value on a specific user.

How can I access this value programmatically?

If I try this, I always get null:

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

user.getExpandoBridge().getAttribute("customAttr") returns a value of Type java.IO.Serializable. Maybe the cast here is wrong?

But the Custom Attribute does exist (following code prints out the attribute key):

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

Somehow I miss the point here....

A: 

It was a security problem...

In 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;
 }

I only had to set the view permisson on the custom expando value, and everything worked fine ....

danimajo