You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "X. Y. Zhao" <x....@gmail.com> on 2005/08/18 01:01:27 UTC

Persistent property initialization in Tapestry 4

I have a very simple page with a persistent property:

public abstract class Sample implements PageBeginRenderListener {
  private static final Log LOG = LogFactory.getLog(Register.class);
  @Persist
  public abstract DataObject getData();
  public abstract void setData(DataObject data);
  public void pageBeginRender(PageEvent event) {
   if (null == getData()) {
    LOG.debug("NEW persist");
    setData(new DataObject());
   }
  }
}

When i refresh the page for the first, second, or even third time, i  
see that pageBeginRender is re-initializing my persistent property!   
However, after three or four page refreshes, it seems like the  
property has been persisted OK.

Is this the correct way of initializing my persistent property?

  Thanks

-- X. Y. ZHAO



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


loading global configuration in Tapestry3 and the usage of org.apache.tapestry.property-source

Posted by sean gao secpay <se...@secpay.com>.
<Question 1>
I would like load  configurable global properties  in my application
These are name/value pairs such as
   tempfolder.path=/home/users/temp
   default.color=white
stored in .properties files or in a database.

Ideally I would like to be able to set something like this in the 
application specification file
    <property name="org.apache.tapestry.global-config">
        config.properties{,config2.properties,config3.properties}
    </property>
But this seems to be impossible without patching tapestry3

Guess I could extend  BaseEngine or define a custom version of Global .
Just wondering which is the common way of achieving this in tapestry?

<Question 2>
It is mentioned in the user guide  
http://jakarta.apache.org/tapestry/3.0.3/doc/TapestryUsersGuide/configuration.extensions.html
"  org.apache.tapestry.property-source (IPropertySource 
<../api/org/apache/tapestry/engine/IPropertySource.html>)
     This extension is fit into the configuration property search path, 
after the servlet context, but before JVM system           properties. A 
typical use would be to access some set of configuration properties 
stored in a database.
"
Can anyone give an example?

Thanks
Sean

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


Re: Persistent property initialization in Tapestry 4

Posted by "X. Y. Zhao" <x....@gmail.com>.
Yes.  You are very right.  Thank you.


On 17-Aug-05, at 191653, Patrick Casey wrote:

