You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Bernard <bh...@gmail.com> on 2013/01/21 02:45:40 UTC

Passing IModel in Constructor of bookmarkable Page?

Hi all

I am searching for a robust pattern to work around
PageExpiredException.

My first idea was to have all pages bookmarkable and rely on
org.apache.wicket.settings.IPageSettings#getRecreateMountedPagesAfterExpiry()
to recover.

But this breaks when passing IModel in page constructors because then
pages are no longer bookmarkable.

Of course avoiding the constructor and letting Wicket create the page
with PageParameters would solve this problem but I want to avoid this.

It would be very useful to pass an IModel to a bookmarkable Page. How
can this be done?

I am trying to avoid expiring logout links (the primary driver of all
this). In case of page expiry I can deal with the exceptional call of
the default constructor from
IPageSettings#getRecreateMountedPagesAfterExpiry() by responding with
a bookmarkable page.

Many thanks,

Bernard



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


Re: Passing IModel in Constructor of bookmarkable Page?

Posted by Bernard <bh...@gmail.com>.
Hi Martin,

This is great.

Thanks for the quick response.

Bernard

On Mon, 21 Jan 2013 10:57:19 +0200, you wrote:

>You can pass the oldPageId as a request parameter too. Then use it: new
>PageReference(oldPageId.toInt()).getPage()
>
>
>On Mon, Jan 21, 2013 at 10:39 AM, Bernard <bh...@gmail.com> wrote:
>
>> Hi Martin,
>>
>> Thanks for the advice. So I will use PageParameters then and let
>> Wicket construct the page.
>>
>> But:
>>
>> I also have page constructors with PageReference parameter to link
>> back to. This would break bookmarkable as well. Would you have similar
>> concerns about PageReference?
>>
>> Kind Regards,
>>
>> Bernard
>>
>>
>> On Mon, 21 Jan 2013 10:05:57 +0200, you wrote:
>>
>> >Hi,
>> >
>> >I think using Page#Page(IModel) constructor is not very useful. It appears
>> >to be anti-pattern lately.
>> >There were several tickets related to ModalWindow when a model is shared
>> >between the page that contains the modal and the page inside the modal.
>> The
>> >two different pages are being serialized with different state of the model
>> >and after deserialization this model is no more the same instance anymore
>> >and the benefit of sharing a model is no more there.
>> >
>> >If you still want to go the way you want then check IPageFactory and its
>> >default impl - DefaultPageFactory.
>> >
>> >
>> >
>> >On Mon, Jan 21, 2013 at 3:45 AM, Bernard <bh...@gmail.com> wrote:
>> >
>> >> Hi all
>> >>
>> >> I am searching for a robust pattern to work around
>> >> PageExpiredException.
>> >>
>> >> My first idea was to have all pages bookmarkable and rely on
>> >>
>> >>
>> org.apache.wicket.settings.IPageSettings#getRecreateMountedPagesAfterExpiry()
>> >> to recover.
>> >>
>> >> But this breaks when passing IModel in page constructors because then
>> >> pages are no longer bookmarkable.
>> >>
>> >> Of course avoiding the constructor and letting Wicket create the page
>> >> with PageParameters would solve this problem but I want to avoid this.
>> >>
>> >> It would be very useful to pass an IModel to a bookmarkable Page. How
>> >> can this be done?
>> >>
>> >> I am trying to avoid expiring logout links (the primary driver of all
>> >> this). In case of page expiry I can deal with the exceptional call of
>> >> the default constructor from
>> >> IPageSettings#getRecreateMountedPagesAfterExpiry() by responding with
>> >> a bookmarkable page.
>> >>
>> >> Many thanks,
>> >>
>> >> Bernard
>> >>
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>


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


Re: Passing IModel in Constructor of bookmarkable Page?

Posted by yka <in...@jcoder.de>.
Well all this page stuff is not related to the topic in this thread.
Please open another thread for that.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Spring-tp4655546p4655570.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Passing IModel in Constructor of bookmarkable Page?

Posted by Martin Grigorov <mg...@apache.org>.
You can pass the oldPageId as a request parameter too. Then use it: new
PageReference(oldPageId.toInt()).getPage()


On Mon, Jan 21, 2013 at 10:39 AM, Bernard <bh...@gmail.com> wrote:

