Hi people, lately I'm having a few runtime problems on my wicket projects, and I'm searching for an clean solution. So let me share it with you, and know seconds options:
Environment: some components that I create for wicket projects on my company has lazy model creation. Means that those components may have an model at they first render or not. Problem: time to time, those components get placed inside an parent component with IComponentInheritedModel. Then simple lines like: if(getDefaultModel() != null) on my components start to throw runtime exceptions, like: org.apache.wicket.WicketRuntimeException: No get method defined for class(...) when some parent is using CompoundPropertyModel for example. Wish: an clean way of to disable this wicket default behavior, that is to inherit models. Current solution: 1- override the initModel method on my component 2- always create my component with an model Why the current solution are not good enough: 1 - an override initModel implementation returning null. It simple don't tell nothing about the fact that this component stop inherit models. IMO the framework need allow developers write self documented code, clean code... 2 - here I have an simple consideration: framework should respect my component design. If I want to develop an component that has 200 inner components, and want to set an model at an inner component only when user start to edit his default value... an web framework simple has to allow me to do it in an simple an clean way. Currently an inner component implementation like: if(getDefaultModel() == null) return defaultValueToRender; is an russian roulette. please, let me know if my consideration here needs more use cases or details, that I can provide a lot of. Possible solutions: 1 - wicket can provide an interface like IInheritedModelProtected 2 - component can have an flag: inheritModel About possible solutions: 1 - I think it is natural: there is an interface to enable model inheritance, so users can search for an interface that stop/prevent model inheritance 2 - good enough solution for an procedural language. We are using OO, right? -- Pedro Henrique Oliveira dos Santos