CheeseDetach does do something for detach(), but it's implemented for you in
LoadableDetachableModel. To really understand what's going on you should
look at that class' implementation. It's straight forward.

http://svn.apache.org/repos/asf/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/model/LoadableDetachableModel.java

I recommend importing all of the Wicket source code into your IDE so can
easily review what's happening behind the APIs. You'll learn a lot.

Good luck,
Dan

On Wed, Jun 15, 2011 at 10:47 PM, Brian Lavender <[email protected]> wrote:

> Dan, thank you for pointing that out. That makes more sense. So, it looks
> like now that my List of Cheeses will not get cached between pages saving
> space? And this is because the model doesn't do anything for detach but
> only does load, so every time, it will get it from the DAO?
>
> Here is the code for my index page. Supporting code files are attached.
>
> public class Index extends CheesrPage {
> public Index() {
>
>        CheeseDAO dao = new CheeseDAOImpl();
>        CheeseDetach myDetach = new CheeseDetach(dao);
>
>        CheeseList myCheeseList = new CheeseList("cheeses", myDetach,
> getCart());
>         add(myCheeseList);
>
> [snip]
> }
>
> On Wed, Jun 15, 2011 at 06:35:25PM -0700, Dan Retzlaff wrote:
> > Look carefully at the ListView's constructor arguments. It wants an
> > IModel<List<Cheese>>, not an IModel<Cheese> which is what your current
> > CheeseDetach provides. Depending on your goals, you can either (1) change
> > CheeseDetach.load() to call getCheeses(), or (2) change the constructor
> to
> > accept a list of cheeses and retain a list of cheese IDs, and query for
> > those cheeses individually in CheeseDetach.load().
> >
> > On Wed, Jun 15, 2011 at 5:38 PM, Brian Lavender <[email protected]> wrote:
> >
> > > I am trying to create a ListView using a detachable model, but I just
> > > can't seem to figure out how to construct my DetachableModel.
> Basically, I
> > > would like to create a detachable model and then pass it to my
> constructor
> > > for a CheeseList.  This is built upon the code for the  examples for
> > > Wicket in Action [1] by Dashorst in Chapter 4.3.  My DAO can return the
> > > cheese based upon id or it can also return the list of cheeses. What
> > > code do I need to put in CheeseDetach for my detachable model?
> > >
> > >
> > >         CheeseDAO myDAO = new CheeseDAOImpl();
> > >
> > >         // Can I make CheeseDetach construct it using the DAO as
> follows?
> > >         CheeseDetach myDetach = new CheeseDetach(myDAO);
> > >
> > >          // ListView can take list or Model as constructor.
> > >          // How does the model work for a ListView?
> > >          CheeseList myCheeseList = new CheeseList("cheeses", myDetach,
> > > getCart());
> > >
> > >          // Add ListView to page
> > >
> > >          add(myCheeseList);
> > >
> > >
> > > 1. https://code.google.com/p/wicketinaction/downloads/list
> > > --
> > > Brian Lavender
> > > http://www.brie.com/brian/
> > >
> > > "There are two ways of constructing a software design. One way is to
> > > make it so simple that there are obviously no deficiencies. And the
> other
> > > way is to make it so complicated that there are no obvious
> deficiencies."
> > >
> > > Professor C. A. R. Hoare
> > > The 1980 Turing award lecture
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [email protected]
> > > For additional commands, e-mail: [email protected]
> > >
>
> --
> Brian Lavender
> http://www.brie.com/brian/
>
> "There are two ways of constructing a software design. One way is to
> make it so simple that there are obviously no deficiencies. And the other
> way is to make it so complicated that there are no obvious deficiencies."
>
> Professor C. A. R. Hoare
> The 1980 Turing award lecture
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>

Reply via email to