> Hi Martin,
>
> Thanks for the advice. So I will use PageParameters then and let
> Wicket construct the page.
>
> But:
>
> I also have page constructors with PageReference parameter to link
> back to. This would break bookmarkable as well. Would you have similar
> concerns about PageReference?
>
> Kind Regards,
>
> Bernard
>
>
> On Mon, 21 Jan 2013 10:05:57 +0200, you wrote:
>
> >Hi,
> >
> >I think using Page#Page(IModel) constructor is not very useful. It appears
> >to be anti-pattern lately.
> >There were several tickets related to ModalWindow when a model is shared
> >between the page that contains the modal and the page inside the modal.
> The
> >two different pages are being serialized with different state of the model
> >and after deserialization this model is no more the same instance anymore
> >and the benefit of sharing a model is no more there.
> >
> >If you still want to go the way you want then check IPageFactory and its
> >default impl - DefaultPageFactory.
> >
> >
> >
> >On Mon, Jan 21, 2013 at 3:45 AM, Bernard <bh...@gmail.com> wrote:
> >
> >> Hi all
> >>
> >> I am searching for a robust pattern to work around
> >> PageExpiredException.
> >>
> >> My first idea was to have all pages bookmarkable and rely on
> >>
> >>
> org.apache.wicket.settings.IPageSettings#getRecreateMountedPagesAfterExpiry()
> >> to recover.
> >>
> >> But this breaks when passing IModel in page constructors because then
> >> pages are no longer bookmarkable.
> >>
> >> Of course avoiding the constructor and letting Wicket create the page
> >> with PageParameters would solve this problem but I want to avoid this.
> >>
> >> It would be very useful to pass an IModel to a bookmarkable Page. How
> >> can this be done?
> >>
> >> I am trying to avoid expiring logout links (the primary driver of all
> >> this). In case of page expiry I can deal with the exceptional call of
> >> the default constructor from
> >> IPageSettings#getRecreateMountedPagesAfterExpiry() by responding with
> >> a bookmarkable page.
> >>
> >> Many thanks,
> >>
> >> Bernard
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: Passing IModel in Constructor of bookmarkable Page?

Posted by Bernard <bh...@gmail.com>.
Hi Martin,

Thanks for the advice. So I will use PageParameters then and let
Wicket construct the page.

But:

I also have page constructors with PageReference parameter to link
back to. This would break bookmarkable as well. Would you have similar
concerns about PageReference?

Kind Regards,

Bernard


On Mon, 21 Jan 2013 10:05:57 +0200, you wrote:

>Hi,
>
>I think using Page#Page(IModel) constructor is not very useful. It appears
>to be anti-pattern lately.
>There were several tickets related to ModalWindow when a model is shared
>between the page that contains the modal and the page inside the modal. The
>two different pages are being serialized with different state of the model
>and after deserialization this model is no more the same instance anymore
>and the benefit of sharing a model is no more there.
>
>If you still want to go the way you want then check IPageFactory and its
>default impl - DefaultPageFactory.
>
>
>
>On Mon, Jan 21, 2013 at 3:45 AM, Bernard <bh...@gmail.com> wrote:
>
>> Hi all
>>
>> I am searching for a robust pattern to work around
>> PageExpiredException.
>>
>> My first idea was to have all pages bookmarkable and rely on
>>
>> org.apache.wicket.settings.IPageSettings#getRecreateMountedPagesAfterExpiry()
>> to recover.
>>
>> But this breaks when passing IModel in page constructors because then
>> pages are no longer bookmarkable.
>>
>> Of course avoiding the constructor and letting Wicket create the page
>> with PageParameters would solve this problem but I want to avoid this.
>>
>> It would be very useful to pass an IModel to a bookmarkable Page. How
>> can this be done?
>>
>> I am trying to avoid expiring logout links (the primary driver of all
>> this). In case of page expiry I can deal with the exceptional call of
>> the default constructor from
>> IPageSettings#getRecreateMountedPagesAfterExpiry() by responding with
>> a bookmarkable page.
>>
>> Many thanks,
>>
>> Bernard
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>


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


Re: Passing IModel in Constructor of bookmarkable Page?

Posted by Bernard <bh...@gmail.com>.
Hi again, Martin.

I have thought about it. This dev list discussion is interesting. I
use static parameter converters in pages which is type safe but not
automatic.

I thought about your suggestion to use IPageFactory.

Suppose a page meets the constructor criteria(default, PageParameters)
for bookmarkable, and it is mapped.

We load it with

