You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sa...@t-systems.com on 2004/03/11 15:24:11 UTC
AW: How to submit form in pop-up window and forward parent result
s page?
Hello bOOyah,
I have had the same problem that you describe. Were you able to solve it?. If so could you share how you did it?
Sam
-----Ursprungliche Nachricht-----
Von: news [mailto:news@sea.gmane.org]Im Auftrag von bOOyah
Gesendet: Donnerstag, 11. Marz 2004 11:43
An: struts-user@jakarta.apache.org
Betreff: 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
Re: AW: How to submit form in pop-up window and forward parent results
page? [OT]
Posted by Guido GarcĂa Bernardo <gg...@itdeusto.com>.
Your "editItem" action, when the update is finished, forwards to
"autoCloseAndReloadOpener.jsp"
autoCloseAndReloadOpener.jsp does steps (5) and (6):
<html>
<body onLoad="self.close()">
<script>
// Reload opener
opener.formReload.submit(); // or something like this, using "opener"
</scrip>
</body>
</html>
I have not tried it...
Regards
PD. This is not struts related.
Samuel.Opoku-Boadu@t-systems.com wrote:
>Hello bOOyah,
>
>I have had the same problem that you describe. Were you able to solve it?. If so could you share how you did it?
>
>Sam
>
>-----Ursprungliche Nachricht-----
>Von: news [mailto:news@sea.gmane.org]Im Auftrag von bOOyah
>Gesendet: Donnerstag, 11. Marz 2004 11:43
>An: struts-user@jakarta.apache.org
>Betreff: 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!
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: AW: How to submit form in pop-up window and forward parent result
s page?
Posted by bOOyah <bo...@nowhere.org>.
Samuel.Opoku-Boadu@t-systems.com wrote:
> Hello bOOyah,
>
> I have had the same problem that you describe. Were you able to solve it?. If so could you share how you did it?
>
> Sam
Hi Sam
The closest help I've received yet was from Anirudh Jayanth who said:
8<--------------------------------------------------
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();
8<--------------------------------------------------
I haven't had a chance to try that out but it looks promising. I don't
think it will also close the pop-up window though.
Kind regards,
--
bOOyah
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org