0

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

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.

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.

4

2 に答える 2

2

質問はあまり明確ではありません。ただし、単にカスタム属性を追加したい場合は、ここUserで私の回答を参照して、参照用に複製することができます。

ユーザーエンティティのカスタムフィールドは、次の方法で作成できます
Control Panel -> Portal -> Custom Fields -> User

また、プログラムで次のように作成できます。

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

次に、値を次のように設定します。

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

カスタムフィールドがすでに存在する場合は、次のように確認できます。

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

データは、「EXPANDO」というプレフィックスが付いたテーブルに保存されます。

  • EXPANDOCOLUMN:カスタムフィールドキーおよびその他の設定を格納します(tableId参照を含む)
  • EXPANDODATA:キーのカスタムフィールド値を格納します(columnIdおよびtableId参照を含む)
  • EXPANDOTABLE:カスタムフィールドを追加するLiferayエンティティ(ユーザー)のストア
  • EXPANDOROW:ユーザーとその値の間のリンク情報を格納します(tableIdおよびuserId参照を含む)

お役に立てれば。

于 2012-07-19T10:37:56.087 に答える