我正在尝试用这种方式开发一个带有三个aui:按钮的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按钮我没有得到表格的请求参数。
你知道我怎么能解决这个问题吗?
谢谢你, 奥里奥尔
答案 0 :(得分: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>
将name属性命名为aui:form的myForm。
HTH
答案 1 :(得分: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>