[prev in list] [next in list] [prev in thread] [next in thread]
List: tapestry-user
Subject: Binding confusion
From: Robert <rvlwork () xs4all ! nl>
Date: 2005-06-30 7:33:16
Message-ID: 42C3A03C.8020402 () xs4all ! nl
[Download RAW message or body]
Hi!
I am having some questions regarding to bindings.
I have a component with one parameter which is a complex object that
includes some setters. I have set the direction to custom. I have done
it because I need to access it before the render phase. And also because
I can implement the methods to access the parameter myself and avoid to
use abstract classes (bad design in my opinion).
Anyway the confusion is that each time I call getBinding().getObject() I
noticed that I get an object with a different address. They do have the
correct values set by the page that created this parameter. However if I
call a setter on the parameter this change has dissapeared the next time
I call getBinding().getObject().
I have avoided this problem by using an instance field with the
parameter type and set it the first the the parameter is accessed. This
works fine for the pre-render and render phase.
The problem I am having now is with the combination of cleaning up the
parameter and making changes available in an action (long after the
render has finished).
Maybe a little bit of pseudo-code will make things more clear want I
would like...
*Code:*
private MyObject param;
private MyObject getParam()
{
if (param == null)
param = getBinding().getObject();
return param;
}
protected renderComponent()
{
getParam().setValue(1);
....
}
public action()
{
int x = getParam().getValue();
}
My questions are:
1) Is it possible to keep the update in the object without having an
instance variable?
2) How and when can I cleanup the instance variable (set it to null)? If
I do it in cleanupAfterRender it means that the update is not available
in the action handler.
3) Will the component object that is used for the action not always the
same object used to render? And therefore instance variables should not
be trusted between those phases?
Any background information related to these topics is very welcome to
increase my knowledge about Tapestry.
TIA!
Robert.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic