You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by mfs <fa...@gmail.com> on 2007/10/22 08:17:51 UTC

Accessing PageMap ?

Guys,

A quick question..

How would i go about fetching a page (so as to access an attirbute within it
e.g. LoginPage with userId in it) which wicket by default stores in pageMap
(which in turn is stored in Session). I mean i think it wouldn't be a good
idea to store something in a session (even if its frequenly accessed/used)
given that is already being kept in session...like attributes on every-page.

Thanks and Regards,

Farhan.
-- 
View this message in context: http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13337422
Sent from the Wicket - User 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: Accessing PageMap ?

Posted by Eelco Hillenius <ee...@gmail.com>.
> > I GET your point, but what about scenarios where one has regular objects
> > (e.g. Person) mapped as a model using CompoundPropertyModel on a page,
> > wouldnt it be reasonable to access/use the same object (which would
> > already be stored in session since its part of the page)..rather than
> > storing it seperately ?  to access it at other pages..

Then you would pass either the object or the model. E.g:

setResponsePage(new AnotherPage(personModel));

or:

replaceWith(new SomeOtherPanel("myPanel", personModel));

when you use component replacement instead of page navigation.

Passing objects like that (and requiring them in page/ component
constructors) is good OO programming. Requiring your pages to know
about pages being stored in the session and containing certain objects
will get you into a mess pretty quickly.

The fact that Wicket stores pages (only the current one in fact, as
older pages are saved to second level cache, which is by default a
page file in a temp dir) should be regarded as an implementation
detail. It is completely up to the implementation of the session store
where page maps are being stored. Even the what page maps are used are
implementation details of the session store.

> > WELL i feel like there could be a lot of scenarios where one might need to
> > store things in session, just for the sake of example..like a cart in case
> > of a shopping-cart app (i know there can be other means to achieve the
> > same)..similarly there could be various other scenarios,

Sure, a shopping cart is another good example, unless the shopping
represents a really small part of your app. In the end, you decide
what you think is good for storing in your session and what is yours.

> just wondering if
> > there is a specific reason (with respect to wicket..) because of which u
> > are saying that one shouldnt store anything in the session ?

Generally, you don't want to keep objects much longer in memory then
needed. And besides that, it is just good programming practice to keep
the scope minimal; whether that applies to variables in loops or like
here the reach-ability of objects in general. It's better to keep
things as tidy as you can. And finally, if you have a page that for
instance requires a person object to be available to function right...
communicating that though requiring a person object to be passed in is
a lot clearer than expecting it's clients to put that object in the
session somewhere.

Eelco

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


Re: Accessing PageMap ?

Posted by Maurice Marrink <ma...@gmail.com>.
What johan means is that you don't have to call getUser in the
onbeginrequest because your pages will already call getUser. hence the
user will be lazily loaded and possibly not on every request, just
when you need to. As opposed to calling getUser in the onbeginrequest
where it will be loaded every time.

For example on page A you have a link to Page B which needs the user
object. There are two ways for page B to get the user object:
1. have the constructor of Page b accept the user as an argument. The
onclick of the link in page A would look like this setResponsePage(new
PageB(MyCustomRequestCycle.get().getUser()));

2. have the constructor of Page B get the user like this:
MyCustomRequestCycle.get().getUser();

As you can see there is no need to eagerly load the user in the
onbeginrequest because it will be loaded when it is needed.

Maurice

