make your own base model public abstract class ComponentAssignModel implements IWrapModel, IComponentAssignedModel {
private Component component; /** * @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; } } the only thing is that i dont know if this completely works correctly (but i think it should, bug or no bugs) johan On 7/5/07, Vincent Demay <[EMAIL PROTECTED]> wrote:
Hi I have a custom model where i need to access to the component. The only method I found seems me a little bit overkill : my model should implement IComponentInheritedModel and I also need to declare a new class implementing IWrapModel to return on wrapOnInheritance. Furthermore all this stuff is not really oriented to simply get the component in the model. (maybe there is a better way?) I thought about a very simple way : Just creating a new interface : IComponentAwareModel{ void setComponent(Component component)} and adding in component.class if (model instanceof IComponentAwareModel){ ((IComponentAwareModel)model.setComponent(this))} I think it also avoid to write 40 code lines just to get the component in the model. WDYT? -- Vincent Demay