On Apr 12, 2005, at 8:06 AM, Bruno Haas wrote:
I have written a "hello world" tapestry application that works fine. Being new to the whole tapestry framework, I have a question that I could not find an answer for in the user/developer's manual:
It looks like page properties can be defined two ways:
1. In the page spec using <property-specification>, in this case, the page class needs to be abstract and the getter and setter for the property need to be defined abstract too. Tapestry will then apparently automatically instanciate a derived calls implementing the getter and setter.
You do not need to implement abstract getters/setters to get/set a property. You can use getProperty/setProperty also. I prefer this myself as the abstract thing annoys me.
2. Directly in the Page class, in this case, the page does not need to be abstract. I then have to write my own getter and setter.
And in this case you also need to clear the values in initialize() (which gets called *after* the page is done and is being initialized to be put back into the page pool).
So what is the actual difference between those two ways of doing things ?
The difference is who manages the state of the properties. <property-specification> is managed by Tapestry. Putting in your own concrete getters/setters and having instance variables to hold that mean you have to manage the state yourself or risk other requests getting unintended data.
Is there a recommended way ?
Yes - use <property-specification> and do not use instance variables.
What do I gain by going with the <property-specification> ?
Peace of mind.
Erik
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
