IMHO removing final would be the correct thing: this could be useful in
case a user wants to do something on a page when they are redirected from
another. Sample use case.

1- I have a (mounted) page with some functionality.  I have used this page
for some e-mail or some URL user keep..
2- I have created a new page that handles functionality. I want to replace
old page with RedirectPage pointing to new implementation.
3- On new page I want to display some info in case user arrives to the page
coming from old page (and only in that case).

But I agree the above could also be achieve by "custom means"



On Thu, Feb 20, 2014 at 11:58 AM, Sven Meier <[email protected]> wrote:

> Since #onRedirect() is final currently, I'm +1 to remove IRedirectListener.
>
> Sven
>
>
> On 02/20/2014 11:03 AM, Martin Grigorov 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