On 10/24/07, mfs <fa...@gmail.com> wrote:
>
> Well than may be i am misundertanding it...the getUser method than can be
> defined anywhere (i thought you were suggested in some specific class i.e.
> MyCustomRequestCycle which we would be overriding and hence onBeginRequst
> and onEnd)..and since we were talking in the context where we want to load
> the user-object on every-request thats why i was saying that putting in the
> onBeginRequest would be the way to go.
>
>
>
>
>
>
> Johan Compagner wrote:
> >
> > no why would that be onBeginRequest? calling getUser would be when you
> > need
> > in somewhere in your code
> >
> >
> >
> > On 10/23/07, mfs <fa...@gmail.com> wrote:
> >>
> >>
> >> Makes sense...and calling the getUser method when you need it, and that
> >> would
> >> onBeginRequest ?
> >>
> >> Farhan.
> >>
> >>
> >>
> >> Johan Compagner wrote:
> >> >
> >> > No it has Nothing to do with how wicket caches or something
> >> > Its just how hibernate tracks its own session objects
> >> > And an object that you load in one request with a hibernate session
> >> object
> >> > if you try to reuse that object in another one then that object of the
> >> > last
> >> > time is not attached to the hibernate session of this request
> >> > So you get a StaleObjectException or something like that don't know
> >> > exactly
> >> >
> >> > And what does the wicket Session impl have to do with how YOU use
> >> database
> >> > object in it
> >> > Its just an object in the http session. We don't touch or do anything
> >> with
> >> > the objects you put into it.
> >> >
> >> > And in this example it has nothing to do with wickets lazy lookup.  (by
> >> > using detachable models like LoadableDetachableModel)
> >> > because if you want a user that you want pretty much all your request
> >> then
> >> > store the userid in the wicket session
> >> > and then in your custom request cycle do this:
> >> > MyRequestCycle
> >> > {
> >> >         User user = null;
> >> >         getUser()
> >> >         {
> >> >                if (user == null)
> >> >                 {
> >> >                       user = dao.loadById(getSession().getUserId());
> >> >                 }
> >> >                return user;
> >> >         }
> >> > }
> >> >
> >> >
> >> >
> >> > On 10/23/07, mfs <fa...@gmail.com> wrote:
> >> >>
> >> >>
> >> >> So basically what you are saying is that caching hibernate object in
> >> >> wicket's
> >> >> session can cause issues with hibernate when using the cached
> >> >> object...either in the same request or any subsequent request..right ?
> >> I
> >> >> wonder if that has anything to do with wickets session impl, its just
> >> >> would
> >> >> be true for any web-framework ?
> >> >>
> >> >> Also can you point me to an article on wicket's lazy lookup ? I still
> >> >> dont
> >> >> completely follow you..
> >> >>
> >> >>
> >> >>
> >> >> Johan Compagner wrote:
> >> >> >
> >> >> >>
> >> >> >>
> >> >> >> sorry but I dont completely get your point on hibernate objects not
> >> >> >> attached
> >> >> >> to the current session...can you please elaborate..I mean given the
> >> >> >> context
> >> >> >> in discussion if lets say i stored hibernate objects in the current
> >> >> >> session,
> >> >> >> would that cause any issues..is that what you mean OR ??
> >> >> >
> >> >> >
> >> >> > Sorry current Hibernate sessions. If you want to use your Wicket
> >> >> session
> >> >> > cached object
> >> >> > again in hibernate in that request then you get hibernate errors.
> >> >> (because
> >> >> > it is not attached to the current hibernate session)
> >> >> >
> >> >> >
> >> >> >> YOU mean using the lazy mechanism at the hibernate layer ?
> >> >> >
> >> >> >
> >> >> >
> >> >> > no the lazy lookup is in wicket.
> >> >> > your request cycle has an method getUser() and only when you call
> >> that
> >> >> you
> >> >> > load it in
> >> >> > Then it can be cached by hibernate in the second level cache of
> >> >> hibernate.
> >> >> >
> >> >> > johan
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >> http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13354462
> >> >> Sent from the Wicket - User 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
> >> >>
> >> >>
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13370686
> >> Sent from the Wicket - User 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
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13375581
> Sent from the Wicket - User 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
>
>

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


Re: Accessing PageMap ?

Posted by mfs <fa...@gmail.com>.
Well than may be i am misundertanding it...the getUser method than can be
defined anywhere (i thought you were suggested in some specific class i.e.
MyCustomRequestCycle which we would be overriding and hence onBeginRequst
and onEnd)..and since we were talking in the context where we want to load
the user-object on every-request thats why i was saying that putting in the
onBeginRequest would be the way to go.






