You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by tomask79 <to...@embedit.cz> on 2013/11/12 10:28:39 UTC

Page recreation if page has expired problem....

Hi guys,

since wicket 1.5 we can use "recreate page if page has expired" option in
the page settings in order to avoid page expirations. I tried that, but it
doesn't restore PageParameters, so it is useless for us...

So I wrote my own PageInstanceMapper with overrided mapRequest method:

public IRequestHandler mapRequest(Request request) {
 Url url = request.getUrl();
        IRequestHandler resultRequestHandler = null;
        if (matches(url))
        {
            PageComponentInfo info = getPageComponentInfo(url);
            if (info != null && info.getPageInfo().getPageId() != null)
            {
                Integer renderCount = info.getComponentInfo() != null ?
info.getComponentInfo()
                        .getRenderCount() : null;

                if (info.getComponentInfo() == null)
                {
                    PageProvider provider = new
PageProvider(info.getPageInfo().getPageId(),
                            renderCount);
                    provider.setPageSource(getContext());
                    // render page
                    resultRequestHandler = new
RenderPageRequestHandler(provider);
                }
                else
                {
                    ComponentInfo componentInfo = info.getComponentInfo();

                    PageAndComponentProvider provider = new
PageAndComponentProvider(
                            info.getPageInfo().getPageId(), renderCount,
                            componentInfo.getComponentPath());

                    // my method to test whether page is in the storage....
                    if (!isPageResolvable(info.getPageInfo().getPageId(),
provider)) {
                        provider = new PageAndComponentProvider(<pageClass
to restore>,
                                <page params to restore>,
componentInfo.getComponentPath());
                    }

                    provider.setPageSource(getContext());

                    // listener interface
                    RequestListenerInterface listenerInterface =
requestListenerInterfaceFromString(componentInfo.getListenerInterface());

                    resultRequestHandler = new
ListenerInterfaceRequestHandler(provider, listenerInterface,
                            componentInfo.getBehaviorId());
                }
            }
        }
        return resultRequestHandler;
}


In this way PageProvider knows exactly howto recreate the page properly,
it's working great.....But if the recreated page contains forms, all entered
data are lost...:-(((

Is there any way of reconstructing the page without loosing the entered form
input?

thanks a lot in advance

T.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Page-recreation-if-page-has-expired-problem-tp4662339.html
Sent from the Forum for Wicket Core developers mailing list archive at Nabble.com.

Re: Page recreation if page has expired problem....

Posted by tomask79 <to...@embedit.cz>.
Hi Martin,

thanks a lot for answer.

Yes, saving form data in the session and use them when recreating the page
eventually is one of the options I'm thinking about.

To the context, we now support working in the multiple browser tabs in our
wicket application, but we also want to use some page eviction strategy to
not to keep all of the browsed pages in the session....which is problematic
when working in multiple tabs....So I was looking for the way of recreating
pages when IDataStore holding just N last pages would be overflowed.

Another option seems to be to allow users to open just N browser tabs...

well, thanks again for answer and for your work at wicket framework

Tomas








--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Page-recreation-if-page-has-expired-problem-tp4662339p4662427.html
Sent from the Forum for Wicket Core developers mailing list archive at Nabble.com.

Re: Page recreation if page has expired problem....

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

You should ask your questions in users@ mailing list.


On Tue, Nov 12, 2013 at 11:28 AM, tomask79 <to...@embedit.cz> wrote:

> Hi guys,
>
> since wicket 1.5 we can use "recreate page if page has expired" option in
> the page settings in order to avoid page expirations. I tried that, but it
> doesn't restore PageParameters, so it is useless for us...
>
> So I wrote my own PageInstanceMapper with overrided mapRequest method:
>
> public IRequestHandler mapRequest(Request request) {
>  Url url = request.getUrl();
>         IRequestHandler resultRequestHandler = null;
>         if (matches(url))
>         {
>             PageComponentInfo info = getPageComponentInfo(url);
>             if (info != null && info.getPageInfo().getPageId() != null)
>             {
>                 Integer renderCount = info.getComponentInfo() != null ?
> info.getComponentInfo()
>                         .getRenderCount() : null;
>
>                 if (info.getComponentInfo() == null)
>                 {
>                     PageProvider provider = new
> PageProvider(info.getPageInfo().getPageId(),
>                             renderCount);
>                     provider.setPageSource(getContext());
>                     // render page
>                     resultRequestHandler = new
> RenderPageRequestHandler(provider);
>                 }
>                 else
>                 {
>                     ComponentInfo componentInfo = info.getComponentInfo();
>
>                     PageAndComponentProvider provider = new
> PageAndComponentProvider(
>                             info.getPageInfo().getPageId(), renderCount,
>                             componentInfo.getComponentPath());
>
>                     // my method to test whether page is in the storage....
>                     if (!isPageResolvable(info.getPageInfo().getPageId(),
> provider)) {
>                         provider = new PageAndComponentProvider(<pageClass
> to restore>,
>                                 <page params to restore>,
> componentInfo.getComponentPath());
>                     }
>
>                     provider.setPageSource(getContext());
>
>                     // listener interface
>                     RequestListenerInterface listenerInterface =
> requestListenerInterfaceFromString(componentInfo.getListenerInterface());
>
>                     resultRequestHandler = new
> ListenerInterfaceRequestHandler(provider, listenerInterface,
>                             componentInfo.getBehaviorId());
>                 }
>             }
>         }
>         return resultRequestHandler;
> }
>
>
> In this way PageProvider knows exactly howto recreate the page properly,
> it's working great.....But if the recreated page contains forms, all
> entered
> data are lost...:-(((
>
> Is there any way of reconstructing the page without loosing the entered
> form
> input?
>

My answer is YES and NO.
You can store the missing data in the Session and use it when
restoring/re-creating a page.

It will *not* work in the case when PageExpiredException is due to session
expiration. In this case there is no way to associate the old (POST) data
to a new request.

It will work in the cases when PageExpiredException is caused by:
- IDataStore (disk store) overflow. In this case older page may be removed
to be able to store a newer page
- page not stored error. This may happen is something went bad when Wicket
serializes the page. Trying to load the page later from IDataStore will
lead to "page not found" error


>
> thanks a lot in advance
>
> T.
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Page-recreation-if-page-has-expired-problem-tp4662339.html
> Sent from the Forum for Wicket Core developers mailing list archive at
> Nabble.com.
>