掲示板

Alloy UI form

thumbnail
11年前 に Priyanka Dhingra によって更新されました。

Alloy UI form

Liferay Master 投稿: 501 参加年月日: 11/12/20 最新の投稿
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
11年前 に Rakesh Goswami によって更新されました。

RE: Alloy UI form

New Member 投稿: 15 参加年月日: 12/02/21 最新の投稿
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
11年前 に Priyanka Dhingra によって更新されました。

RE: Alloy UI form

Liferay Master 投稿: 501 参加年月日: 11/12/20 最新の投稿
Hi Rakesh,
thanks for the reply

but its not working
11年前 に sangeeth k によって更新されました。

RE: Alloy UI form

Regular Member 投稿: 114 参加年月日: 12/04/22 最新の投稿
Hi priyanka,

check this link
thumbnail
11年前 に Priyanka Dhingra によって更新されました。

RE: Alloy UI form

Liferay Master 投稿: 501 参加年月日: 11/12/20 最新の投稿
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
11年前 に manasa chandri によって更新されました。

RE: Alloy UI form

Regular Member 投稿: 152 参加年月日: 10/09/28 最新の投稿
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
11年前 に Priyanka Dhingra によって更新されました。

RE: Alloy UI form

Liferay Master 投稿: 501 参加年月日: 11/12/20 最新の投稿
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
11年前 に manasa chandri によって更新されました。

RE: Alloy UI form

Regular Member 投稿: 152 参加年月日: 10/09/28 最新の投稿
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
11年前 に Vishal Panchal によって更新されました。

RE: Alloy UI form

Expert 投稿: 289 参加年月日: 12/05/20 最新の投稿
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
11年前 に Priyanka Dhingra によって更新されました。

RE: Alloy UI form

Liferay Master 投稿: 501 参加年月日: 11/12/20 最新の投稿
Hi Vishal,

Nope, its not working
thumbnail
11年前 に Amit Doshi によって更新されました。

RE: Alloy UI form

Liferay Master 投稿: 550 参加年月日: 10/12/29 最新の投稿
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
11年前 に Priyanka Dhingra によって更新されました。

RE: Alloy UI form

Liferay Master 投稿: 501 参加年月日: 11/12/20 最新の投稿
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
11年前 に Amit Doshi によって更新されました。

RE: Alloy UI form

Liferay Master 投稿: 550 参加年月日: 10/12/29 最新の投稿
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
9年前 に Manoj Prasad によって更新されました。

RE: Alloy UI form

New Member 投稿: 14 参加年月日: 13/03/20 最新の投稿
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>