Foren

Alloy UI form

thumbnail
Priyanka Dhingra, geändert vor 11 Jahren.

Alloy UI form

Liferay Master Beiträge: 501 Beitrittsdatum: 20.12.11 Neueste Beiträge
Hi,

I used aui:form
<aui:form action="<%=actionMethod%>" name="<portlet:namespace />fm" method="post">
<aui:button-row>
		<aui:button type="submit" value="save" onClick="submitForm();" />
		<aui:button value="cancel" />
	</aui:button-row>
</aui:form>
<script type="text/javascript">
	function submitForm() {
		alert("In submit form");
		document.<portlet:namespace />fm.submit();
	}
</script>

but
document.<portlet:namespace />fm.submit(); statement is not working

Help me, resolve this
thanks in advance
regards
Priyanka
Rakesh Goswami, geändert vor 11 Jahren.

RE: Alloy UI form

New Member Beiträge: 15 Beitrittsdatum: 21.02.12 Neueste Beiträge
Hi..Priyanka
in place of name='<portlet:namespace />fm' use name="fm" only. just one change required. Keep all other things as it is. it will work.
thumbnail
Priyanka Dhingra, geändert vor 11 Jahren.

RE: Alloy UI form

Liferay Master Beiträge: 501 Beitrittsdatum: 20.12.11 Neueste Beiträge
Hi Rakesh,
thanks for the reply

but its not working
sangeeth k, geändert vor 11 Jahren.

RE: Alloy UI form

Regular Member Beiträge: 114 Beitrittsdatum: 22.04.12 Neueste Beiträge
Hi priyanka,

check this link
thumbnail
Priyanka Dhingra, geändert vor 11 Jahren.

RE: Alloy UI form

Liferay Master Beiträge: 501 Beitrittsdatum: 20.12.11 Neueste Beiträge
Hi Sangeeth,
I checked the link
but the form is html form
I want the solution for <aui:form> if you can help

Thanks anyways for replying
Regards
Priyanka
thumbnail
manasa chandri, geändert vor 11 Jahren.

RE: Alloy UI form

Regular Member Beiträge: 152 Beitrittsdatum: 28.09.10 Neueste Beiträge
Hi Priyanka,


Try this below code

<aui:form action='<%=actionMethod%>' id='<portlet:namespace />fm' name='<portlet:namespace />fm'
method="post">

When ever your calling the script, you need to give form id.

Thanks & Regards,
Manasa.chandri.
thumbnail
Priyanka Dhingra, geändert vor 11 Jahren.

RE: Alloy UI form

Liferay Master Beiträge: 501 Beitrittsdatum: 20.12.11 Neueste Beiträge
Hi Manasa,

Nope, not working.
You try to run this code:
<aui:form action="<%=actionMethod%>" name="<portlet:namespace />fm" id="<portlet:namespace />fm" method="post" onsubmit="xxx();">
	<aui:button-row>
		<aui:button value="save" onClick="<portlet:namespace />submitForm();" />
		<aui:button value="cancel" />
	</aui:button-row>
</aui:form>


<script type="text/javascript">
	function submitForm() {
		alert("In submit form");
		document.<portlet:namespace />fm.submit();
	}
	function xxx() {
		alert("going from xxx");
	}
</script>
thumbnail
manasa chandri, geändert vor 11 Jahren.

RE: Alloy UI form

Regular Member Beiträge: 152 Beitrittsdatum: 28.09.10 Neueste Beiträge
Hi Priyanka,

Where is the url, your didn't written type ="submit", other wise write the url in javascript.

(like: submitForm(url){
// your code
var URL = '<%=url%>';
document.fm.method="post";
document.fm.action = URL;
document.fm.submit();
}
)


Thanks & Regards,
Manasa.chandri.
thumbnail
Vishal Panchal, geändert vor 11 Jahren.

RE: Alloy UI form

Expert Beiträge: 289 Beitrittsdatum: 20.05.12 Neueste Beiträge
Hi Priyanka,

According to me your code is fine but it can be possible that the javascript function submitForm() could not be find.
So , You may do one thing that you can write your following lines of code(<script></script>) at the beginning of jsp page ..
<script type="text/javascript">
function submitForm() {
alert("In submit form");
document.<portlet:namespace />fm.submit();
}
</script>

Hope it will work for you,

Thanks & Regards,
Vishal R. Panchal
thumbnail
Priyanka Dhingra, geändert vor 11 Jahren.

RE: Alloy UI form

Liferay Master Beiträge: 501 Beitrittsdatum: 20.12.11 Neueste Beiträge
Hi Vishal,

Nope, its not working
thumbnail
Amit Doshi, geändert vor 11 Jahren.

RE: Alloy UI form

