Fórumok

getting expando value

Joaquín Fernández, módosítva 10 év-val korábban

getting expando value

Junior Member Bejegyzések: 93 Csatlakozás dátuma: 2012.01.02. Legújabb bejegyzések
Hi all,

I've created a new user field with expando, and i'm able to get the value using:

String myattribute = (String)user.getExpandoBridge().getAttribute("My attribute");

The problem is that, when i try to get the value, but the user is not logged, I get null.

Do i have to be logged to used expando?
Is there any posibility to read the value without being logged in the portal?

Thanks!
thumbnail
Victor Zorin, módosítva 10 év-val korábban

RE: getting expando value

Liferay Legend Bejegyzések: 1228 Csatlakozás dátuma: 2008.04.14. Legújabb bejegyzések
If the user is not logged in, which value do you expect to fetch?

The custom attributes in this case (User.class) are stored against a specific user Id. When user is not logged in, user Id is null.
Joaquín Fernández, módosítva 10 év-val korábban

RE: getting expando value

Junior Member Bejegyzések: 93 Csatlakozás dátuma: 2012.01.02. Legújabb bejegyzések
Because the user for whom I'm asking this value, is not the logged user. It's another user.
When I'm logged, the custom attribute I'm getting is not my (the user logged) custom attribute.
thumbnail
Krzysztof Gołębiowski, módosítva 10 év-val korábban

RE: getting expando value

Liferay Master Bejegyzések: 549 Csatlakozás dátuma: 2011.06.25. Legújabb bejegyzések
Hello Joaquín,
Expando values has permissions as all other Liferay objects, if don't give read access for Guest role, he will always get null value. You can ommit permission check by adding false to getAttribute method:

String field = (String) user.getExpandoBridge().getAttribute("myField", false);


Regards,
KG