留言板

Alloy UI form

thumbnail
Priyanka Dhingra,修改在11 年前。

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
Rakesh Goswami,修改在11 年前。

RE: Alloy UI form

New Member 帖子: 15 加入日期: 12-2-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
Priyanka Dhingra,修改在11 年前。

RE: Alloy UI form

Liferay Master 帖子: 501 加入日期: 11-12-20 最近的帖子
Hi Rakesh,
thanks for the reply

but its not working
sangeeth k,修改在11 年前。

RE: Alloy UI form

Regular Member 帖子: 114 加入日期: 12-4-22 最近的帖子
Hi priyanka,

check this link
thumbnail
Priyanka Dhingra,修改在11 年前。

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
manasa chandri,修改在11 年前。

RE: Alloy UI form

Regular Member 帖子: 152 加入日期: 10-9-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
Priyanka Dhingra,修改在11 年前。

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
manasa chandri,修改在11 年前。

RE: Alloy UI form

Regular Member 帖子: 152 加入日期: 10-9-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
Vishal Panchal,修改在11 年前。

RE: Alloy UI form

Expert 帖子: 289 加入日期: 12-5-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
Priyanka Dhingra,修改在11 年前。

RE: Alloy UI form

Liferay Master 帖子: 501 加入日期: 11-12-20 最近的帖子
Hi Vishal,

Nope, its not working
thumbnail
Amit Doshi,修改在11 年前。

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
Priyanka Dhingra,修改在11 年前。

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
Amit Doshi,修改在11 年前。

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
Manoj Prasad,修改在9 年前。

RE: Alloy UI form

New Member 帖子: 14 加入日期: 13-3-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>