Hi,

correct me if I'm wrong, Igor, but I thought detach() is used to keep the model memory footprint low
*between requests* and Serialization is a total different story.
If I mark a field as transient I don't have to nullify it in detach().
For example using a IDataProvider for pagination:
If I set a (transient) field to null after every request I have to initialize it before every request too, sounds inefficient to me. To re-initialize a transient field I would use readObject(ObjectInputStream in)
instead.
If I'm right the following comment in IDetachable is misleading:

        /**
* Detaches model after use. This is generally used to null out transient references that can be
         * re-attached later.
         */
        void detach();

What am I missing?

Robin.



On 06.08.2009, at 21:45, Igor Vaynberg wrote:

yep, lazy init is the way to do things. also helps to mark those
fields as transient as an additional safeguard.

-igor

On Thu, Aug 6, 2009 at 12:22 AM, Gabi Kaltman<gkalt...@yahoo.com> wrote:
Hi,

I'm very young on the Wicket planet, so please excuse my simple question related to DataView/IDataProvider

My configuration:
1. I use a DataView (MyDataView)
2. I added a PageNavigator to MyDataView
3. I defined a IDataProvider attached to  MyDataView (MyDataProvider)
4. MyDataProvider has a not-serializable field (MyField)
5. MyField is used in the method MyDataProvider.size()
6. I use Wicket 1.4.0

What I do:
1. In the method MyDataProvider.detach() , I nullify MyField (MyField = null)

What happens:
1. When I navigate through pages, I get a NPE in MyDataProvider.size() as MyField became null

How I fixed it:
1. I overrode in MyDataView the method getDataProvider(). Didn't work. I noticed that this method is never invoked 2. I tested again null in MyDataProvider.size(). If MyField is null, I just reinitialize it. It works

My question is if this solution is the optimal one, or there is a better one?

Thanks,
kaltman





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to