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]
>

Reply via email to