Liferay Master Beiträge: 550 Beitrittsdatum: 29.12.10 Neueste Beiträge
Priyanka :-

<aui:form action='<%=actionMethod%>' name='<portlet:namespace />fm'
method="post">
<aui:button-row>
<aui:button type="submit" value="save" onClick="submitForm();" />
<aui:button value="cancel" />
</aui:button-row>
</aui:form >
<script type="text/javascript">
function submitForm() {
alert("In submit form");
document.<portlet:namespace />fm.submit();
}
</script>



My First point is if you written


<aui:button type="submit" value="save" onClick="submitForm();" />


It will directly submit the form. Then what will be the difference between type="button" and type="submit"

Submit itself tells it will submit the form. Then what's the need of JavaScript function for it.
If you had written type="button" then you need to write javascript in order to submit the form.

And I don't think it matters what you write the name in the form. submit button will submit the form whatever the name will be.

I think you are missing something in making the action='<%=actionMethod%>'

Hope I am clear.

Regards,
Amit Doshi
thumbnail
Priyanka Dhingra, geändert vor 11 Jahren.

RE: Alloy UI form

Liferay Master Beiträge: 501 Beitrittsdatum: 20.12.11 Neueste Beiträge
Hi Amit,
this is the code...
<portlet:actionurl var="actionMethod" name="actionMethod" />
<script type="text/javascript">
	function submitForm() {
		alert("In submit form");
		document.<portlet:namespace />fm.submit();
	}
	function xxx() {
		alert("going from xxx");
	}
</script>
<aui:form action="<%=actionMethod%>" name="<portlet:namespace />fm" id="<portlet:namespace />fm" method="post" onsubmit="xxx();">
	<aui:button-row>
		<aui:button value="save" onClick="<portlet:namespace />submitForm();" />
		<aui:button value="cancel" />
	</aui:button-row>
</aui:form>

The actionURL is working without this document.<portlet:namespace />fm.submit(); containing function....i verified

but this statement is not getting executed
thumbnail
Amit Doshi, geändert vor 11 Jahren.

RE: Alloy UI form

Liferay Master Beiträge: 550 Beitrittsdatum: 29.12.10 Neueste Beiträge
It will never run.
Here I am highlighting some of the point.

Because the name='<portlet:namespace />fm' which you have used in form will make internally something name of the form like _portletname_fm. Check the name of that form with the help of firebug.

And when you write javascript like


document.<portlet:namespace />fm.submit();


It will check for the form name like "<portlet:namespace />fm". As It is written in javascript. It will not automatically create portletnamespace for the portlet.
you have to pass that parameter from the javascript function.

And it will never get any form with the name like "<portlet:namespace />fm".

So you need to do something like this


<portlet:actionurl var="actionMethod" name="actionMethod" />
<script type="text/javascript">
    function submitForm(portletnamespace) {
      var frmname=portletnamespace+"fm";
        alert("In submit form");
        xxx();
        document.frmname.submit();
    }
    function xxx() {
        alert("going from xxx");
    }
</script>
<aui:form action="<%=actionMethod%>" name="<portlet:namespace />fm" id="<portlet:namespace />fm" method="post">
    <aui:button-row>
        <aui:button value="save" onClick="submitForm('<portlet:namespace />');" />
        <aui:button value="cancel" />
    </aui:button-row>
</aui:form>


Hope I am clear.

Thanks & Regards,
Amit Doshi
Manoj Prasad, geändert vor 9 Jahren.

RE: Alloy UI form

New Member Beiträge: 14 Beitrittsdatum: 20.03.13 Neueste Beiträge
Seems to work as per Amit's suggestion

However my problem is slightly different, in this code below, when the save button is clicked, the FormTestPortlet.addProduct method does not get executed.

<portlet:actionURL var="addProduct" name="addProduct" />
<script type="text/javascript">
function submitForm(portletnamespace) {
var frmname=portletnamespace+"fm";
alert("In submit form");
xxx();

}
function xxx() {
alert("going from xxx");

}
</script>
<aui:form action='<%=addProduct%>' name='<portlet:namespace />fm'
id='<portlet:namespace />fm' method="post" >
<aui:button-row>
<aui:button value="save" />
<aui:button value="cancel" onClick="submitForm('<portlet:namespace />');" />
</aui:button-row>
</aui:form>



Portlet class has :

public class FormTestPortlet extends MVCPortlet {

public void addProduct(ActionRequest request, ActionResponse response)
throws Exception {
System.out.println("Gauranga!!!");
}
}

portlet.xml has
<portlet-name>form-test</portlet-name>
<display-name>Form Test</display-name>
<portlet-class>com.test.FormTestPortlet</portlet-class>
<init-param>
<name>view-template</name>
<value>/html/formtest/view.jsp</value>
</init-param>