Re: CompoundPropertyModel and nested DataView

2009-06-25 Thread Igor Vaynberg
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, Bobbybobby.hubb...@garmin.com 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: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



RE: CompoundPropertyModel and nested DataView

2009-06-25 Thread Hubbard, Bobby
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:igor.vaynb...@gmail.com] 
Sent: Thursday, June 25, 2009 11:22 AM
To: users@wicket.apache.org
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, Bobbybobby.hubb...@garmin.com 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: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: CompoundPropertyModel and nested DataView

2009-06-25 Thread Jeremy Thomerson
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, Bobbybobby.hubb...@garmin.com 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:igor.vaynb...@gmail.com]
 Sent: Thursday, June 25, 2009 11:22 AM
 To: users@wicket.apache.org
 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, Bobbybobby.hubb...@garmin.com 
 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: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: CompoundPropertyModel and nested DataView

2009-06-25 Thread Jeremy Thomerson
And, no, this is not the ideal place for a CPM.  A CPM is most
commonly used on a form that has many form components below it that
directly edit items off of the form's model.  ie:


new Form(new CPM(new Person()))

form.add(new Label(firstName))   --- by using a CPM, you save
creating your own property model here

form.add(new Label(lastName))   --- by using a CPM, you save
creating your own property model here

I have been using Wicket for several years, and I hardly ever use a
CPM.  It's a shortcut that you can use if you choose to do so.  But
it's nothing more than that.  Like Igor said, you'll be better served
by understanding models first rather than understanding CPM.

--
Jeremy Thomerson
http://www.wickettraining.com




On Thu, Jun 25, 2009 at 6:22 PM, Jeremy
Thomersonjer...@wickettraining.com wrote:
 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, Bobbybobby.hubb...@garmin.com 
 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:igor.vaynb...@gmail.com]
 Sent: Thursday, June 25, 2009 11:22 AM
 To: users@wicket.apache.org
 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, Bobbybobby.hubb...@garmin.com 
 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: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org