My best idea so far is to have AbstractDetachableModel check for a null model directly after attach and throw an ObjectNotFoundException. You could also throw this from your DAOs if you don't like returning null. If there was some single place to catch this, which I think there is, the user could do whatever they like with this error.
Actually, having one central place to catch and react to exceptions can be very handy. Spring supports it with their ExceptionHandlerResolver and the pattern allows you to throw arbitrary exceptions anywhere in your code knowing that they will be handled properly when they bubble up to the top. On 7/10/05, Eelco Hillenius <[EMAIL PROTECTED]> wrote: > That's a good one. I think it is good that the exception is thrown. > Trying to work with objects that don't exist anymore is wrong; so far so > good. > > Problem with trying to solve this generic is that an exception thrown in > the model could have many causes. How would you like to be able to react > on such an error? Having something like onModelRuntimeException on your > components? That might sound convenient at first, but it doesn't handle > the cases where the model is accessed directly by clients. You could > decorate your models with model objects that catch the exceptions. But > that would mean a lot of code. Hmmm... do you have any ideas on how this > could be supported best? > > Eelco > > > Phil Kulak wrote: > > >A user clicks on an edit link an gets a form containing a detachable > >model. While the user is editing data on the form, the object they are > >working on is deleted by another user. The current user submits the > >form, which get it's model attached to contain a null object, and OGNL > >throws a null pointer exception. Has anyone found an elegant solution > >to this? Maybe model can throw an exception if it's object is null > >that's caught somewhere to display a nice message to the user? Is > >there one place in Wicket where I can catch all exceptions? > > > > > >------------------------------------------------------- > >This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening > >July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual > >core and dual graphics technology at this free one hour event hosted by HP, > >AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar > >_______________________________________________ > >Wicket-user mailing list > >[email protected] > >https://lists.sourceforge.net/lists/listinfo/wicket-user > > > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening > July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual > core and dual graphics technology at this free one hour event hosted by HP, > AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar > _______________________________________________ > Wicket-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/wicket-user > ------------------------------------------------------- This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar _______________________________________________ Wicket-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-user
