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<[email protected]> 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: [email protected] For additional commands, e-mail: [email protected]
