You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by mscoon <ms...@gmail.com> on 2019/11/21 12:44:27 UTC

Opening a stateful page in a new window/tab with ajax

Hi all,

We are using the following code inside an ajax callback to create a new
page and open it in a new window. Are there any gotchas with respect to how
we create MyPage and get the url for it? Is it guaranteed to be found in
the user's session when the request for it comes in?

void openPageInNewWindow(AjaxRequestTarget target) {
    Page pg = new MyPage();
    String url = urlFor(new RenderPageRequestHandler(new
PageProvider(pg))).toString();
     target.appendJavaScript("window.open(\"" + url + "\")");
}

Is there a better way to do this?

Note that we don't want to use a BookmarkablePage page as an alternative.
We want the new page to be instantiated inside the ajax callback.

Thank you in advance,
Marios

Re: Opening a stateful page in a new window/tab with ajax

Posted by mscoon <ms...@gmail.com>.
Thanks for the prompt answer.

On Thu, Nov 21, 2019 at 6:38 PM Sven Meier <sv...@meiers.net> wrote:

> Hi,
>
> that's a perfectly valid usage.
>
> Have fun
> Sven
>
>
> On 21.11.19 13:44, mscoon wrote:
> > Hi all,
> >
> > We are using the following code inside an ajax callback to create a new
> > page and open it in a new window. Are there any gotchas with respect to
> how
> > we create MyPage and get the url for it? Is it guaranteed to be found in
> > the user's session when the request for it comes in?
> >
> > void openPageInNewWindow(AjaxRequestTarget target) {
> >      Page pg = new MyPage();
> >      String url = urlFor(new RenderPageRequestHandler(new
> > PageProvider(pg))).toString();
> >       target.appendJavaScript("window.open(\"" + url + "\")");
> > }
> >
> > Is there a better way to do this?
> >
> > Note that we don't want to use a BookmarkablePage page as an alternative.
> > We want the new page to be instantiated inside the ajax callback.
> >
> > Thank you in advance,
> > Marios
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Opening a stateful page in a new window/tab with ajax

Posted by Sven Meier <sv...@meiers.net>.
Hi,

that's a perfectly valid usage.

Have fun
Sven


On 21.11.19 13:44, mscoon wrote:
> Hi all,
>
> We are using the following code inside an ajax callback to create a new
> page and open it in a new window. Are there any gotchas with respect to how
> we create MyPage and get the url for it? Is it guaranteed to be found in
> the user's session when the request for it comes in?
>
> void openPageInNewWindow(AjaxRequestTarget target) {
>      Page pg = new MyPage();
>      String url = urlFor(new RenderPageRequestHandler(new
> PageProvider(pg))).toString();
>       target.appendJavaScript("window.open(\"" + url + "\")");
> }
>
> Is there a better way to do this?
>
> Note that we don't want to use a BookmarkablePage page as an alternative.
> We want the new page to be instantiated inside the ajax callback.
>
> Thank you in advance,
> Marios
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org