Re: IComponentInheritedModel IWrapModel just to get the component in model
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
IComponentInheritedModel IWrapModel just to get the component in model
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
Re: IComponentInheritedModel IWrapModel just to get the component in model
* Vincent Demay: I think it also avoid to write 40 code lines just to get the component in the model. I also find it utterly complicated. Is there a reason for this that we are overlooking? -- Jean-Baptiste Quenot aka John Banana Qwerty http://caraldi.com/jbq/
Re: IComponentInheritedModel IWrapModel just to get the component in model
Perhaps you are looking for IComponentAssignedModel ? -Matej On 7/5/07, Jean-Baptiste Quenot [EMAIL PROTECTED] wrote: * Vincent Demay: I think it also avoid to write 40 code lines just to get the component in the model. I also find it utterly complicated. Is there a reason for this that we are overlooking? -- Jean-Baptiste Quenot aka John Banana Qwerty http://caraldi.com/jbq/
Re: IComponentInheritedModel IWrapModel just to get the component in model
On 7/5/07, Jean-Baptiste Quenot [EMAIL PROTECTED] wrote: * Vincent Demay: I think it also avoid to write 40 code lines just to get the component in the model. I also find it utterly complicated. Is there a reason for this that we are overlooking? -- yes, there is. the interface you are proposing would only support a single model instance per component relationship, where in reality it is often the case that a single instance of imodel is assigned to multiple components. -igor Jean-Baptiste Quenot aka John Banana Qwerty http://caraldi.com/jbq/