掲示板

aui:form with many aui:button

10年前 に Oriol Mesia によって更新されました。

aui:form with many aui:button

Junior Member 投稿: 64 参加年月日: 13/04/04 最新の投稿
Hi people,

I am trying to develop an aui:form with three aui:button this way...


<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>

And I want to execute different methods from the Portlet, depending on the button pressed...

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

But by doing click on the And and Or buttons I don't get the request parameters of the form.


Do you know how I can solve this??

Thank you,
Oriol
thumbnail
10年前 に mohammad azaruddin によって更新されました。

RE: aui:form with many aui:button

Expert 投稿: 492 参加年月日: 12/09/17 最新の投稿
Hi

i used something like this
<aui:form name="fm" method="post" action="<%=myActionURL.toString()%>">
<aui:button name="button1" type="submit" value="XXX" />
<aui:button name="button2" type="button" value=" YYY" href="<%=myRenderURL.toString()%>" />
</aui:form
>

So when i click on first button form is submitted and it will go to action URL.and when i click on second button render URL is executed.
I stil confused how if Threre are two action URL for single form..


If you get solution for this please post here


Azhar
10年前 に Oriol Mesia によって更新されました。

RE: aui:form with many aui:button

Junior Member 投稿: 64 参加年月日: 13/04/04 最新の投稿
System.out.println("Parameters : " + request.getParameter("FirstRuleElement"));
System.out.println("Parameters : " + request.getParameter("FirstRuleAttribute"));
System.out.println("Parameters : " + request.getParameter("Operator"));

Using that on the destiny method I get three nulls.


Thank you but your code doesn't function for me.
thumbnail
10年前 に Anup Krishnan によって更新されました。

RE: aui:form with many aui:button

New Member 投稿: 9 参加年月日: 11/04/14 最新の投稿
Hi,

The target method received the null values because the form was never submitted , intead it was just a url request using href link.

Just as Amit suggested , try to call a commont script when any of the button clicked, and let the script decide which url to call.

Try this :
Add an name to the form :
<aui:form action="<%= generateRuleURL.toString() %>" name="formToSubmit" method="post">

Change the current button type and onclicks as below :
<aui:button type="button" value="End" onClick="<%= commonFunction('End')%>" />
<aui:button type="button" value="And" onClick="<%= commonFunction('And')%>" />
<aui:button type="button" value="Or" onClick="<%= commonFunction('Or')%>" />

Add a javascript in your page:
<script>
function commonFunction(value){
// 1) validate the form
// 2) check for the val and depending on that change the action of the form
// eg. if(val=='Or') { AUI().one("#<portlet:namespace/>formToSubmit").action='<%= generateRuleOrURL.toString()%>';}
// 3) Submit the form
}
</script>


HTH
Anup
10年前 に Oriol Mesia によって更新されました。

RE: aui:form with many aui:button

Junior Member 投稿: 64 参加年月日: 13/04/04 最新の投稿
Anup Krishnan:
Hi,

The target method received the null values because the form was never submitted , intead it was just a url request using href link.

Just as Amit suggested , try to call a commont script when any of the button clicked, and let the script decide which url to call.

Try this :
Add an name to the form :
<aui:form action="<%= generateRuleURL.toString() %>" name="formToSubmit" method="post">

Change the current button type and onclicks as below :
<aui:button type="button" value="End" onClick="<%= commonFunction('End')%>" />
<aui:button type="button" value="And" onClick="<%= commonFunction('And')%>" />
<aui:button type="button" value="Or" onClick="<%= commonFunction('Or')%>" />

Add a javascript in your page:
<script>
function commonFunction(value){
// 1) validate the form
// 2) check for the val and depending on that change the action of the form
// eg. if(val=='Or') { AUI().one("#<portlet:namespace/>formToSubmit").action='<%= generateRuleOrURL.toString()%>';}
// 3) Submit the form
}
</script>


HTH
Anup


Hi, thank you for the help but now I'm getting an error that I could not understand...

