簡體   English   中英

在Liferay Portal 6.1中保存自定義屬性

[英]Saving Custom Attribute in Liferay Portal 6.1

我寫了一個liferay portlet來學習expando / custom屬性。 我為每個用戶都有一個名為nick的自定義屬性。 我在jsp中有這個表格

<form action='<portlet:actionURL></portlet:actionURL>' method="post">
    <liferay-ui:custom-attribute className="<%=User.class.getName()%>"
        classPK="<%=user.getPrimaryKey()%>" name="nick" editable="true" label="Nick">
    </liferay-ui:custom-attribute>
    <input type="submit" value="Save" />
</form>

當我嘗試使用以下方法在processAction中獲取此值時

String nick = request.getParameter("nick");

要么

String nick = ParamUtil.get(request, "nick", "no nick given");

它什么也沒給我。 我檢查了此文本框的名稱為_testexpandoportlet_WAR_testexpandoportlet_ExpandoAttribute--nick--

如何在processAction中獲得它?

嘗試使用PortalUtil.getExpandoValue(...)

  String expandoValue = (String)PortalUtil.getExpandoValue(request, "nick", ExpandoColumnConstants.STRING, ExpandoColumnConstants.PROPERTY_DISPLAY_TYPE_TEXT_BOX);

此代碼段將起作用

String nick = "";
nick = (String) PortalUtil.getExpandoValue(request,
                "ExpandoAttribute--" + "nick" + "--",
                ExpandoColumnConstants.STRING, ExpandoColumnConstants.PROPERTY_DISPLAY_TYPE_TEXT_BOX);

為了他人的幫助,我已將Portlet上傳到Sourceforge。 test-expando-portlet的鏈接

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM