自定义 portlet 中的自动字段 liferay

Auto fields liferay in custom portlet

我有疑问。

我有一个 main.jsp,其中包括另外 2 个 jsp 和一个提交按钮。它们都是表单的一部分。 第二个包括一个带有验证器的自动字段:

<div id="groupwork-fields" >
    <div class="lfr-form-row lfr-form-row-inline">
        <div class="row-fields">
            <aui:input fieldParam='name' id="repetibleName" cssClass="full-size"
                name="<%=AwardConstants.FIELD_OTHERS_NAME%>"
                label='<%=AwardConstants.LABEL_NAME %>'
                value="">
                <aui:validator name="custom" errorMessage="fill-name">
                        function (val, fieldNode, ruleValue) {
                            var result = true;
                                var selector = document.getElementById("<portlet:namespace/>select-group").value;
                                if (selector == 1 && val === "") {
                                    result = false;
                                }
                                return result;
                        }
                    </aui:validator>
                </aui:input>
                <aui:input cssClass="full-size"
                    id="email0" fieldParam='email0'
                    name="email0"
                    label='<%=AwardConstants.LABEL_EMAIL %>'
                    value="">
                    <aui:validator name="maxLength">100</aui:validator>
                    <aui:validator name="email"></aui:validator>
                    <aui:validator name="custom" errorMessage="fill-email">
                        function (val, fieldNode, ruleValue) {
                            var result = true;
                            var name = document.getElementById("<portlet:namespace/>name0").value;
                            if (name !== "" && val === "") {
                                    result = false;
                             }
                            return result;
                        }
                    </aui:validator>
            </aui:input>
        </div>
    </div>
</div>

验证这些字段并按下提交按钮后转到下一个方法:

public void saveAutofieldData(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException,  SystemException {

    String groupworkIndexes = actionRequest.getParameter("groupworkIndexes");
    _log.info("::::::::::::::::groupworkIndexes:::::::::::::::::::::::" + groupworkIndexes); 

    /**
     * Split the row index by comma
     */

    String[] indexOfRows = groupworkIndexes.split(",");
    _log.info("::::::::::::::::indexOfRows.length:::::::::::::::::::::::"+ indexOfRows.length);

    for (int i = 0; i < indexOfRows.length; i++) {

        String name = (actionRequest.getParameter("name"+ indexOfRows[i])).trim();
        String email = (actionRequest.getParameter("email"+ indexOfRows[i])).trim();
        _log.info("::::::::::::Name::::::::::::::" + name);
        _log.info("::::::::::::Email::::::::::::::" + email);
    }
}

问题是当它试图读取时:actionRequest.getParameter("groupworkIndexes"); 我得到 null

提前致谢

我终于找到了解决办法。 我见过的所有示例都使用 "actionRequest" 来检索数据:

    String groupworkIndexes = actionRequest.getParameter("groupworkIndexes");
    String name = actionRequest.getParameter("name" + indexOfRows[i]));

但在我的例子中,我使用了以下几行:

    String name = (uploadPortletRequest.getParameter("name" + indexOfRows[i]));
    String groupworkIndexes =  (uploadPortletRequest.getParameter("groupworkIndexes"));

我们并不总是会通过 actionRequest

获得首选值