Johan Compagner wrote:
> 
> no why would that be onBeginRequest? calling getUser would be when you
> need
> in somewhere in your code
> 
> 
> 
> On 10/23/07, mfs <fa...@gmail.com> wrote:
>>
>>
>> Makes sense...and calling the getUser method when you need it, and that
>> would
>> onBeginRequest ?
>>
>> Farhan.
>>
>>
>>
>> Johan Compagner wrote:
>> >
>> > No it has Nothing to do with how wicket caches or something
>> > Its just how hibernate tracks its own session objects
>> > And an object that you load in one request with a hibernate session
>> object
>> > if you try to reuse that object in another one then that object of the
>> > last
>> > time is not attached to the hibernate session of this request
>> > So you get a StaleObjectException or something like that don't know
>> > exactly
>> >
>> > And what does the wicket Session impl have to do with how YOU use
>> database
>> > object in it
>> > Its just an object in the http session. We don't touch or do anything
>> with
>> > the objects you put into it.
>> >
>> > And in this example it has nothing to do with wickets lazy lookup.  (by
>> > using detachable models like LoadableDetachableModel)
>> > because if you want a user that you want pretty much all your request
>> then
>> > store the userid in the wicket session
>> > and then in your custom request cycle do this:
>> > MyRequestCycle
>> > {
>> >         User user = null;
>> >         getUser()
>> >         {
>> >                if (user == null)
>> >                 {
>> >                       user = dao.loadById(getSession().getUserId());
>> >                 }
>> >                return user;
>> >         }
>> > }
>> >
>> >
>> >
>> > On 10/23/07, mfs <fa...@gmail.com> wrote:
>> >>
>> >>
>> >> So basically what you are saying is that caching hibernate object in
>> >> wicket's
>> >> session can cause issues with hibernate when using the cached
>> >> object...either in the same request or any subsequent request..right ?
>> I
>> >> wonder if that has anything to do with wickets session impl, its just
>> >> would
>> >> be true for any web-framework ?
>> >>
>> >> Also can you point me to an article on wicket's lazy lookup ? I still
>> >> dont
>> >> completely follow you..
>> >>
>> >>
>> >>
>> >> Johan Compagner wrote:
>> >> >
>> >> >>
>> >> >>
>> >> >> sorry but I dont completely get your point on hibernate objects not
>> >> >> attached
>> >> >> to the current session...can you please elaborate..I mean given the
>> >> >> context
>> >> >> in discussion if lets say i stored hibernate objects in the current
>> >> >> session,
>> >> >> would that cause any issues..is that what you mean OR ??
>> >> >
>> >> >
>> >> > Sorry current Hibernate sessions. If you want to use your Wicket
>> >> session
>> >> > cached object
>> >> > again in hibernate in that request then you get hibernate errors.
>> >> (because
>> >> > it is not attached to the current hibernate session)
>> >> >
>> >> >
>> >> >> YOU mean using the lazy mechanism at the hibernate layer ?
>> >> >
>> >> >
>> >> >
>> >> > no the lazy lookup is in wicket.
>> >> > your request cycle has an method getUser() and only when you call
>> that
>> >> you
>> >> > load it in
>> >> > Then it can be cached by hibernate in the second level cache of
>> >> hibernate.
>> >> >
>> >> > johan
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >> http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13354462
>> >> Sent from the Wicket - User 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
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13370686
>> Sent from the Wicket - User 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
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13375581
Sent from the Wicket - User 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: Accessing PageMap ?

Posted by Johan Compagner <jc...@gmail.com>.
no why would that be onBeginRequest? calling getUser would be when you need
in somewhere in your code



