You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Peter Alfors <pe...@irista.com> on 2001/06/15 16:15:20 UTC
Re: struts-config.xml - How do I open a "success" path as a new
window???
When you say 'return', do you mean you want to close the new window?
Or do you want to open a new link in the original window?
If you just want to close the window, then you can use a javascript command such
as: window.close()
However, if you want to open a link in the parent window, it is a bit more
tricky.
I wrote a quick test to see if it would work...Here is the code I used:
The parent page:
<HTML>
<BODY>
<form name="test1" id="test1" method="POST" target="_blank"
action="testOpenerUpdate.html">
<INPUT type="submit" value="test setting window.opener URL">
</form>
<a href="javascript:window.open('testOpenerUpdate.html', 'testwindow',
location='yes')">test setting window.opener URL</a>
</BODY>
</HTML>
the child page (testOpenerUpdate.html):
<HTML>
<HEAD>
<SCRIPT language="JavaScript">
function setOpenerUrl(newUrl)
{
window.opener.document.location.replace(newUrl);
window.close();
}
</SCRIPT>
</HEAD>
<BODY>
<FORM name="myForm" id="myForm" method="POST">
<INPUT type="button" name="test" id="test"
onClick="setOpenerUrl('http://www.lycos.com')" value="send parent window to
lycos">
</FORM>
</BODY>
</HTML>
It appears that when submitting a form to a target '_blank', that the new window
is not actually a child of the current window. Therefore, you cannot refer back
to it. However, if you use a javascript, open() call, then you do create an
actual child.
I know that this is not a complete solution for you, but hopefully it is a step
in the right direction??
Pete
Linnea Ahlbeck wrote:
> Hi Pete!!
>
> This works, I didn´t know that I could use the target attribute in the
> <html:form> tag! Thanks! Do you also know how to specify the "old window" as
> target from the second window , I would like to return to the first window
> when the actions here are done?
>
> /Linnéa
>
> ----- Original Message -----
> From: "Craig R. McClanahan" <cr...@apache.org>
> To: <st...@jakarta.apache.org>
> Sent: Thursday, June 14, 2001 7:33 PM
> Subject: Re: struts-config.xml - How do I open a "success" path as a new
> window???
>
> On Thu, 14 Jun 2001, Peter Alfors wrote:
>
> >
> > What happens when you execute this?
> >
> > <td align="left"><a class="leftnav" href="myAction.do"
> > target="_blank"><bean:message key="icon.calendar"/></td>
> >
> > I would think that this should do what you want??
> >
>
> You can also use the "target" attribute on an <html:form> or <html:link>
> tag:
>
> <td align="left">
> <html:link styleclass="leftnav" page="/myAction.do"
> target="_blank">
> <bean:message key="icon.calendar"/>
> </html:link>
> </td>
>
> One advantage to this is that URL rewriting is automatically applied to
> maintain session state even if you're not using cookies.
>
> > Pete
> >
>
> Craig
>
> >
> > > -----Original Message-----
> > > From: Linnea Ahlbeck [mailto:linnea.ahlbeck@appium.com]
> > > Sent: Wednesday, June 13, 2001 1:52 AM
> > > To: struts-user@jakarta.apache.org
> > > Subject: struts-config.xml - How do I open a "success" path
> > > as a new window???
> > >
> > > Hi!!
> > >
> > > I want to my path
> > >
> > > <forward name="success" path="/InsertAddress.jsp"/>
> > >
> > > to open the jsp-page as a new window/page ( like the html
> > > tag
> > >
> > > <td align="left"><a class="leftnav" href="http://...../"
> > > target="_blank"><bean:message key="icon.calendar"/></td> )
> > >
> > > Any ideas how to do this with struts???
> > >
> > > Thanks / Linnéa
> > >
> > >
> > >
> >