Thanks (and to Johan as well).

The simple solution of using a small anonymous implementation of 
LoadableDetachableModel will work just fine for my current needs. If I later 
feel that I need something more enterprisy I'll look into building something 
more complex.

// Matthias

> Date: Mon, 12 Nov 2007 15:55:46 +0100
> From: [EMAIL PROTECTED]
> To: [email protected]
> Subject: Re: Examples of using detachable models?
>
> The trick is to let the models do the reloading by id part for you.
> If you take a look at LoadableDetachableModel you see it has an
> abstract load() method. A very common implementation would be this:
> public Object load()
> {
> return myDao.get(Movie.class,movieId);
> }
>
> of course you have to make the dao and the id available to the model.
> The model will make sure that after each request the movie is
> disposed.
> If you only have a handful of these models you probably don't even
> need to look any further.
>
> However as you use more and more of these models you will most likely
> want to build your own model (from scratch) to do more fancy stuff
> like setting the object, retaining a copy of transient objects, etc.
> Fortunately for this purpose there are several other models already
> available like the hibernate models (i think in extensions or in
> wicket-stuff). So you might want to take a look there before you start
> building your own.
>
> Maurice
>
> On Nov 12, 2007 2:46 PM, Matthias Karlsson  wrote:
>>
>> Hi,
>>
>> I have recently started to use Wicket and I'm finally getting up to speed 
>> after getting my Dao-framework and Spring integrated nicely with it. 
>> However, I'm having problems figuring out how to implement detachable models.
>>
>> Let's take a simple example from my code base (I'm free-typing here so this 
>> code may not be 100% correct, but hopefully you'll get what I mean).
>>
>> public class MyPage extends WebPage {
>>
>> private Movie movie;
>>
>> public MyPage(Movie movie) {
>>
>> this.movie = movie;
>>
>> add(new MyForm("form"));
>>
>> }
>>
>> private final MyForm extends Form {
>>
>> private MyForm(String id) {
>>
>> super(id, new CompoundPropertyModel(movie));
>>
>> add(new TextField("name"));
>> add(new TextField("year", Integer.class));
>>
>> /* etc */
>>
>> }
>>
>> }
>>
>> }
>>
>> Now, this code works well. However, Movie is not an object that I would like 
>> serialize, mainly because I due to technical reasons not even can. However, 
>> using just an identifier I would be able to restore it using a globally 
>> accessable dao-locator.
>>
>> If anyone could give me a few hints or pointers I would appreciate it.
>>
>> Thanks for a great framework.
>>
>> // Matthias
>> _________________________________________________________________
>> Express yourself instantly with MSN Messenger! Download today it's FREE!
>> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to