On 10/23/07, mfs <fa...@gmail.com> wrote:
>
>
> Makes sense...and calling the getUser method when you need it, and that
> would
> onBeginRequest ?
>
> Farhan.
>
>
>
> Johan Compagner wrote:
> >
> > No it has Nothing to do with how wicket caches or something
> > Its just how hibernate tracks its own session objects
> > And an object that you load in one request with a hibernate session
> object
> > if you try to reuse that object in another one then that object of the
> > last
> > time is not attached to the hibernate session of this request
> > So you get a StaleObjectException or something like that don't know
> > exactly
> >
> > And what does the wicket Session impl have to do with how YOU use
> database
> > object in it
> > Its just an object in the http session. We don't touch or do anything
> with
> > the objects you put into it.
> >
> > And in this example it has nothing to do with wickets lazy lookup.  (by
> > using detachable models like LoadableDetachableModel)
> > because if you want a user that you want pretty much all your request
> then
> > store the userid in the wicket session
> > and then in your custom request cycle do this:
> > MyRequestCycle
> > {
> >         User user = null;
> >         getUser()
> >         {
> >                if (user == null)
> >                 {
> >                       user = dao.loadById(getSession().getUserId());
> >                 }
> >                return user;
> >         }
> > }
> >
> >
> >
> > On 10/23/07, mfs <fa...@gmail.com> wrote:
> >>
> >>
> >> So basically what you are saying is that caching hibernate object in
> >> wicket's
> >> session can cause issues with hibernate when using the cached
> >> object...either in the same request or any subsequent request..right ?
> I
> >> wonder if that has anything to do with wickets session impl, its just
> >> would
> >> be true for any web-framework ?
> >>
> >> Also can you point me to an article on wicket's lazy lookup ? I still
> >> dont
> >> completely follow you..
> >>
> >>
> >>
> >> Johan Compagner wrote:
> >> >
> >> >>
> >> >>
> >> >> sorry but I dont completely get your point on hibernate objects not
> >> >> attached
> >> >> to the current session...can you please elaborate..I mean given the
> >> >> context
> >> >> in discussion if lets say i stored hibernate objects in the current
> >> >> session,
> >> >> would that cause any issues..is that what you mean OR ??
> >> >
> >> >
> >> > Sorry current Hibernate sessions. If you want to use your Wicket
> >> session
> >> > cached object
> >> > again in hibernate in that request then you get hibernate errors.
> >> (because
> >> > it is not attached to the current hibernate session)
> >> >
> >> >
> >> >> YOU mean using the lazy mechanism at the hibernate layer ?
> >> >
> >> >
> >> >
> >> > no the lazy lookup is in wicket.
> >> > your request cycle has an method getUser() and only when you call
> that
> >> you
> >> > load it in
> >> > Then it can be cached by hibernate in the second level cache of
> >> hibernate.
> >> >
> >> > johan
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13354462
> >> Sent from the Wicket - User 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
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13370686
> Sent from the Wicket - User 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: Accessing PageMap ?

Posted by mfs <fa...@gmail.com>.
Makes sense...and calling the getUser method when you need it, and that would
onBeginRequest ?

Farhan.



Johan Compagner wrote:
> 
> No it has Nothing to do with how wicket caches or something
> Its just how hibernate tracks its own session objects
> And an object that you load in one request with a hibernate session object
> if you try to reuse that object in another one then that object of the
> last
> time is not attached to the hibernate session of this request
> So you get a StaleObjectException or something like that don't know
> exactly
> 
> And what does the wicket Session impl have to do with how YOU use database
> object in it
> Its just an object in the http session. We don't touch or do anything with
> the objects you put into it.
> 
> And in this example it has nothing to do with wickets lazy lookup.  (by
> using detachable models like LoadableDetachableModel)
> because if you want a user that you want pretty much all your request then
> store the userid in the wicket session
> and then in your custom request cycle do this:
> MyRequestCycle
> {
>         User user = null;
>         getUser()
>         {
>                if (user == null)
>                 {
>                       user = dao.loadById(getSession().getUserId());
>                 }
>                return user;
>         }
> }
> 
> 
> 
> On 10/23/07, mfs <fa...@gmail.com> wrote:
>>
>>
>> So basically what you are saying is that caching hibernate object in
>> wicket's
>> session can cause issues with hibernate when using the cached
>> object...either in the same request or any subsequent request..right ? I
>> wonder if that has anything to do with wickets session impl, its just
>> would
>> be true for any web-framework ?
>>
>> Also can you point me to an article on wicket's lazy lookup ? I still
>> dont
>> completely follow you..
>>
>>
>>
>> Johan Compagner wrote:
>> >
>> >>
>> >>
>> >> sorry but I dont completely get your point on hibernate objects not
>> >> attached
>> >> to the current session...can you please elaborate..I mean given the
>> >> context
>> >> in discussion if lets say i stored hibernate objects in the current
>> >> session,
>> >> would that cause any issues..is that what you mean OR ??
>> >
>> >
>> > Sorry current Hibernate sessions. If you want to use your Wicket
>> session
>> > cached object
>> > again in hibernate in that request then you get hibernate errors.
>> (because
>> > it is not attached to the current hibernate session)
>> >
>> >
>> >> YOU mean using the lazy mechanism at the hibernate layer ?
>> >
>> >
>> >
>> > no the lazy lookup is in wicket.
>> > your request cycle has an method getUser() and only when you call that
>> you
>> > load it in
>> > Then it can be cached by hibernate in the second level cache of
>> hibernate.
>> >
>> > johan
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13354462
>> Sent from the Wicket - User 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
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13370686
Sent from the Wicket - User 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: Accessing PageMap ?

