Hi, Wicket uses standard Java Serialization and the logic to prevent serializing the same object instance more than once is in the Java standard libraries. So - it is safe to keep many references in your code. They will not lead to bigger serialized pages.
Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Mon, Oct 17, 2016 at 10:36 AM, Jim <jima...@gmail.com> wrote: > Hello, > > I have been trying to figure out if having a Component as a class member > (and especially inside a Model) will cause it to be serialized mutliple > times. > > From what I have gathered so far, stateful pages always serialize their > components. But is there a danger of serializing the Component more than > once? Or is wicket smart enough to only hold references to the serialized > instance after the first serialization? > > For example, take the following model: > > public class VisibilityModel extends Model<Boolean> { > > private final Component component; > > VisibilityModel (Component component) { > this.component = component; > } > > @Override > public Boolean getObject () { > return component.isVisible(); > } > > @Override > public void setObject (Boolean object) { > component.setVisible(object); > } > } > > Will the Component be serialized again with the model, or will wicket only > hold a reference to the already serialized instance of the component? > > Thank you in advance >