You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by bOOyah <bo...@nowhere.org> on 2004/03/11 11:43:19 UTC
Q: How to submit form in pop-up window and forward parent results
page?
Hi all.
(Caveat: this might actually turn out to be a Javascript question):
I would appreciate any help or even alternatives to what I'm trying to
achieve below:-
Here's a rough sequence of what I'm trying to achieve...
(1) My app has a page displaying an item link.
(2) When the user clicks on the link a pop-up browser window appears
with a form containing all the details about that item.
(3) After modifying the item's details the user clicks on the form
Submit button.
(4) The Submit action saves the changes to the database.
(5) The pop-up windows closes.
(6) The original, parent page 'refreshes' to reflect the changes the
user made in the pop-up windows (e.g. changing the name of the item
under the link).
I can get as far as step (4) using Struts and Javascript handlers.
Here's how my parent pops-up the item editing window:
----------
<% String link = "javascript:popUp('"+
request.getContextPath()+
/editItem.do?action=edit&item="+
itemID + "');";
%>
. . .
<td><html:link href="javascript:;" onclick="<%=link%>">
<c:out value="Edit Item"/></html:link>
</td>
----------
Here's the form element of my pop-up:
----------
<% String submitScript = "form.submit();
opener.location='"+
request.getContextPath()+
"/showItemDetails.do';"+
"self.close();";
%>
. . .
<html:form action="/saveItem" onsubmit="<%=submitScript%>">
----------
So I'm submitting the form, telling the parent to forward to the results
page ('/showItemDetails.do') and closing the pop-up.
But it doesn't work that way:-(
The submission works fine; the data is written to the DB. But the
pop-up browser window doesn't close and the parent isn't forwarded to
the results page. So I guess once a form is submitted the rest of the
Javascript just 'disappears' and isn't executed?
Any help out there..?
Many thanks in advance!
--
bOOyah
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: How to submit form in pop-up window and forward parent results page?
Posted by Anirudh Jayanth <an...@sysarris.soft.net>.
The javascript for the submit in the popup window could be something
like this
opener.parent.document.forms[0].action="Action.do";
opener.parent.document.forms[0].submit();
Anirudh Jayanth
SysArris Software
120A, Elephant Rock Road,
3rd Block, Jayanagar,
Bangalore - 560011
Tel: 6655165 / 052 [ ext - 244 ]
anirudh.j@sysarris.soft.net
-----Original Message-----
From: news [mailto:news@sea.gmane.org] On Behalf Of bOOyah
Sent: Thursday, March 11, 2004 4:13 PM
To: struts-user@jakarta.apache.org
Subject: Q: How to submit form in pop-up window and forward parent
results page?
Hi all.
(Caveat: this might actually turn out to be a Javascript question):
I would appreciate any help or even alternatives to what I'm trying to
achieve below:-
Here's a rough sequence of what I'm trying to achieve...
(1) My app has a page displaying an item link.
(2) When the user clicks on the link a pop-up browser window appears
with a form containing all the details about that item.
(3) After modifying the item's details the user clicks on the form
Submit button.
(4) The Submit action saves the changes to the database.
(5) The pop-up windows closes.
(6) The original, parent page 'refreshes' to reflect the changes the
user made in the pop-up windows (e.g. changing the name of the item
under the link).
I can get as far as step (4) using Struts and Javascript handlers.
Here's how my parent pops-up the item editing window:
----------
<% String link = "javascript:popUp('"+
request.getContextPath()+
/editItem.do?action=edit&item="+
itemID + "');";
%>
. . .
<td><html:link href="javascript:;" onclick="<%=link%>">
<c:out value="Edit Item"/></html:link>
</td>
----------
Here's the form element of my pop-up:
----------
<% String submitScript = "form.submit();
opener.location='"+
request.getContextPath()+
"/showItemDetails.do';"+
"self.close();";
%>
. . .
<html:form action="/saveItem" onsubmit="<%=submitScript%>">
----------
So I'm submitting the form, telling the parent to forward to the results
page ('/showItemDetails.do') and closing the pop-up.
But it doesn't work that way:-(
The submission works fine; the data is written to the DB. But the
pop-up browser window doesn't close and the parent isn't forwarded to
the results page. So I guess once a form is submitted the rest of the
Javascript just 'disappears' and isn't executed?
Any help out there..?
Many thanks in advance!
--
bOOyah
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org