【问题标题】:Saving Custom Attribute in Liferay Portal 6.1在 Liferay Portal 6.1 中保存自定义属性
【发布时间】:2013-03-07 06:36:55
【问题描述】:

我编写了一个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 中得到这个?

【问题讨论】:

    标签: liferay


    【解决方案1】:

    尝试使用PortalUtil.getExpandoValue(...)

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

    【讨论】:

    • 不幸的是,这并没有像看起来那样工作。我检查了liferay源。 Liferay 也采用了类似的方式,但名称已修改。看到这段代码.. String nick = (String) PortalUtil.getExpandoValue(request, "ExpandoAttribute--" + "nick" + "--", ExpandoColumnConstants.STRING, ExpandoColumnConstants.PROPERTY_DISPLAY_TYPE_TEXT_BOX);
    【解决方案2】:

    此代码部分将起作用

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

    为了其他人的帮助,我已将 portlet 上传到 Sourceforge。 test-expando-portlet的链接

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-10
      • 2022-07-12
      相关资源
      最近更新 更多