>
>     The question I'm asking though is this what's happening?
>
>     You click page foo.
>     Tapestry creates instance #1 of page foo, initialized variables.
>     You click page foo again.
>     Tapestry creates instance #2 of page foo, initialized variables.
>     You click page foo yet again.
>     Tapestry pulls instance #1 of page foo out of page pool. No second
> initialization takes place.
>
>     In other words, are you running into a case where you're assuming
> the page object you get for interaction #2 is the same page object  
> you got
> for interaction #1?
>
>     --- Pat
>
>
>> -----Original Message-----
>> From: X. Y. Zhao [mailto:x.y.zhao.88@gmail.com]
>> Sent: Wednesday, August 17, 2005 4:11 PM
>> To: Tapestry users
>> Subject: Re: Persistent property initialization in Tapestry 4
>>
>> If i set the property, and the output it's value, it is the same for
>> the first few refreshes, even though i change them within my class.
>> But like i said, after the first few refreshes, the changes persist.
>>
>> On 17-Aug-05, at 190504, Patrick Casey wrote:
>>
>>
>>>
>>>     Are you sure you're seeing re-initialization of *exactly* the  
>>> same
>>> page object? Or is tapestry just creating 3 or 4 pages to fill up
>>> the page
>>> pool and subsequent to that you're pulling things out of pool? In
>>> other
>>> words are the first few refreshes really using the same page, or
>>> are they
>>> causing a new page to be generated?
>>>
>>>     --- Pat
>>>
>>>
>>>
>>>> -----Original Message-----
>>>> From: X. Y. Zhao [mailto:x.y.zhao.88@gmail.com]
>>>> Sent: Wednesday, August 17, 2005 4:01 PM
>>>> To: Tapestry users
>>>> Subject: Persistent property initialization in Tapestry 4
>>>>
>>>> I have a very simple page with a persistent property:
>>>>
>>>> public abstract class Sample implements PageBeginRenderListener {
>>>>   private static final Log LOG = LogFactory.getLog(Register.class);
>>>>   @Persist
>>>>   public abstract DataObject getData();
>>>>   public abstract void setData(DataObject data);
>>>>   public void pageBeginRender(PageEvent event) {
>>>>    if (null == getData()) {
>>>>     LOG.debug("NEW persist");
>>>>     setData(new DataObject());
>>>>    }
>>>>   }
>>>> }
>>>>
>>>> When i refresh the page for the first, second, or even third  
>>>> time, i
>>>> see that pageBeginRender is re-initializing my persistent property!
>>>> However, after three or four page refreshes, it seems like the
>>>> property has been persisted OK.
>>>>
>>>> Is this the correct way of initializing my persistent property?
>>>>
>>>>   Thanks
>>>>
>>>> -- X. Y. ZHAO
>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------- 
>>>> --
>>>> To unsubscribe, e-mail: tapestry-user- 
>>>> unsubscribe@jakarta.apache.org
>>>> For additional commands, e-mail: tapestry-user-
>>>> help@jakarta.apache.org
>>>>
>>>>
>>>
>>>
>>>
>>>
>>> -------------------------------------------------------------------- 
>>> -
>>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: tapestry-user- 
>>> help@jakarta.apache.org
>>>
>>>
>>>
>>
>> -- X. Y. ZHAO
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user- 
>> help@jakarta.apache.org
>>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

-- X. Y. ZHAO



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


RE: Persistent property initialization in Tapestry 4

Posted by Patrick Casey <pa...@adelphia.net>.
	The question I'm asking though is this what's happening?

	You click page foo.
	Tapestry creates instance #1 of page foo, initialized variables.
	You click page foo again.
	Tapestry creates instance #2 of page foo, initialized variables.
	You click page foo yet again.
	Tapestry pulls instance #1 of page foo out of page pool. No second
initialization takes place.

	In other words, are you running into a case where you're assuming
the page object you get for interaction #2 is the same page object you got
for interaction #1?

	--- Pat

> -----Original Message-----
> From: X. Y. Zhao [mailto:x.y.zhao.88@gmail.com]
> Sent: Wednesday, August 17, 2005 4:11 PM
> To: Tapestry users
> Subject: Re: Persistent property initialization in Tapestry 4
> 
> If i set the property, and the output it's value, it is the same for
> the first few refreshes, even though i change them within my class.
> But like i said, after the first few refreshes, the changes persist.
> 
> On 17-Aug-05, at 190504, Patrick Casey wrote:
> 
> >
> >     Are you sure you're seeing re-initialization of *exactly* the same
> > page object? Or is tapestry just creating 3 or 4 pages to fill up
> > the page
> > pool and subsequent to that you're pulling things out of pool? In
> > other
> > words are the first few refreshes really using the same page, or
> > are they
> > causing a new page to be generated?
> >
> >     --- Pat
> >
> >
> >> -----Original Message-----
> >> From: X. Y. Zhao [mailto:x.y.zhao.88@gmail.com]
> >> Sent: Wednesday, August 17, 2005 4:01 PM
> >> To: Tapestry users
> >> Subject: Persistent property initialization in Tapestry 4
> >>
> >> I have a very simple page with a persistent property:
> >>
> >> public abstract class Sample implements PageBeginRenderListener {
> >>   private static final Log LOG = LogFactory.getLog(Register.class);
> >>   @Persist
> >>   public abstract DataObject getData();
> >>   public abstract void setData(DataObject data);
> >>   public void pageBeginRender(PageEvent event) {
> >>    if (null == getData()) {
> >>     LOG.debug("NEW persist");
> >>     setData(new DataObject());
> >>    }
> >>   }
> >> }
> >>
> >> When i refresh the page for the first, second, or even third time, i
> >> see that pageBeginRender is re-initializing my persistent property!
> >> However, after three or four page refreshes, it seems like the
> >> property has been persisted OK.
> >>
> >> Is this the correct way of initializing my persistent property?
> >>
> >>   Thanks
> >>
> >> -- X. Y. ZHAO
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: tapestry-user-
> >> help@jakarta.apache.org
> >>
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
> 
> -- X. Y. ZHAO
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org




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


