自定义portray在自定义portlet中

时间:2015-11-30 12:34:56

标签: liferay liferay-aui autofield

我有疑问。

我有一个main.jsp,其中包含另外两个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

提前谢谢

1 个答案:

答案 0 :(得分:0)

我终于得到了解决方案。 我见过的所有例子都是&#34; actionRequest&#34;检索数据:

    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

获得首选值