Posted by Johan Compagner <jc...@gmail.com>.
No it has Nothing to do with how wicket caches or something
Its just how hibernate tracks its own session objects
And an object that you load in one request with a hibernate session object
if you try to reuse that object in another one then that object of the last
time is not attached to the hibernate session of this request
So you get a StaleObjectException or something like that don't know exactly

And what does the wicket Session impl have to do with how YOU use database
object in it
Its just an object in the http session. We don't touch or do anything with
the objects you put into it.

And in this example it has nothing to do with wickets lazy lookup.  (by
using detachable models like LoadableDetachableModel)
because if you want a user that you want pretty much all your request then
store the userid in the wicket session
and then in your custom request cycle do this:
MyRequestCycle
{
        User user = null;
        getUser()
        {
               if (user == null)
                {
                      user = dao.loadById(getSession().getUserId());
                }
               return user;
        }
}



On 10/23/07, mfs <fa...@gmail.com> wrote:
>
>
> So basically what you are saying is that caching hibernate object in
> wicket's
> session can cause issues with hibernate when using the cached
> object...either in the same request or any subsequent request..right ? I
> wonder if that has anything to do with wickets session impl, its just
> would
> be true for any web-framework ?
>
> Also can you point me to an article on wicket's lazy lookup ? I still dont
> completely follow you..
>
>
>
> Johan Compagner wrote:
> >
> >>
> >>
> >> sorry but I dont completely get your point on hibernate objects not
> >> attached
> >> to the current session...can you please elaborate..I mean given the
> >> context
> >> in discussion if lets say i stored hibernate objects in the current
> >> session,
> >> would that cause any issues..is that what you mean OR ??
> >
> >
> > Sorry current Hibernate sessions. If you want to use your Wicket session
> > cached object
> > again in hibernate in that request then you get hibernate errors.
> (because
> > it is not attached to the current hibernate session)
> >
> >
> >> YOU mean using the lazy mechanism at the hibernate layer ?
> >
> >
> >
> > no the lazy lookup is in wicket.
> > your request cycle has an method getUser() and only when you call that
> you
> > load it in
> > Then it can be cached by hibernate in the second level cache of
> hibernate.
> >
> > johan
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13354462
> Sent from the Wicket - User 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: Accessing PageMap ?

Posted by mfs <fa...@gmail.com>.
So basically what you are saying is that caching hibernate object in wicket's
session can cause issues with hibernate when using the cached
object...either in the same request or any subsequent request..right ? I
wonder if that has anything to do with wickets session impl, its just would
be true for any web-framework ?

Also can you point me to an article on wicket's lazy lookup ? I still dont
completely follow you..



Johan Compagner wrote:
> 
>>
>>
>> sorry but I dont completely get your point on hibernate objects not
>> attached
>> to the current session...can you please elaborate..I mean given the
>> context
>> in discussion if lets say i stored hibernate objects in the current
>> session,
>> would that cause any issues..is that what you mean OR ??
> 
> 
> Sorry current Hibernate sessions. If you want to use your Wicket session
> cached object
> again in hibernate in that request then you get hibernate errors. (because
> it is not attached to the current hibernate session)
> 
> 
>> YOU mean using the lazy mechanism at the hibernate layer ?
> 
> 
> 
> no the lazy lookup is in wicket.
> your request cycle has an method getUser() and only when you call that you
> load it in
> Then it can be cached by hibernate in the second level cache of hibernate.
> 
> johan
> 
> 

-- 
View this message in context: http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13354462
Sent from the Wicket - User 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: Accessing PageMap ?

Posted by Johan Compagner <jc...@gmail.com>.
>
>
> sorry but I dont completely get your point on hibernate objects not
> attached
> to the current session...can you please elaborate..I mean given the
> context
> in discussion if lets say i stored hibernate objects in the current
> session,
> would that cause any issues..is that what you mean OR ??


Sorry current Hibernate sessions. If you want to use your Wicket session
cached object
again in hibernate in that request then you get hibernate errors. (because
it is not attached to the current hibernate session)


> YOU mean using the lazy mechanism at the hibernate layer ?



no the lazy lookup is in wicket.
your request cycle has an method getUser() and only when you call that you
load it in
Then it can be cached by hibernate in the second level cache of hibernate.

johan

Re: Accessing PageMap ?

Posted by mfs <fa...@gmail.com>.
> if you want to cache it you can cache it in the session But for example
hibernate objects that are not > attached to the current session can give
shitty errors

