Foren

submit form by using javascript and using alloy ui tag

asif aftab, geändert vor 10 Jahren.

submit form by using javascript and using alloy ui tag

Regular Member Beiträge: 123 Beitrittsdatum: 02.09.13 Neueste Beiträge
I have to navigate from one jsp to another by using button. for that reason I just created an action class in which I can jump dynamically

<portlet:actionurl var="viewCall" name="returnView"></portlet:actionurl>


So I just used javascript function and then to jsp.
my js function is
<aui:script>
function viewFun()																						//redirect to insert action class
{ 
	 document.getElementById("<portlet:namespace />viewDisplayd").action='&lt;%=viewCall.toString()%&gt;';
	// alert("hello");
	 document.getElementById('<portlet:namespace />viewDisplayd').submit();
	 
} 
</aui:script>

and my code is

<aui:form id="viewDisplayd" method="post">		 		 	  
		<aui:input type="button" value="back" name="hello" onclick="viewFun();"></aui:input>
</aui:form>

but in javascript I got an error that either value is null or not an object in
document.getElementById

I already did lots of time the same thing but without using aui.So please help me
thanks
asif aftab
thumbnail
Atin Agarwal, geändert vor 10 Jahren.

RE: submit form by using javascript and using alloy ui tag

Junior Member Beiträge: 86 Beitrittsdatum: 20.02.12 Neueste Beiträge
Hi Asif,

I have to navigate from one jsp to another by using button. for that reason I just created an action class in which I can jump dynamically


If you simply want to navigate from one jsp to another then there is no need to use action URL , you can simply use render URL for that.

Suppose you want to navigate from a.jsp to b.jsp then simply use the following code on your a.jsp -

<portlet:renderURL var="viewCall">
<portlet:param name="mvcPath" value="/html/b.jsp"/> // path to your b.jsp
</portlet:renderURL>

<aui:button value="back" type="button" onClick="<%= viewCall%>" />

Also, in case you want to submit a form through AUI script you can use -

<aui:form name="viewDisplayd" method="post">
<aui:input type="button" value="back" name="hello" onclick="viewFun()"></aui:input>
</aui:form>

<aui:script>
function viewFun(){
submitForm(document.<portlet:namespace />viewDisplayd);
}
</aui:script>

Regards,
Atin Agarwal
thumbnail
Edwin Lobo, geändert vor 7 Jahren.

RE: submit form by using javascript and using alloy ui tag

New Member Beiträge: 10 Beitrittsdatum: 05.05.16 Neueste Beiträge
Atin Agarwal:

Also, in case you want to submit a form through AUI script you can use -
<aui:form name="viewDisplayd" method="post">
<aui:input type="button" value="back" name="hello" onclick="viewFun()"></aui:input>
</aui:form>

<aui:script>
function viewFun(){
submitForm(document.<portlet:namespace />viewDisplayd);
}
</aui:script>


Hi Atin,

Can I send an aui:form value to the viewFun() Javascript function?


<aui:form action="viewFun()" name="<portlet:namespace />fm">  
<aui:form name="<portlet:namespace />fm" method="post"> 
        <aui:input name="hello" label="hello"></aui:input>
        <aui:button type="submit"></aui:button>
</aui:form>

<aui:script>
function viewFun(){        
        var hello = &lt;% ParamUtil.getString(request, "hello");%&gt;;
}
</aui:script>
</aui:form>


How to do something like that?
thumbnail
Santosh B Biradar, geändert vor 6 Jahren.

RE: submit form by using javascript and using alloy ui tag

Junior Member Beiträge: 41 Beitrittsdatum: 04.08.15 Neueste Beiträge
Hi Asif,

If you want to redirect from one jsp page to another jsp then yo should use liferay Render Url in ur jsp page.
And If you want jump from Action class to Jsp then you should use actionResponse.setRenderParametes("","") and there you should provide you key and valule pair[mvcPath , and Your path of you jsp]
Its very late reply but , it will help to somebody

Regards
Santosh B B