Re: Persistent property initialization in Tapestry 4

Posted by "X. Y. Zhao" <x....@gmail.com>.
If i set the property, and the output it's value, it is the same for  
the first few refreshes, even though i change them within my class.   
But like i said, after the first few refreshes, the changes persist.

On 17-Aug-05, at 190504, Patrick Casey wrote:

>
>     Are you sure you're seeing re-initialization of *exactly* the same
> page object? Or is tapestry just creating 3 or 4 pages to fill up  
> the page
> pool and subsequent to that you're pulling things out of pool? In  
> other
> words are the first few refreshes really using the same page, or  
> are they
> causing a new page to be generated?
>
>     --- Pat
>
>
>> -----Original Message-----
>> From: X. Y. Zhao [mailto:x.y.zhao.88@gmail.com]
>> Sent: Wednesday, August 17, 2005 4:01 PM
>> To: Tapestry users
>> Subject: Persistent property initialization in Tapestry 4
>>
>> I have a very simple page with a persistent property:
>>
>> public abstract class Sample implements PageBeginRenderListener {
>>   private static final Log LOG = LogFactory.getLog(Register.class);
>>   @Persist
>>   public abstract DataObject getData();
>>   public abstract void setData(DataObject data);
>>   public void pageBeginRender(PageEvent event) {
>>    if (null == getData()) {
>>     LOG.debug("NEW persist");
>>     setData(new DataObject());
>>    }
>>   }
>> }
>>
>> When i refresh the page for the first, second, or even third time, i
>> see that pageBeginRender is re-initializing my persistent property!
>> However, after three or four page refreshes, it seems like the
>> property has been persisted OK.
>>
>> Is this the correct way of initializing my persistent property?
>>
>>   Thanks
>>
>> -- X. Y. ZHAO
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user- 
>> help@jakarta.apache.org
>>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

-- X. Y. ZHAO



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


RE: Persistent property initialization in Tapestry 4

Posted by Patrick Casey <pa...@adelphia.net>.
	Are you sure you're seeing re-initialization of *exactly* the same
page object? Or is tapestry just creating 3 or 4 pages to fill up the page
pool and subsequent to that you're pulling things out of pool? In other
words are the first few refreshes really using the same page, or are they
causing a new page to be generated?

	--- Pat

> -----Original Message-----
> From: X. Y. Zhao [mailto:x.y.zhao.88@gmail.com]
> Sent: Wednesday, August 17, 2005 4:01 PM
> To: Tapestry users
> Subject: Persistent property initialization in Tapestry 4
> 
> I have a very simple page with a persistent property:
> 
> public abstract class Sample implements PageBeginRenderListener {
>   private static final Log LOG = LogFactory.getLog(Register.class);
>   @Persist
>   public abstract DataObject getData();
>   public abstract void setData(DataObject data);
>   public void pageBeginRender(PageEvent event) {
>    if (null == getData()) {
>     LOG.debug("NEW persist");
>     setData(new DataObject());
>    }
>   }
> }
> 
> When i refresh the page for the first, second, or even third time, i
> see that pageBeginRender is re-initializing my persistent property!
> However, after three or four page refreshes, it seems like the
> property has been persisted OK.
> 
> Is this the correct way of initializing my persistent property?
> 
>   Thanks
> 
> -- X. Y. ZHAO
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org




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