sorry but I dont completely get your point on hibernate objects not attached
to the current session...can you please elaborate..I mean given the context
in discussion if lets say i stored hibernate objects in the current session,
would that cause any issues..is that what you mean OR ??

also caching of datatabase objects shouldn't be done in the web layer you
should use ehcache for that or something. and you don't have to load the
database object in the RequestCycle.onBegin you just can do it lazy when you
really need it.

YOU mean using the lazy mechanism at the hibernate layer ? 

THANKS for the quick follow-up
johan



On 10/22/07, mfs <fa...@gmail.com> wrote:
>
>
> Johan,
>
> I am wondering if it would be a good approach to load the User (or any
> required object) for every request (i beleive you meant to override the
> newRequestCycle() method and provide impl for
> WebRequestCycle.onBeginRequest
> and WebRequestCycle.onEndRequst) and subsequently load/unload the object
> (based on id) in the corresponding methods..wouldnt it be considered
> rather
> a heavier operation to perform on every request compared to just storing
> the
> complete object in the session, OR MAY be we can put in some condition in
> (onBegin/onEnd methods) where based on the requested page we determine
> whether the required object is to be loaded from the data-store or not,
> though i am not sure if it possible to put in such condition ?
>
> Please comment..
>
> Thanks and Regards,
>
> Farhan.
>
>
>
> Johan Compagner wrote:
> >
> >>
> >> > I GET your point, but what about scenarios where one has regular
> >> objects
> >> > (e.g. Person) mapped as a model using CompoundPropertyModel on a
> page,
> >> > wouldnt it be reasonable to access/use the same object (which would
> >> > already be stored in session since its part of the page)..rather than
> >> > storing it seperately ?  to access it at other pages..
> >
> >
> >
> > objects that should be shared over multiply request and pages should
> just
> > be
> > stored in the Wicket Session object.
> >
> > If you don't want the complete object in it. then store the id (in
> wicket
> > session) and make your custom request cycle load that once
> > for the request so that you could use it where ever you want
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13350486
> Sent from the Wicket - User 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
>
>



-- 
View this message in context: http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13352314
Sent from the Wicket - User 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: Accessing PageMap ?

Posted by Johan Compagner <jc...@gmail.com>.
if you want to cache it you can cache it in the session
But for example hibernate objects that are not attached to the current
session
can give shitty errors

also caching of datatabase objects shouldn't be done in the web layer you
should use ehcache for that or something.
and you don't have to load the database object in the RequestCycle.onBegin
you just can do it lazy when you really need it.

johan



On 10/22/07, mfs <fa...@gmail.com> wrote:
>
>
> Johan,
>
> I am wondering if it would be a good approach to load the User (or any
> required object) for every request (i beleive you meant to override the
> newRequestCycle() method and provide impl for
> WebRequestCycle.onBeginRequest
> and WebRequestCycle.onEndRequst) and subsequently load/unload the object
> (based on id) in the corresponding methods..wouldnt it be considered
> rather
> a heavier operation to perform on every request compared to just storing
> the
> complete object in the session, OR MAY be we can put in some condition in
> (onBegin/onEnd methods) where based on the requested page we determine
> whether the required object is to be loaded from the data-store or not,
> though i am not sure if it possible to put in such condition ?
>
> Please comment..
>
> Thanks and Regards,
>
> Farhan.
>
>
>
> Johan Compagner wrote:
> >
> >>
> >> > I GET your point, but what about scenarios where one has regular
> >> objects
> >> > (e.g. Person) mapped as a model using CompoundPropertyModel on a
> page,
> >> > wouldnt it be reasonable to access/use the same object (which would
> >> > already be stored in session since its part of the page)..rather than
> >> > storing it seperately ?  to access it at other pages..
> >
> >
> >
> > objects that should be shared over multiply request and pages should
> just
> > be
> > stored in the Wicket Session object.
> >
> > If you don't want the complete object in it. then store the id (in
> wicket
> > session) and make your custom request cycle load that once
> > for the request so that you could use it where ever you want
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13350486
> Sent from the Wicket - User 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: Accessing PageMap ?

Posted by mfs <fa...@gmail.com>.
Johan,

