Re: target _blank *and* refresh original page

Chuck Hill <[email protected]> Wed, 31 Aug 2011 20:23:00 -0700
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
Hi Ondra,

I don't think that you can do this with target.  If you use JavaScript =
to open the window:

    /**
     * @return JavaScript to open the pop-up or null if pop-up should =
not be shown
     */
    public String windowOpener()
    {
        String windowOpener =3D null;

        if (shouldOpenPopup)
        {
            // Stripped down, custom version of code in =
ERXJSOpenWindowHyperlink
            StringBuffer result =3D new StringBuffer();
            result.append("var win=3Dopen('");
            result.append(context().directActionURLForActionNamed("...", =
new NSDictionary(value, key)));
            ERXExtensions.addRandomizeDirectActionURL(result);

            result.append("','");
            result.append(name for window goes here);
            result.append("','");

            result.append("width=3D860");
            result.append(",height=3D650");
            result.append(",location=3Dno");
            result.append(",scrollbars=3Dno");
            result.append(",menubar=3Dno");
            result.append(",toolbar=3Dno");
            result.append(",titlebar=3Dno");
            result.append(",resizable=3Dyes");
            result.append(",dependant=3Dyes");
            result.append("'); ");
            result.append("win.focus(); ");
            windowOpener =3D result.toString();
        }
        shouldOpenPopup =3D false;

        return windowOpener;
    }

Then the popup can refer to the main window as window.opener in =
JavaScript (e.g. in the body onload event) to refresh it.


Chuck

On 2011-08-31, at 6:54 PM, Ond=C5=99ej =C4=8Cada wrote:

> Hello there,
>=20
> seems a rather usual task, but I can't find a decent solution nor =
google out one.
>=20
> I've got a WOHyperlink which returns something (through WORedirect, =
though I don't think that's important) in a new window -- i.e., I've set =
target=3D_blank in the WOHyperlink bindings.
>=20
> The trick is that I would need to refresh the original page too: my =
code looks more or less this way
>=20
> String theResult; // bound to a WOString in the page
> WOActionResults showFooInExtraPage() { // bound to a target=3D_blank =
WOHyperlink
>  WORedirect wor=3Dnew WORedirect(context());
>  wor.setUrl( ... computed somehow, irrelevant, works all right ...);
>  theResult=3D"Thanks for getting "+wor.url();
>  return wor;
> }
>=20
> How to make the original page to reflect the new theResult value =
automatically without waiting till the user does something to refresh it =
manually?
>=20
> About the best I can think of is to refresh the page all the time, but =
that would be *quite* ugly and inconvenient -- the user might not use =
the WOHyperlink at all, and it would seem highly weird to have the page =
refresh all the time without apparent reason :/
>=20
> Thanks a lot,
> ---
> Ondra =C4=8Cada
> OCSoftware:     [email protected]               http://www.ocs.cz
> private         [email protected]             http://www.ocs.cz/oc
>=20
>=20
>=20
> _______________________________________________
> WebObjects-dev mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/webobjects-dev

--=20
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall =
knowledge of WebObjects or who are trying to solve specific problems.   =20=

http://www.global-village.net/products/practical_webobjects