0

我正在尝试以这种方式开发带有三个 aui:button 的 aui:form ...

<portlet:actionURL name="generateRule" var="generateRuleURL"/>
<portlet:actionURL name="generateRuleAnd" var="generateRuleAndURL"/>
<portlet:actionURL name="generateRuleOr" var="generateRuleOrURL"/>

<aui:form action="<%= generateRuleURL.toString() %>" method="post">
<aui:fieldset column="false">
<aui:select name="FirstRuleElement" >
<aui:option value="Age">
<liferay-ui:message key="Age" />
</aui:option>
<aui:option value="Country">
<liferay-ui:message key="Country" />
</aui:option>
<aui:option value="Direction">
<liferay-ui:message key="Direction" />
</aui:option>
</aui:select>
<aui:select name="FirstRuleAttribute" >
<aui:option value="Age">
<liferay-ui:message key="Age" />
</aui:option>
<aui:option value="Country">
<liferay-ui:message key="Country" />
</aui:option>
<aui:option value="Direction">
<liferay-ui:message key="Direction" />
</aui:option>
</aui:select>
</aui:fieldset>
<aui:fieldset column="false">
<aui:button-row>
<aui:button type="submit" value="End" />

<aui:button type="submit" value="And"
onClick="<%= generateRuleAndURL.toString()%>" />

<aui:button type="submit" value="Or"
onClick="<%= generateRuleOrURL.toString()%>" />
</aui:button-row>
</aui:fieldset>
</aui:form>

我想从 Portlet 执行不同的方法,具体取决于按下的按钮......

public void generateRule(ActionRequest request, ActionResponse response)
public void generateRuleAnd(ActionRequest request, ActionResponse response)
public void generateRuleOr(ActionRequest request, ActionResponse response)

使用此功能检索数据...

request.getParameter("FirstRuleElement")

但是通过单击 And 和 Or 按钮,我没有得到表单的请求参数。

你知道我怎么能解决这个问题吗?

谢谢你,奥里奥尔

4

2 回答 2

1

取而代之的是

<aui:button type="submit" value="And"
onClick="<%= generateRuleAndURL.toString()%>" />

<aui:button type="submit" value="Or"
onClick="<%= generateRuleOrURL.toString()%>" />

,您可以在下面使用 javascript。

<aui:button type="submit" value="And"
onClick="javascript:submitTheForm('<%= generateRuleAndURL.toString()%>')" />
<aui:button type="submit" value="Or"
onClick="javascript:submitTheForm('<%=generateRuleOrURL.toString()%>')" />

<script>
function submitTheForm(url){
    document.forms['<portlet:namespace/>myform'].action=url;
    document.forms['<portlet:namespace/>myform'].submit();
}
</script>

为 aui:form 赋予 name 属性为 myForm。

高温高压

于 2013-04-24T14:27:49.410 回答
0

这是我在 docroot 文件夹下 view.jsp 中的代码。

<portlet:defineObjects />

<c:choose>
    <c:when test="<%= themeDisplay.isSignedIn() %>">
        <aui:form action="<%= generateRuleURL.toString() %>" method="post">
            <aui:fieldset column="false">
            <aui:select name="FirstRuleElement" >
                <aui:option value="Age">
                    <liferay-ui:message key="Age" />
                </aui:option>
                <aui:option value="Country">
                    <liferay-ui:message key="Country" />
                </aui:option>
                <aui:option value="Direction">
                    <liferay-ui:message key="Direction" />
                </aui:option>
            </aui:select>
            <aui:select name="FirstRuleAttribute" >
                <aui:option value="Age">
                    <liferay-ui:message key="Age" />
                </aui:option>
                <aui:option value="Country">
                    <liferay-ui:message key="Country" />
                </aui:option>
                <aui:option value="Direction">
                    <liferay-ui:message key="Direction" />
                </aui:option>
            </aui:select>
            <aui:select name="Operator" >
                <aui:option value="=">
                    <liferay-ui:message key="=" />
                </aui:option>
                <aui:option value=">">
                    <liferay-ui:message key=">" />
                </aui:option>
                <aui:option value="<">
                    <liferay-ui:message key='"\<"' />
                </aui:option>
                <aui:option value=">=">
                    <liferay-ui:message key=">=" />
                </aui:option>
                <aui:option value="<=">
                    <liferay-ui:message key="<=" />
                </aui:option>
            </aui:select>
            </aui:fieldset>
            <aui:fieldset column="false">
            <aui:input cssClass="lfr-textarea-container" name="ruleDefinition" style="height: 75px; width: 100%;" type="textarea" value="" wrap="off" />
            <aui:button-row>

                <portlet:actionURL name="generateRule" var="generateRuleURL"/>
                <aui:button type="button" value="End" onClick="<%= generateRuleURL.toString()%>" />

                <portlet:actionURL name="generateRule" var="generateRuleAndURL"/>
                <aui:button type="button" value="And" onClick="<%= generateRuleAndURL.toString()%>" />

                <portlet:actionURL name="generateRule" var="generateRuleOrURL"/>
                <aui:button type="button" value="Or" onClick="<%= generateRuleOrURL.toString()%>" />

                </aui:button-row>
            </aui:fieldset>
        </aui:form>
    </c:when>
    <c:otherwise>
        <div class="portlet-msg-info">
            <aui:a href="<%= themeDisplay.getURLSignIn() %>" label="sign-in-to-your-account" />
        </div>
    </c:otherwise>
</c:choose>
于 2013-04-26T10:41:27.560 回答