You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jonny Wray <jo...@yahoo.com> on 2004/08/25 05:39:29 UTC

Re: do java classes and properties need to be abstract for any particular reason?

I would get the book and read up on this - it caught me out when learning
the framework. The developers and user docs has all you need also, I learnt
from that before the book was out.

The reason is that pages in Tapestry are pooled - when one is requested it
comes from a pool rather than being created, it is rendered, and then
returned to the pool. In order for pooled page instances to be shared across
requests, they need to be reset to a basic state before being returned to
the pool. If you use instance variables and your own concrete getter/setter
you need to manage this yourself. If you make it a property and define
abstract getter and setters, the framework does the "sneaky" stuff for you.

It works well - you end up more or less forgetting about the pooling
mechanism in day to day work.

The one thing I don't like about this is that by declaring the class
abstract you loose the ability for your IDE and the compiler to tell you if
you've not implemented an interface fully. I've been caught by this a few
times. 

On 8/25/04 2:42 AM, "Francisco Hernandez" <la...@lagcisco.com> wrote:

> under what condition would you want to use abstract classes/properties?
> 
> I would rather just use the instance variables inside my listener
> methods that the getter/setters unless theres something sneaky going on,
> again, im new at this, i've got much to learn, got to pickup the book too
> 
> 
> Jamie Orchard-Hays wrote:
> 
>> The best way to define page properties is to use <property-specification> in
>> the .page file. If you need to access the property in the .java file, you
>> create abstract setters and getters for each of these properties. (Be sure
>> to make the java class abstract.) This is the normal way to create and
>> access page properties. Otherwise, you have to do manual initialization in
>> the .java file.
>> 
>> Note that initialize() is not for setting up properties on a page, but for
>> setting them back to their proper values (usually null) when you are DONE
>> with the page.
>> 
>> Jamie
>> ----- Original Message -----
>> From: "Francisco Hernandez" <la...@lagcisco.com>
>> To: "Tapestry users" <ta...@jakarta.apache.org>
>> Sent: Wednesday, August 25, 2004 12:41 AM
>> Subject: do java classes and properties need to be abstract for any
>> particular reason?
>> 
>> 
>>  
>> 
>>> im very new to tapestry and have been playing around with it and have
>>> noticed in all the examples that they always use abstract for properties
>>> and classes is their a particular reason for this?
>>> 
>>> i have been making a little app just to test tapestry and have yet to
>>> mark my classes and properties as abstract and everything still works as
>>> expected, I also use use instance variables inside the listeners and
>>> they seem to be working fine, i did read somewhere that tapestry
>>> subclasses my classes at runtime but im not too sure about the details
>>> of this and how it affects the listeners, another thing issue though, if
>>> I do have to make the classes/properties abstract how do i go about
>>> testing the classes since i cannot instanciate them? is there somekind
>>> of tapestry testing framework out there?
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> 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
>> 
>> 
>>  
>> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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: do java classes and properties need to be abstract for any particular reason?

Posted by Francisco Hernandez <la...@lagcisco.com>.
thanks for the explanation, now I remember reading something about pages
being pooled.

anyhow i'll read the user/developer docs on the website, i skipped them
because they said they were out-of-date

and with the classes being marked as abstract, i remember trying to
implement PageRenderListener i believe while
expecting IDEA to tell me to implement that interface and i was
scratching my head as to why it wasnt telling me to implement it, thanks
for giving me the heads up on this!

Jonny Wray wrote:

>I would get the book and read up on this - it caught me out when learning
>the framework. The developers and user docs has all you need also, I learnt
>from that before the book was out.
>
>The reason is that pages in Tapestry are pooled - when one is requested it
>comes from a pool rather than being created, it is rendered, and then
>returned to the pool. In order for pooled page instances to be shared across
>requests, they need to be reset to a basic state before being returned to
>the pool. If you use instance variables and your own concrete getter/setter
>you need to manage this yourself. If you make it a property and define
>abstract getter and setters, the framework does the "sneaky" stuff for you.
>
>It works well - you end up more or less forgetting about the pooling
>mechanism in day to day work.
>
>The one thing I don't like about this is that by declaring the class
>abstract you loose the ability for your IDE and the compiler to tell you if
>you've not implemented an interface fully. I've been caught by this a few
>times. 
>
>On 8/25/04 2:42 AM, "Francisco Hernandez" <la...@lagcisco.com> wrote:
>
>  
>
>>under what condition would you want to use abstract classes/properties?
>>
>>I would rather just use the instance variables inside my listener
>>methods that the getter/setters unless theres something sneaky going on,
>>again, im new at this, i've got much to learn, got to pickup the book too
>>
>>
>>Jamie Orchard-Hays wrote:
>>
>>    
>>
>>>The best way to define page properties is to use <property-specification> in
>>>the .page file. If you need to access the property in the .java file, you
>>>create abstract setters and getters for each of these properties. (Be sure
>>>to make the java class abstract.) This is the normal way to create and
>>>access page properties. Otherwise, you have to do manual initialization in
>>>the .java file.
>>>
>>>Note that initialize() is not for setting up properties on a page, but for
>>>setting them back to their proper values (usually null) when you are DONE
>>>with the page.
>>>
>>>Jamie
>>>----- Original Message -----
>>>From: "Francisco Hernandez" <la...@lagcisco.com>
>>>To: "Tapestry users" <ta...@jakarta.apache.org>
>>>Sent: Wednesday, August 25, 2004 12:41 AM
>>>Subject: do java classes and properties need to be abstract for any
>>>particular reason?
>>>
>>>
>>> 
>>>
>>>      
>>>
>>>>im very new to tapestry and have been playing around with it and have
>>>>noticed in all the examples that they always use abstract for properties
>>>>and classes is their a particular reason for this?
>>>>
>>>>i have been making a little app just to test tapestry and have yet to
>>>>mark my classes and properties as abstract and everything still works as
>>>>expected, I also use use instance variables inside the listeners and
>>>>they seem to be working fine, i did read somewhere that tapestry
>>>>subclasses my classes at runtime but im not too sure about the details
>>>>of this and how it affects the listeners, another thing issue though, if
>>>>I do have to make the classes/properties abstract how do i go about
>>>>testing the classes since i cannot instanciate them? is there somekind
>>>>of tapestry testing framework out there?
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>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
>>>
>>>
>>> 
>>>
>>>      
>>>
>>
>>---------------------------------------------------------------------
>>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
>
>
>  
>




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


RE: do java classes and properties need to be abstract for anyparticular reason?

Posted by "Filip S. Adamsen" <fi...@stubkjaer-adamsen.dk>.
> -----Original Message-----
> From: Jonny Wray [mailto:jonny_wray@yahoo.com]
> Sent: Wednesday, August 25, 2004 5:39 AM
> To: Tapestry users
> Subject: Re: do java classes and properties need to be abstract for
> anyparticular reason?
> 
> 
> [...]
> 
> It works well - you end up more or less forgetting about the pooling
> mechanism in day to day work.
> 

What pooling mechanism? ;o)

> [...]




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