|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
IComponentInheritedModel rule exceptionHi 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 |
|
|
Re: IComponentInheritedModel rule exception> 2 - here I have an simple consideration: framework should respect my
> component design. > My view is different: we should respect the framework design. Don't fight your tools, learn how to use them properly. That said, I think that the model is the place where lazy instantiations should occur. I mean, create your components with models that create their 'backend' on demand, like LoadableDetachableModel (without the 'detach' stuff, maybe). Such model object should be pretty small in byte size, so it shouldn't be a problem for memory consumption. Well, I'm not an expert in Wicket's internals, so it's just a guess. :) |
|
|
Re: IComponentInheritedModel rule exception 2 - here I have an simple consideration: framework should respect my
> component design. > >My view is different: we should respect the framework design. Don't fight >your tools, learn how to use them properly. I agree. Let me say it in a different way: framework should allow an simple component design like the one described >That said, I think that the model is the place where lazy instantiations >should occur. I mean, create your components with models that create their >'backend' on demand, like LoadableDetachableModel (without the 'detach' >stuff, maybe). Such model object should be pretty small in byte size, so it >shouldn't be a problem for memory consumption. I agree too. But is up to me decide how and when my components will have they models. I see it just as an fair wish. >Well, I'm not an expert in Wicket's internals, so it's just a guess. :) I'm not too :) It was just a wish.Tank you for the opinion. On Sun, Nov 1, 2009 at 12:25 PM, tetsuo <ronald.tetsuo@...> wrote: > > 2 - here I have an simple consideration: framework should respect my > > component design. > > > > My view is different: we should respect the framework design. Don't fight > your tools, learn how to use them properly. > > That said, I think that the model is the place where lazy instantiations > should occur. I mean, create your components with models that create their > 'backend' on demand, like LoadableDetachableModel (without the 'detach' > stuff, maybe). Such model object should be pretty small in byte size, so it > shouldn't be a problem for memory consumption. > > Well, I'm not an expert in Wicket's internals, so it's just a guess. :) > -- Pedro Henrique Oliveira dos Santos |
| Free embeddable forum powered by Nabble | Forum Help |