Make model aware of its component with wicket1.3
Migrating from wicket 1.2.X to 1.3 is not really hard if code has been well written (of course
). Something is quite annoying : model. Models are no longer aware of component using them. Here is a simple Abstract Class making model aware of component :
[Java] public abstract class AbstractComponentAwareModel implements IWrapModel, IComponentAssignedModel { private Component component; public abstract Object getObject(); public abstract void setObject(Object object); public void detach() {} /** * @see org.apache.wicket.model.IWrapModel#getWrappedModel() */ public IModel getWrappedModel() { return this; } /** * @see org.apache.wicket.model.IComponentAssignedModel#wrapOnAssignment (org.apache.wicket.Component) */ public IWrapModel wrapOnAssignment(Component component) { this.component = component; return this; } protected Component getComponent() { return this.component; } }
Thx to Johan Compagner for the tip