line 97 en el archivo jsp: /view.jsp
Invalid character constant
94: <aui:fieldset column="false">
95: <aui:input cssClass="lfr-textarea-container" name="ruleDefinition" style="height: 75px; width: 100%;" type="textarea" value="" wrap="off" />
96: <aui:button-row>
97: <aui:button type="button" value="End" onClick="<%= commonFunction('End')%>" />
98: <aui:button type="button" value="And" onClick="<%= commonFunction('And')%>" />
99: <aui:button type="button" value="Or" onClick="<%= commonFunction('Or')%>" />
100: </aui:button-row>

And I placed the function in the same view.jsp file as follows:

<portlet:defineObjects />

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

<script>
function commonFunction(value){
// 1) validate the form
var x=document.forms["rulesForm"]["FirstRuleElement"].value;
System.out.println("Prova : " + x);
var y=document.forms["rulesForm"]["FirstRuleAttribute"].value;
System.out.println("Prova : " + y);
var z=document.forms["rulesForm"]["Operator"].value;
System.out.println("Prova : " + z);
alert("First name must be filled out");
if (x==null || x=="" || y==null || y=="" || z==null || z=="")
{
alert("First name must be filled out");
return false;
}
// 2) check for the val and depending on that change the action of the form
if(value=='Or') { AUI().one("#<portlet:namespace/>rulesForm").action='<%= generateRuleOrURL.toString()%>';}
if(value=='And') { AUI().one("#<portlet:namespace/>rulesForm").action='<%= generateRuleAndURL.toString()%>';}
if(value=='End') { AUI().one("#<portlet:namespace/>rulesForm").action='<%= generateRuleURL.toString()%>';}
// 3) Submit the form
document.forms["rulesForm"].submit();
}
</script>

<c:choose>
<c:when test="<%= themeDisplay.isSignedIn() %>">
<aui:form action="<%= generateRuleURL.toString() %>" name="rulesForm" method="post">


.....

Could you help me with that, please? Thank you in advance!
thumbnail
10年前 に Anup Krishnan によって更新されました。

RE: aui:form with many aui:button

New Member 投稿: 9 参加年月日: 11/04/14 最新の投稿
Sorry my mistake it should be :
<aui:button type="button" value="End" onClick="commonFunction('End')" />
<aui:button type="button" value="And" onClick="commonFunction('And')" />
<aui:button type="button" value="Or" onClick="commonFunction('Or')" />

HTH
Anup
thumbnail
10年前 に Amit Doshi によって更新されました。

RE: aui:form with many aui:button

Liferay Master 投稿: 550 参加年月日: 10/12/29 最新の投稿
Oriol Mesia:
Hi people,

I am trying to develop an aui:form with three aui:button this way...


<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>

And I want to execute different methods from the Portlet, depending on the button pressed...

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

But by doing click on the And and Or buttons I don't get the request parameters of the form.


Do you know how I can solve this??

Thank you,
Oriol


Rather than making all button as submit. Make all of them as type="button" and bind the click event on the button. And based on the click call the AUI Script or javascript and call the url respectively from the Script.

Thanks & Regards,
Amit Doshi
thumbnail
10年前 に mohammad azaruddin によって更新されました。

RE: aui:form with many aui:button

Expert 投稿: 492 参加年月日: 12/09/17 最新の投稿
HI amith
what you suggested is almost clear and there will be no action attribute in aui:form tag.'m i correct...?
thumbnail
10年前 に Amit Doshi によって更新されました。

RE: aui:form with many aui:button

Liferay Master 投稿: 550 参加年月日: 10/12/29 最新の投稿
mohammad azaruddin:
HI amith
what you suggested is almost clear and there will be no action attribute in aui:form tag.'m i correct...?


There is an attribute action available in aui:form but you don't require the same in your current requirement.
thumbnail
10年前 に mohammad azaruddin によって更新されました。

RE: aui:form with many aui:button

Expert 投稿: 492 参加年月日: 12/09/17 最新の投稿
HI amith

Thank you emoticon