On 4/12/2005 08:49, Erik Hatcher wrote: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 are you saying that if you implement a getter/setter yourself, and you have instance variables, you have to reset/unset these instance variables by overriding the initialize() method?
Yes. Emphatically yes! Otherwise another user will see that data as that same page instance will be used for another request.
In Struts, for example, the same issue applies with Action's. They are not to maintain their own state unless you want the hassle of managing it fully knowing how things are pooled.
I don't remember seeing that in Howard's book.
I'm sure its in there, but I don't have the book handy to provide a reference.
Yes - use <property-specification> and do not use instance variables.
The only way to get at data that is more complicated that a simple
variable like, say, the address from the current person, is to provide
your own getter, right? Or provide a getter to return the person and get
at the address using ognl, which seems a bit sloppy to me.
I'm not following exactly. If your page has a <property-specification> for a Person object, components could easily get at "person.address" with OGNL expressions.
Instance variables aren't bad, it just requires that you manage the state knowing that the page instance will likely be reused by another request.
What do I gain by going with the <property-specification> ?
Peace of mind.
I use <property-specification> when I don't need anything other than a variable, don't care what it's called, etc. But for more complicated operations, this isn't an option, is it? Am I missing something?
That's not the case. <property-specification> works for any type of object, and OGNL expressions can get at any piece of that object. This topic is more on the .java side of things and whether to use abstract getters/setters for a property or to implement your own concrete getters/setters and maintain data in instance variables.
Erik
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
