I am confused about the 'proper' way to handle page inits and detaches, w/regards to persistent variables.

Let's say I have a page with one persistent variable, 'vr', so have a setter which fires a change notification:
public void setVr(VacationRequest vr) {
this.vr = vr;
fireObservedChange("vr", vr);
}
I have a detach, as follows:
public void detach() {
vr = null;
super.detach();
}
and ideally, I have an initialize, as follows:
protected void initialize() {
setVr(new VacationRequest());
}

The problem is that since detach calls initialize, I get an exception saying, to paraphrase, that I am trying to modify a persistent variable after a commit. Now I understand why this is happening, and could simply do this:
protected void initialize() {
vr = new VacationRequest());
}

But I would rather call my setter, that's why it's there for. And the setter does need to have the fireObservedChange call for use in other contexts.

So what am I missing here? Is there Is there any way at page initialization time to use your setters, and still have those setters have the change notificaiton calls in them, so they behave properly when called in other contexts?





-------------------------------------------------------
This sf.net email is sponsored by:
With Great Power, Comes Great Responsibility Learn to use your power at OSDN's High Performance Computing Channel
http://hpc.devchannel.org/
_______________________________________________
Tapestry-developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/tapestry-developer

Reply via email to