class SomeModel extends LoadableDetachableModel {
protected Object load() {
return new Foo();
}
}
new SomeModel(anotherFooThatWasLoaded);
Oh, cute! Or even:
new LoadableDetachableModel(anotherFooThatWasLoaded) {
protected Object load() { return new Foo(); }
}
I thought that load would be called even the first time.
Regarding validation, I'm feeling a tad too frustrated trying to integrate
the bean validation framework infrastructure.
The problem is that spring validators assume that the bean is already bound.
But in the cases where the bean comes from the repositories (inside a
session-in-view), at the time it has been invalidly bound only an exception
thrown inside a transactional context (for example a @Transactional
annotated service method) could avoid persisting an invalid bean.
So I could make onSubmit transactional itself resorting to some aop arcane,
or I could put the validation inside a service (but then I would face a
nightmare of errors/exceptions mapping), or I could get rid of my beloved
validators and learn to love wicket validators (which are fine except that I
don't like the tight tie that they have with the presentation components). I
could momentarily detach the entity before binding it also, but this is a
nono for entities with complex lazy-loaded associations.
This is the kind of dilemma that I usually solve up not going against the
framework (wicket in this case). But if someone has an idea about how
validation could happen after binding inside a [EMAIL PROTECTED] context
without incurring the risk of persisting an invalid entity, and without
losing the ability to simply map errors to ui components, please let me
know.
Cheers,
Carlos
The thing I want to point out here is that you can just initialize the
LDM with the object you loaded from the database, for the first
request, and then implement load like this to get fresh instances on
next requests.
Eelco
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user