You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2007/12/02 14:34:57 UTC

T5: Map and persistency

Hi,

One thing confuses me, here is a sample code:

 private Map<String, String> countryList;

 @Inject private DBServices dbServices;

  void pageLoaded() {
        countryList = dbServices.getCountryList();

without any Persist annotation, the countryList is persisted between
requests. if I move the above line to the constructor of the page class, it
has the same result. why?

A.C.
-- 
View this message in context: http://www.nabble.com/T5%3A-Map-and-persistency-tf4931665.html#a14115516
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: Map and persistency

Posted by Kevin Menard <km...@servprise.com>.
That's a different problem altogether.  You're not conditionally calling the
method, so it would have nothing to do with a cached value.  It has to do
with the page lifecycle events.  It would appear as though you do not want
to be using pageLoaded().

See http://tapestry.apache.org/tapestry5/tapestry-core/guide/lifecycle.html
for more details.



On 12/2/07 11:08 AM, in article 14116894.post@talk.nabble.com, "Angelo Chen"
<an...@yahoo.com.hk> wrote:

> 
> no, the getCountryList is a service that I put a log, the log displays that
> the method was called only once.
> 
> 
> nirvdrum wrote:
>> 
>> Are you sure it's persisted and not just repopulated by the time you check
>> it?
>> 
>> 
>> On 12/2/07 8:34 AM, in article 14115516.post@talk.nabble.com, "Angelo
>> Chen"
>> <an...@yahoo.com.hk> wrote:
>> 
>>> 
>>> Hi,
>>> 
>>> One thing confuses me, here is a sample code:
>>> 
>>>  private Map<String, String> countryList;
>>> 
>>>  @Inject private DBServices dbServices;
>>> 
>>>   void pageLoaded() {
>>>         countryList = dbServices.getCountryList();
>>> 
>>> without any Persist annotation, the countryList is persisted between
>>> requests. if I move the above line to the constructor of the page class,
>>> it
>>> has the same result. why?
>>> 
>>> A.C.
>> 
>> -- 
>> Kevin Menard
>> Servprise International, Inc.
>> Remote reboot & power control for network equipment
>> www.servprise.com              +1 508.892.3823 x308
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> 
>> 

-- 
Kevin Menard
Servprise International, Inc.
Remote reboot & power control for network equipment
www.servprise.com              +1 508.892.3823 x308



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


Re: T5: Map and persistency

Posted by Doublel <mo...@gmail.com>.
pageLoaded() is only loaded when the page is request FIRST time, after
compile  put the class into page pool, next request,  pageLoaded() method is
reloaded  from page pool directly.I thank pageLoaded() not execute after
FIRST time.

 this is my opinon.

2007/12/3, Angelo Chen <an...@yahoo.com.hk>:
>
>
> Hi,
> Sorry for not making it clear, here is a simple sample, my question is,
> why
> the countryList instantiated in the pageLoaded persist without a need to
> use
> @Persist? maybe what assigned in the pageLoaded are considered as default
> value like constructor? Thanks,
> A.C.
>
> public class Search {
>
>   private Map<String, String> countryList;
>   public Map<String, String> getCountryList() {
>         return countryList;
>     }
>
> void pageLoaded() {
>         countryList = new TreeMap<String, String>();
>         countryList.put("US", "USA");
>         countryList.put("HK", "Hong Kong");
>     }
> }
>
>
> Davor Hrg wrote:
> >
> > please post some more code,
> > I'm also unable to comprehend what the problem is ?
> >
> > Davor Hrg
> >
> > On Dec 2, 2007 5:08 PM, Angelo Chen <an...@yahoo.com.hk> wrote:
> >
> >>
> >> no, the getCountryList is a service that I put a log, the log displays
> >> that
> >> the method was called only once.
> >>
> >>
> >> nirvdrum wrote:
> >> >
> >> > Are you sure it's persisted and not just repopulated by the time you
> >> check
> >> > it?
> >> >
> >> >
> >> > On 12/2/07 8:34 AM, in article 14115516.post@talk.nabble.com, "Angelo
> >> > Chen"
> >> > <an...@yahoo.com.hk> wrote:
> >> >
> >> >>
> >> >> Hi,
> >> >>
> >> >> One thing confuses me, here is a sample code:
> >> >>
> >> >>  private Map<String, String> countryList;
> >> >>
> >> >>  @Inject private DBServices dbServices;
> >> >>
> >> >>   void pageLoaded() {
> >> >>         countryList = dbServices.getCountryList();
> >> >>
> >> >> without any Persist annotation, the countryList is persisted between
> >> >> requests. if I move the above line to the constructor of the page
> >> class,
> >> >> it
> >> >> has the same result. why?
> >> >>
> >> >> A.C.
> >> >
> >> > --
> >> > Kevin Menard
> >> > Servprise International, Inc.
> >> > Remote reboot & power control for network equipment
> >> > www.servprise.com              +1 508.892.3823 x308
> >> >
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> > For additional commands, e-mail: users-help@tapestry.apache.org
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/T5%3A-Map-and-persistency-tf4931665.html#a14116894
> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/T5%3A-Map-and-persistency-tf4931665.html#a14120628
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
得与失都是生活

Re: T5: Map and persistency

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi,
Sorry for not making it clear, here is a simple sample, my question is, why
the countryList instantiated in the pageLoaded persist without a need to use
@Persist? maybe what assigned in the pageLoaded are considered as default
value like constructor? Thanks,
A.C.

public class Search {

  private Map<String, String> countryList;
  public Map<String, String> getCountryList() {
        return countryList;
    }

 void pageLoaded() {
        countryList = new TreeMap<String, String>();
        countryList.put("US", "USA");
        countryList.put("HK", "Hong Kong");
    }
}


Davor Hrg wrote:
> 
> please post some more code,
> I'm also unable to comprehend what the problem is ?
> 
> Davor Hrg
> 
> On Dec 2, 2007 5:08 PM, Angelo Chen <an...@yahoo.com.hk> wrote:
> 
>>
>> no, the getCountryList is a service that I put a log, the log displays
>> that
>> the method was called only once.
>>
>>
>> nirvdrum wrote:
>> >
>> > Are you sure it's persisted and not just repopulated by the time you
>> check
>> > it?
>> >
>> >
>> > On 12/2/07 8:34 AM, in article 14115516.post@talk.nabble.com, "Angelo
>> > Chen"
>> > <an...@yahoo.com.hk> wrote:
>> >
>> >>
>> >> Hi,
>> >>
>> >> One thing confuses me, here is a sample code:
>> >>
>> >>  private Map<String, String> countryList;
>> >>
>> >>  @Inject private DBServices dbServices;
>> >>
>> >>   void pageLoaded() {
>> >>         countryList = dbServices.getCountryList();
>> >>
>> >> without any Persist annotation, the countryList is persisted between
>> >> requests. if I move the above line to the constructor of the page
>> class,
>> >> it
>> >> has the same result. why?
>> >>
>> >> A.C.
>> >
>> > --
>> > Kevin Menard
>> > Servprise International, Inc.
>> > Remote reboot & power control for network equipment
>> > www.servprise.com              +1 508.892.3823 x308
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/T5%3A-Map-and-persistency-tf4931665.html#a14116894
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-Map-and-persistency-tf4931665.html#a14120628
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: Map and persistency

Posted by Davor Hrg <hr...@gmail.com>.
please post some more code,
I'm also unable to comprehend what the problem is ?

Davor Hrg

On Dec 2, 2007 5:08 PM, Angelo Chen <an...@yahoo.com.hk> wrote:

>
> no, the getCountryList is a service that I put a log, the log displays
> that
> the method was called only once.
>
>
> nirvdrum wrote:
> >
> > Are you sure it's persisted and not just repopulated by the time you
> check
> > it?
> >
> >
> > On 12/2/07 8:34 AM, in article 14115516.post@talk.nabble.com, "Angelo
> > Chen"
> > <an...@yahoo.com.hk> wrote:
> >
> >>
> >> Hi,
> >>
> >> One thing confuses me, here is a sample code:
> >>
> >>  private Map<String, String> countryList;
> >>
> >>  @Inject private DBServices dbServices;
> >>
> >>   void pageLoaded() {
> >>         countryList = dbServices.getCountryList();
> >>
> >> without any Persist annotation, the countryList is persisted between
> >> requests. if I move the above line to the constructor of the page
> class,
> >> it
> >> has the same result. why?
> >>
> >> A.C.
> >
> > --
> > Kevin Menard
> > Servprise International, Inc.
> > Remote reboot & power control for network equipment
> > www.servprise.com              +1 508.892.3823 x308
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/T5%3A-Map-and-persistency-tf4931665.html#a14116894
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: T5: Map and persistency

Posted by Angelo Chen <an...@yahoo.com.hk>.
no, the getCountryList is a service that I put a log, the log displays that
the method was called only once.


nirvdrum wrote:
> 
> Are you sure it's persisted and not just repopulated by the time you check
> it?
> 
> 
> On 12/2/07 8:34 AM, in article 14115516.post@talk.nabble.com, "Angelo
> Chen"
> <an...@yahoo.com.hk> wrote:
> 
>> 
>> Hi,
>> 
>> One thing confuses me, here is a sample code:
>> 
>>  private Map<String, String> countryList;
>> 
>>  @Inject private DBServices dbServices;
>> 
>>   void pageLoaded() {
>>         countryList = dbServices.getCountryList();
>> 
>> without any Persist annotation, the countryList is persisted between
>> requests. if I move the above line to the constructor of the page class,
>> it
>> has the same result. why?
>> 
>> A.C.
> 
> -- 
> Kevin Menard
> Servprise International, Inc.
> Remote reboot & power control for network equipment
> www.servprise.com              +1 508.892.3823 x308
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-Map-and-persistency-tf4931665.html#a14116894
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: Map and persistency

Posted by Kevin Menard <km...@servprise.com>.
Are you sure it's persisted and not just repopulated by the time you check
it?


On 12/2/07 8:34 AM, in article 14115516.post@talk.nabble.com, "Angelo Chen"
<an...@yahoo.com.hk> wrote:

> 
> Hi,
> 
> One thing confuses me, here is a sample code:
> 
>  private Map<String, String> countryList;
> 
>  @Inject private DBServices dbServices;
> 
>   void pageLoaded() {
>         countryList = dbServices.getCountryList();
> 
> without any Persist annotation, the countryList is persisted between
> requests. if I move the above line to the constructor of the page class, it
> has the same result. why?
> 
> A.C.

-- 
Kevin Menard
Servprise International, Inc.
Remote reboot & power control for network equipment
www.servprise.com              +1 508.892.3823 x308



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


Re: T5: Map and persistency

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Filip,

I'm just a little confused with persist and default value, I think what we
instantiated/assigned in the padedLoaded are considered default value and it
will be used by T5 to reset private variables in the page, am I right?

This does bring up another topic, what is the best practice to create maps
for different Selects in a page? I'd prefer to set it up in the pageLoaded,
so that all users accessing same page does not have to incur the cost of
assignment again, is this a right assumption? Thanks,

A.C.


Filip S. Adamsen-2 wrote:
> 
> Hi Angelo,
> 
> pageLoaded is only executed when the page is first instantiated and 
> configured.
> 
> I think you might want to use pageAttached instead, which is executed 
> every time the page is attached to a new request.
> 
> http://tapestry.apache.org/tapestry5/tapestry-core/guide/lifecycle.html
> 
> -Filip
> 
> Angelo Chen skrev:
>> Hi,
>> 
>> One thing confuses me, here is a sample code:
>> 
>>  private Map<String, String> countryList;
>> 
>>  @Inject private DBServices dbServices;
>> 
>>   void pageLoaded() {
>>         countryList = dbServices.getCountryList();
>> 
>> without any Persist annotation, the countryList is persisted between
>> requests. if I move the above line to the constructor of the page class,
>> it
>> has the same result. why?
>> 
>> A.C.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-Map-and-persistency-tf4931665.html#a14122452
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: Map and persistency

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Filip,

I'm just a little confused with persist and default value, I think what we
instantiated/assigned in the padedLoaded are considered default value and it
will be used by T5 to reset private variables in the page, am I right?

This does bring up another topic, what is the best practice to create maps
for different Selects in a page? I'd prefer to set it up in the pageLoaded,
so that all users accessing same page does not have to incur the cost of
assignment again, is this a right assumption? Thanks,

A.C.


Filip S. Adamsen-2 wrote:
> 
> Hi Angelo,
> 
> pageLoaded is only executed when the page is first instantiated and 
> configured.
> 
> I think you might want to use pageAttached instead, which is executed 
> every time the page is attached to a new request.
> 
> http://tapestry.apache.org/tapestry5/tapestry-core/guide/lifecycle.html
> 
> -Filip
> 
> Angelo Chen skrev:
>> Hi,
>> 
>> One thing confuses me, here is a sample code:
>> 
>>  private Map<String, String> countryList;
>> 
>>  @Inject private DBServices dbServices;
>> 
>>   void pageLoaded() {
>>         countryList = dbServices.getCountryList();
>> 
>> without any Persist annotation, the countryList is persisted between
>> requests. if I move the above line to the constructor of the page class,
>> it
>> has the same result. why?
>> 
>> A.C.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-Map-and-persistency-tf4931665.html#a14122451
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: Map and persistency

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
Hi Angelo,

pageLoaded is only executed when the page is first instantiated and 
configured.

I think you might want to use pageAttached instead, which is executed 
every time the page is attached to a new request.

http://tapestry.apache.org/tapestry5/tapestry-core/guide/lifecycle.html

-Filip

Angelo Chen skrev:
> Hi,
> 
> One thing confuses me, here is a sample code:
> 
>  private Map<String, String> countryList;
> 
>  @Inject private DBServices dbServices;
> 
>   void pageLoaded() {
>         countryList = dbServices.getCountryList();
> 
> without any Persist annotation, the countryList is persisted between
> requests. if I move the above line to the constructor of the page class, it
> has the same result. why?
> 
> A.C.

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