On Jun 3, 2005, at 9:05 AM, Robert wrote:
There really isn't much to elaborate on. You can make your
classes concrete, use <property-specification> (or <property> in
Tapestry 4.0 DTD) in the specification files and simply use get/
setProperty in your Java code to work with the values.
The thing that I don't understand is that when I define my own
getter or setter for a property, that I will get into an infinite
loop.
For example if I have an address property and implement:
public Address getAddress()
{
return (Address)getProperty("address");
}
What I expected is that the call would lead into the enhanced class
with its own implementation of getAddress.
I forgot if the enhancing was based on the properties specified in
the page specification, or on the abstract methods, or both.
Of course if I name the method getAddressProperty or something then
it works fine.
I see what you mean. I do not wrap my calls to getProperty inside
normal looking getters like that so I've not had that issue.
I'm not sure if you're saying you have had a problem naming things
this way or if you're saying you expected there to be a problem - I
don't know if this is an issue or not, but I wouldn't be surprised.
I think that as long as I do all my instances like this, I will get
used to it and won't forget.
Are there any other downsides on it? Like losing some functionality
regarding lifecycle management?
Be careful with persistent properties - but other than that I think
you'd be fine.
For example I have a component with a value parameter
<parameter name="value" direction="in" required="yes" type="int"/>
The component class contains:
private int value;
public void initialize() {
value = 0;
}
public int getValue() {
return 50;
}
public void setValue(int value) {
this.value = 40;
}
I noticed that initialize is never called. Isn't it needed for the
same reason as pages?
The first time when going to a page with this component, it will
enter both getValue and setValue. But the next times it will enter
just setValue.
The value 50 or 40 are actually never displayed on my page. I will
only see the value that was given to the value parameter.
I really would like to know what is happening.
I find Tapestry very confusing :)
Me too :)
I'm not sure off the top of my head about component parameters like
this, but initialize() is a page thing, not component if I remember
correctly.
Personally, I avoid instance variables in Tapestry pages/components,
but I do use get/setProperty. I highly recommend you get Howard's
book if you don't already have it - he's provided a lot of helpful
state information in there.
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]