The problem in your example is not the CPM, but your data provider - where does it get it's list of items from?
-- Jeremy Thomerson http://www.wickettraining.com On Thu, Jun 25, 2009 at 6:07 PM, Hubbard, Bobby<[email protected]> wrote: > Does that mean what I am trying to do is not suited for > CompoundPropertyModel? :) Can you point me to some documentation that might > help me understand it better? > > -----Original Message----- > From: Igor Vaynberg [mailto:[email protected]] > Sent: Thursday, June 25, 2009 11:22 AM > To: [email protected] > Subject: Re: CompoundPropertyModel and nested DataView > > if you are a newbie do not use CPM it is a shortcut model more suited > for users who know and understand models well. > > -igor > > On Wed, Jun 24, 2009 at 5:35 PM, Hubbard, Bobby<[email protected]> > wrote: >> I am a Wicket newbie and am currently struggling with >> CompoundPropertyModel. I have found a lot on the list about >> CompoundPropertyModel but not regarding this specific issue. I am >> building a shopping cart. I have placed the cart's form inside a panel >> and the cart items (via DataView) are inside the form. ShoppingCart is a >> model that I would like to use to represent the current state of the >> entire cart. It contains a array of ShoppingCartItem 's. However, when >> running this, cartItems never gets set on the ShoppingCart model. While >> debugging, cartItems is a child of the panelForm, but never gets >> populated on the ShoppingCart pojo via CompoundPropertyModel. The form >> does persist and if I traverse the panelForm object I could figure out >> how to get to the ShoppingCartItem's...but I'd rather not. J >> >> >> >> What am I missing? Is there a better way to do this? See code attached >> below. >> >> >> >> Thanks!! >> >> >> >> <code> >> >> ... >> >> public CartPanel(String id) { >> >> super(id); >> >> Form panelForm = new Form("panelForm", new >> CompoundPropertyModel(new ShoppingCart())) { >> >> �...@override >> >> protected void onSubmit() { >> >> // need to rewrite cookie on update >> >> ShoppingCart cart = (ShoppingCart) getModelObject(); >> >> System.out.println(cart.getCartItems());// check if >> cart items got populated >> >> } >> >> }; >> >> add(panelForm); >> >> >> >> IDataProvider dataProvider = new ShoppingCartItemsProvider(); >> >> DataView dataView = new DataView("cartItems", dataProvider) { >> >> �...@override >> >> protected void populateItem(final Item item) { >> >> final ShoppingCartItem cartItem = (ShoppingCartItem) >> item >> >> .getModelObject(); >> >> item.add(new Label("itemName", cartItem.getName())); >> >> item.add(new TextField("quantity", new >> ShoppingCartItemModel( >> >> new Model(cartItem), >> ShoppingCartItemType.QUANTITY))); >> >> } >> >> }; >> >> // add general text labels and buttons to the cart >> >> addFieldsAndButtons(panelForm); >> >> panelForm.add(dataView); >> >> }... >> >> </code> >> >> >> >> Thanks!! >> >> >> >> >> -------------------------------------------------------------------------- >> This e-mail and any attachments may contain confidential material for the >> sole use of the intended recipient. If you are not the intended recipient, >> please be aware that any disclosure, copying, distribution or use of this >> e-mail or any attachment is prohibited. If you have received this e-mail in >> error, please contact the sender and delete all copies. >> Thank you for your cooperation. >> > > --------------------------------------------------------------------- > 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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