I am wondering if it would be a good approach to load the User (or any
required object) for every request (i beleive you meant to override the
newRequestCycle() method and provide impl for WebRequestCycle.onBeginRequest
and WebRequestCycle.onEndRequst) and subsequently load/unload the object
(based on id) in the corresponding methods..wouldnt it be considered rather
a heavier operation to perform on every request compared to just storing the
complete object in the session, OR MAY be we can put in some condition in
(onBegin/onEnd methods) where based on the requested page we determine
whether the required object is to be loaded from the data-store or not,
though i am not sure if it possible to put in such condition ? 

Please comment..

Thanks and Regards,

Farhan.



Johan Compagner wrote:
> 
>>
>> > I GET your point, but what about scenarios where one has regular
>> objects
>> > (e.g. Person) mapped as a model using CompoundPropertyModel on a page,
>> > wouldnt it be reasonable to access/use the same object (which would
>> > already be stored in session since its part of the page)..rather than
>> > storing it seperately ?  to access it at other pages..
> 
> 
> 
> objects that should be shared over multiply request and pages should just
> be
> stored in the Wicket Session object.
> 
> If you don't want the complete object in it. then store the id (in wicket
> session) and make your custom request cycle load that once
> for the request so that you could use it where ever you want
> 
> 

-- 
View this message in context: http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13350486
Sent from the Wicket - User 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: Accessing PageMap ?

Posted by Johan Compagner <jc...@gmail.com>.
>
> > I GET your point, but what about scenarios where one has regular objects
> > (e.g. Person) mapped as a model using CompoundPropertyModel on a page,
> > wouldnt it be reasonable to access/use the same object (which would
> > already be stored in session since its part of the page)..rather than
> > storing it seperately ?  to access it at other pages..



objects that should be shared over multiply request and pages should just be
stored in the Wicket Session object.

If you don't want the complete object in it. then store the id (in wicket
session) and make your custom request cycle load that once
for the request so that you could use it where ever you want

Re: Accessing PageMap ?

Posted by mfs <fa...@gmail.com>.

Eelco Hillenius wrote:
> 
>> How would i go about fetching a page (so as to access an attirbute within
>> it
>> e.g. LoginPage with userId in it)
> 
> You don't. Keep pages and components for representing your user
> interface, and work with regular objects to carry your 'business
> state'.
> 
> I GET your point, but what about scenarios where one has regular objects
> (e.g. Person) mapped as a model using CompoundPropertyModel on a page,
> wouldnt it be reasonable to access/use the same object (which would
> already be stored in session since its part of the page)..rather than
> storing it seperately ?  to access it at other pages..
> 
>> which wicket by default stores in pageMap
>> (which in turn is stored in Session). I mean i think it wouldn't be a
>> good
>> idea to store something in a session (even if its frequenly
>> accessed/used)
>> given that is already being kept in session...like attributes on
>> every-page.
> 
> You typically don't store anything in the session directly, unless it
> is something you'll readily want to have available throughout (like a
> User object that represents the currently logged in user).
> 
> WELL i feel like there could be a lot of scenarios where one might need to
> store things in session, just for the sake of example..like a cart in case
> of a shopping-cart app (i know there can be other means to achieve the
> same)..similarly there could be various other scenarios, just wondering if
> there is a specific reason (with respect to wicket..) because of which u
> are saying that one shouldnt store anything in the session ?
> 
> Take a look at for instance wicket-phonebook
> (http://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicket-phonebook)
> for a more 'real life' example of what an application with Wicket can
> look like. And/ or buy this book: http://www.manning.com/dashorst/ :-)
> 
> CERTAINLY plan to...thanks
> 
> Eelco
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Accessing-PageMap---tf4668934.html#a13338269
Sent from the Wicket - User 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: Accessing PageMap ?

Posted by Eelco Hillenius <ee...@gmail.com>.
> How would i go about fetching a page (so as to access an attirbute within it
> e.g. LoginPage with userId in it)

You don't. Keep pages and components for representing your user
interface, and work with regular objects to carry your 'business
state'.

> which wicket by default stores in pageMap
> (which in turn is stored in Session). I mean i think it wouldn't be a good
> idea to store something in a session (even if its frequenly accessed/used)
> given that is already being kept in session...like attributes on every-page.

You typically don't store anything in the session directly, unless it
is something you'll readily want to have available throughout (like a
User object that represents the currently logged in user).

Take a look at for instance wicket-phonebook
(http://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicket-phonebook)
for a more 'real life' example of what an application with Wicket can
look like. And/ or buy this book: http://www.manning.com/dashorst/ :-)

Eelco

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