Martin,

Glad to be of some help. Also markup of RedirectPage.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd";>
<html xmlns:wicket="http://wicket.apache.org";><head><meta
wicket:id="redirect" http-equiv="refresh" content="0;
url=app"/></head></html>

might be "improved" to

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd";>
<html xmlns:wicket="http://wicket.apache.org";>
<head><meta wicket:id="redirect" http-equiv="refresh" content="0;
url=app"/></head>
<body>
    <wicket:child/>
</body>
</html>

So that redirect page can be sub classed without the need to copy and paste
header? Maybe also get rid of the final on Page? So, what one can actually
do something on onRedirect(). e.g display a popup "Welcome to our new way
of handling bla...." for users that get redirected to a page (and not show
it for user entering directly to the page). Maybe I can help and  cook a
little example for sample application.



On Thu, Feb 20, 2014 at 11:03 AM, Martin Grigorov <[email protected]>wrote:

> I've missed RedirectPage in my search the first time. Thanks!
>
> Here is a better version:
>
> diff --git
>
> i/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/RedirectPage.java
>
> w/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/RedirectPage.java
> index 9b60bea..57f6f1f 100644
> ---
>
> i/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/RedirectPage.java
> +++
>
> w/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/RedirectPage.java
> @@ -17,8 +17,9 @@
>  package org.apache.wicket.markup.html.pages;
>
>  import org.apache.wicket.AttributeModifier;
> -import org.apache.wicket.IRedirectListener;
>  import org.apache.wicket.Page;
> +import org.apache.wicket.core.request.handler.PageProvider;
> +import org.apache.wicket.core.request.handler.RenderPageRequestHandler;
>  import org.apache.wicket.markup.html.WebMarkupContainer;
>  import org.apache.wicket.markup.html.WebPage;
>  import org.apache.wicket.model.Model;
> @@ -57,7 +58,7 @@ public class RedirectPage extends WebPage
>         {
>                 final WebMarkupContainer redirect = new
> WebMarkupContainer("redirect");
>                 final String content = waitBeforeRedirectInSeconds +
> ";URL=" + url;
> -               redirect.add(new AttributeModifier("content", new
> Model<String>(content)));
> +               redirect.add(new AttributeModifier("content", new
> Model<>(content)));
>                 add(redirect);
>         }
>
> @@ -69,7 +70,7 @@ public class RedirectPage extends WebPage
>          */
>         public RedirectPage(final Page page)
>         {
> -               this(page.urlFor(IRedirectListener.INTERFACE,
> page.getPageParameters()), 0);
> +               this(page, 0);
>         }
>
>         /**
> @@ -83,7 +84,7 @@ public class RedirectPage extends WebPage
>          */
>         public RedirectPage(final Page page, final int
> waitBeforeRedirectInSeconds)
>         {
> -               this(page.urlFor(IRedirectListener.INTERFACE,
> page.getPageParameters()),
> +               this(page.urlFor(new RenderPageRequestHandler(new
> PageProvider(page))),
>                         waitBeforeRedirectInSeconds);
>         }
>
>
> I think it is better because it will create a "nice looking" url if there
> is #mountPage() for this page.
>
> Martin Grigorov
> Wicket Training and Consulting
>
>
> On Thu, Feb 20, 2014 at 11:52 AM, Ernesto Reinaldo Barreiro <
> [email protected]> wrote:
>
> > Martin,
> >
> > I cannot find where IRedirectListener#onRedirect is actually called
> except
> > when page is visited via RedirectPage... So, to me is just a marker...
> > Maybe making it not final might make sense as a page could do something
> > when some other RedirectPage redirects to it?
> >
> >
> > On Thu, Feb 20, 2014 at 10:30 AM, Martin Grigorov <[email protected]
> > >wrote:
> >
> > > Hi,
> > >
> > > I have the following patch here:
> > >
> > > -public abstract class Page extends MarkupContainer implements
> > > IRedirectListener, IRequestablePage
> > > +public abstract class Page extends MarkupContainer implements
> > > IRequestablePage
> > >  {
> > >         /** True if the page hierarchy has been modified in the current
> > > request. */
> > >         private static final int FLAG_IS_DIRTY = FLAG_RESERVED3;
> > > @@ -497,16 +497,6 @@ public abstract class Page extends MarkupContainer
> > > implements IRedirectListener,
> > >         }
> > >
> > >         /**
> > > -        * Redirect to this page.
> > > -        *
> > > -        * @see org.apache.wicket.IRedirectListener#onRedirect()
> > > -        */
> > > -       @Override
> > > -       public final void onRedirect()
> > > -       {
> > > -       }
> > > -
> > >
> > >
> > > o.a.w.Page currently implements IRedirectListener but does nothing in
> > > #onRedirect() and the method is final.
> > > What is the idea here ? Maybe to forbid page specializations to use
> > > IRedirectListener ?!
> > >
> > > With my patch there are no other implementations of IRedirectListener,
> so
> > > we can remove it completely. Can you imagine a use case when IRL is
> > needed
> > > ?
> > >
> > >
> > > Martin Grigorov
> > > Wicket Training and Consulting
> > >
> >
> >
> >
> > --
> > Regards - Ernesto Reinaldo Barreiro
> >
>



-- 
Regards - Ernesto Reinaldo Barreiro

Reply via email to