setResponsePage(new SomePage(someModel));

Now we get http://localhost:8080/wicket/page?2

because we did not do 

setResponsePage(SomePage.class, somePageParameters);

but we want to see

http://localhost:8080/SomeMountedBookmarkablePage?2

otherwise links break after expiry.

How do we get that?


Kind Regards,

Bernard


On Tue, 22 Jan 2013 10:16:42 +0200, you wrote:

>Hi,
>
>By default Wicket recognizes a page as bookmarkable if it has default
>constructor or a constructor with PageParameters as a single parameter.
>
>Check this thread that explains how you can do something similar as your
>requirement.
>http://markmail.org/thread/faoipbe6m6jh57ps
>
>
>On Tue, Jan 22, 2013 at 8:59 AM, Bernard <bh...@gmail.com> wrote:
>
>> Hi Martin,
>>
>> I now have second thoughts before replacing a page constructor having
>> an IModel parameter with the use of PageParameters which I need when
>> letting Wicket create the page. It can be a nightmare.
>>
>> Passing IModel server side on page constructon has many advantages. We
>> get security because the model cannot be manipulated by the client. We
>> get type safety because we don't need to wrap the model's key(s) into
>> PageParameters. And we get brevity and convenience which is a Wicket
>> plus. Could it be that expecting ModalWindow to have the same instance
>> as the parent page has to be seen in a different light?
>>
>> Please challenge me. I can't find at the moment any reference that
>> passing LDM in Page constructors is a bad thing. I always thought that
>> it is the Wicket way to exploit its statefulness.
>>
>> Back to the original subject, I would need a bookmarkable page that I
>> can still pass an IModel to - either in a constructor or via a
>> callback.
>>
>> So if the page is created from the bookmarkable URL and the page finds
>> that the session is expired then it cannot get the model from the
>> session but it can take corrective action. Otherwise we don't even
>> have a page because of the non-bookmarkable dilemma. This very
>> un-Wicket.
>>
>> In other words, if in a stateful web framework, we fail to identify
>> the page class (not its identity - it is expired) - only because we
>> were passing parameters to it server side - then this is a big issue
>> that would be rewarding to address. The framwork is completely blind
>> wrt to state even though the user can see the full state on the
>> screen.
>>
>> Should I open a Jira issue to address this?
>>
>> Kind Regards,
>>
>> Bernard
>>
>> On Mon, 21 Jan 2013 10:05:57 +0200, you wrote:
>>
>> >Hi,
>> >
>> >I think using Page#Page(IModel) constructor is not very useful. It appears
>> >to be anti-pattern lately.
>> >There were several tickets related to ModalWindow when a model is shared
>> >between the page that contains the modal and the page inside the modal.
>> The
>> >two different pages are being serialized with different state of the model
>> >and after deserialization this model is no more the same instance anymore
>> >and the benefit of sharing a model is no more there.
>> >
>> >If you still want to go the way you want then check IPageFactory and its
>> >default impl - DefaultPageFactory.
>> >
>> >
>> >
>> >On Mon, Jan 21, 2013 at 3:45 AM, Bernard <bh...@gmail.com> wrote:
>> >
>> >> Hi all
>> >>
>> >> I am searching for a robust pattern to work around
>> >> PageExpiredException.
>> >>
>> >> My first idea was to have all pages bookmarkable and rely on
>> >>
>> >>
>> org.apache.wicket.settings.IPageSettings#getRecreateMountedPagesAfterExpiry()
>> >> to recover.
>> >>
>> >> But this breaks when passing IModel in page constructors because then
>> >> pages are no longer bookmarkable.
>> >>
>> >> Of course avoiding the constructor and letting Wicket create the page
>> >> with PageParameters would solve this problem but I want to avoid this.
>> >>
>> >> It would be very useful to pass an IModel to a bookmarkable Page. How
>> >> can this be done?
>> >>
>> >> I am trying to avoid expiring logout links (the primary driver of all
>> >> this). In case of page expiry I can deal with the exceptional call of
>> >> the default constructor from
>> >> IPageSettings#getRecreateMountedPagesAfterExpiry() by responding with
>> >> a bookmarkable page.
>> >>
>> >> Many thanks,
>> >>
>> >> Bernard
>> >>
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>>
>>


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


Re: Passing IModel in Constructor of bookmarkable Page?

Posted by Bernard <bh...@gmail.com>.
Hi Martin,

