Nathan Hamblen wrote:
> As others have pointed out, the magic of IModel works better than you
> think (or thought) it does. I often have two constructors for pages, one
> taking bookmarkable parameters and another taking an IModel so that I
> don't always have to reload DB objects page to page. It's a cinch.
Currently I use models to hold, attach & detach my persistent objects. 
About using IModels in constructors, I've mostly do it to be able to 
unit test my pages easier. But inside my application code, I prefer 
other components *not* to see or be aware of each other's internal 
models. That said, I prefer 'new PersonProfilePage("id",person)' instead 
of 'new PersonProfilePage("id",profileModel)'. I would like to hear 
comments on this, since I'm not sure everybody agrees.

> This system works very well and practically everyone uses it, but that
> shouldn't stop you from trying something else. Whatever you come up with
> just might be the way we all do it in a few years, when server resources
> dwarf those available today. I like IModels fine, and will like them
> even more when they're strongly typed, but I'll admit it would be easier
> to just pass around the objects they contain. Significantly easier for
> new users.
> So please do give it a shot. (I'm assuming your app is high-complexity,
> low-volume, or that you have small data objects.) I can't think of
> anything in Wicket that would slow you down, other than the minor
> annoyance of having to wrap objects in new Model(Serializable o) before
> passing them to some framework components.
> And let us know how it goes!
> Nathan
I'm currently using detached objects in my pages. Although it would seem 
easy at first, there's a hell lot of problems keeping the objects in 
sync with session. Lazy exceptions are just one of them. You could Also 
easily get two objects with same id in the session if you're not 
careful. As I said earlier, I use Session.lock() to re-attach objects. 
Cascading the lock through the object graph and taking care of attaching 
all objects in use is also another pain.
We need to come up with something that would free the developer of 
thinking about this attaching detaching of objects. Sure I'll look more 
for an efficient way,But until something is found I'll revert back to 
loading objects with each request.


Take Surveys. Earn Cash. Influence the Future of IT
Join's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
Wicket-user mailing list

Reply via email to