Hi,

For the most part nesting models in wicket is what you expect of it.
for example i can nest a hibernateobjectmodel inside a propertymodel
and i will get the right property from my hibernateobject in my
component.

So this encourages patterns like new Form("myform",new
CompoundPropertyModel(imodelFromUnknownSource). The Imodel passed too
the compoundmodel can be anything from an annonymous IModel
implementation too a hibernateobjectmodel.

There is only one catch it does not work when you unknowingly nest 2
CompoundPropertyModels because the deepest nested model wil return the
property while the toplevel model expexts the whole object.

Now my first idea was to simply not allow this and catch this
behaviour in the constructor of CompoundPropertyModel and throw an
exception.
While this works for the case where you nest a compoundmodel directly
in another compoundmodel it does not work if you have something like:
new CompoundPropertyModel(new NestingSupportedModel(    new
CompoundPropertyModel(new Pojo()))) -Don't let that
NestingSupportedModel distract you it just redirects the getObject
call to its nested object-, unless you dig through the entire tree of
models you get in the constructor of CompoundPropertyModel. Which i
think is ugly.

Since this problem is not limited to compoundmodels but to all models
that do not return the whole object in getObject() but say a property
or a calculation.
The question arises do we want to support this kind of behaviour.
And if we do howmuch impact will it have.
And what are we going to support:
-compound in compound should behave like it is only 1compound
-any "normal" model in compound is already supported
-compound in "normal" model should behave like it is only a compound

IMO we can support nesting of all types of models, even if it means
that you nest the same type of model 25 levels deep ( imo its up to
the app builder to prevent this, but the performance impact should not
be that much higher, and memory impact will depend on the amound of
extra fields in the models) and ofcourse there will always be models
that don't support haveing a nested model but they should document
that behaviour.

By using a simpel interface like INestedModel we could return the
whole object instead of the property/ calculation or whatever the
drawback is that it affects all models, they will need to check for
this interface.

phew that a lot of text to read. Main question is does/will/should
wicket support nesting of models that don't play nicely because they
dont return what you put in them -like compoundmodels and
propertymodels-
This definitly is opening a big can of worms.

Maurice Marrink


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to