I now have second thoughts before replacing a page constructor having
an IModel parameter with the use of PageParameters which I need when
letting Wicket create the page. It can be a nightmare.

Passing IModel server side on page constructon has many advantages. We
get security because the model cannot be manipulated by the client. We
get type safety because we don't need to wrap the model's key(s) into
PageParameters. And we get brevity and convenience which is a Wicket
plus. Could it be that expecting ModalWindow to have the same instance
as the parent page has to be seen in a different light?

Please challenge me. I can't find at the moment any reference that
passing LDM in Page constructors is a bad thing. I always thought that
it is the Wicket way to exploit its statefulness.

Back to the original subject, I would need a bookmarkable page that I
can still pass an IModel to - either in a constructor or via a
callback.

So if the page is created from the bookmarkable URL and the page finds
that the session is expired then it cannot get the model from the
session but it can take corrective action. Otherwise we don't even
have a page because of the non-bookmarkable dilemma. This very
un-Wicket.

In other words, if in a stateful web framework, we fail to identify
the page class (not its identity - it is expired) - only because we
were passing parameters to it server side - then this is a big issue
that would be rewarding to address. The framwork is completely blind
wrt to state even though the user can see the full state on the
screen.

Should I open a Jira issue to address this?

Kind Regards,

Bernard

On Mon, 21 Jan 2013 10:05:57 +0200, you wrote:

>Hi,
>
>I think using Page#Page(IModel) constructor is not very useful. It appears
>to be anti-pattern lately.
>There were several tickets related to ModalWindow when a model is shared
>between the page that contains the modal and the page inside the modal. The
>two different pages are being serialized with different state of the model
>and after deserialization this model is no more the same instance anymore
>and the benefit of sharing a model is no more there.
>
>If you still want to go the way you want then check IPageFactory and its
>default impl - DefaultPageFactory.
>
>
>
>On Mon, Jan 21, 2013 at 3:45 AM, Bernard <bh...@gmail.com> wrote:
>
>> Hi all
>>
>> I am searching for a robust pattern to work around
>> PageExpiredException.
>>
>> My first idea was to have all pages bookmarkable and rely on
>>
>> org.apache.wicket.settings.IPageSettings#getRecreateMountedPagesAfterExpiry()
>> to recover.
>>
>> But this breaks when passing IModel in page constructors because then
>> pages are no longer bookmarkable.
>>
>> Of course avoiding the constructor and letting Wicket create the page
>> with PageParameters would solve this problem but I want to avoid this.
>>
>> It would be very useful to pass an IModel to a bookmarkable Page. How
>> can this be done?
>>
>> I am trying to avoid expiring logout links (the primary driver of all
>> this). In case of page expiry I can deal with the exceptional call of
>> the default constructor from
>> IPageSettings#getRecreateMountedPagesAfterExpiry() by responding with
>> a bookmarkable page.
>>
>> Many thanks,
>>
>> Bernard
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>


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


Re: Passing IModel in Constructor of bookmarkable Page?

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

I think using Page#Page(IModel) constructor is not very useful. It appears
to be anti-pattern lately.
There were several tickets related to ModalWindow when a model is shared
between the page that contains the modal and the page inside the modal. The
two different pages are being serialized with different state of the model
and after deserialization this model is no more the same instance anymore
and the benefit of sharing a model is no more there.

If you still want to go the way you want then check IPageFactory and its
default impl - DefaultPageFactory.



On Mon, Jan 21, 2013 at 3:45 AM, Bernard <bh...@gmail.com> wrote:

> Hi all
>
> I am searching for a robust pattern to work around
> PageExpiredException.
>
> My first idea was to have all pages bookmarkable and rely on
>
> org.apache.wicket.settings.IPageSettings#getRecreateMountedPagesAfterExpiry()
> to recover.
>
> But this breaks when passing IModel in page constructors because then
> pages are no longer bookmarkable.
>
> Of course avoiding the constructor and letting Wicket create the page
> with PageParameters would solve this problem but I want to avoid this.
>
> It would be very useful to pass an IModel to a bookmarkable Page. How
> can this be done?
>
> I am trying to avoid expiring logout links (the primary driver of all
> this). In case of page expiry I can deal with the exceptional call of
> the default constructor from
> IPageSettings#getRecreateMountedPagesAfterExpiry() by responding with
> a bookmarkable page.
>
> Many thanks,
>
> Bernard
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>