Define as var I had some serialization problems with that too.
On Wed, Aug 24, 2011 at 9:55 AM, Martin Grigorov <[email protected]>wrote: > Do you experience problems ? > I see no reason this to fail. > I think the constant (val/final) should be declared outside of the > RepeatingView scope and used inside it, then it will be serialized > with it. > > On Wed, Aug 24, 2011 at 10:45 AM, danisevsky <[email protected]> wrote: > > Hello, I am playing with Scala and Wicket and I am not clear about > > using "val" and "var" when I am working with JPA entity objects (which > > are not serializable). For example: > > > > add(new RefreshingView[User]("users"){ > > override def getItemModels(): java.util.Iterator[IModel[User]] = { > > var models = new java.util.ArrayList[IModel[User]](); > > for(user <- getAllUsers()){ > > models.add(new EntityDetachableModel[User](user)) > > } > > models.iterator() > > } > > def populateItem(item: Item[User]) = { > > val user = item.getModelObject // is this the same like final > > User user = item.getModelObject() in Java? > > //... > > } > > }) > > > > if val user = item.getModelObject is the same like: > > final User user = item.getModelObject > > then I can't use val for entity objects because they are not > > serializable and outer class (RefreshingView) holds reference on its > > final fields. Is it true? > > So should I use always var for non serializable objects? > > > > Thank you in advance for clarification. > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > > > > > -- > Martin Grigorov > jWeekend > Training, Consulting, Development > http://jWeekend.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
