Re: Model problem with my own component
thanks Sven On Wed, Jan 11, 2012 at 6:46 PM, Sven Meier wrote: > Hi, > > >> add(new ProductImage("image", getDefaultModel()); > > this line is causing the null product. > > >> I thought when setting the default model all the children are visited and >> model updated.? > > No, not at all. Either you have to do that by yourself or you have to give > ProductImage a more intelligent model: > > add(new ProductImage("image", new AbstractReadOnlyModel() { > public Product getObject() { > return getDefaultModel().getObject(); > } > }); > > Hope this helps > Sven > > Am 11.01.2012 08:01, schrieb Wayne W: >> >> Hello, >> >> I cannot get my component model to update correctly when being set. I >> have list of products and when I click on the name via ajax I update a >> Product panel to display the info. In that panel I have my component >> that displays the image of the product. sudo code: >> >> ProductPanel(id, IModel model) { >> super(id, new CompoundPropertyModel(model)); >> >> add(new Label("name"); >> add(new ProductImage("image", getDefaultModel()); >> } >> >> ProductImage extends Image { >> ProductImage(id, IModel model) { >> super( id, model); >> >> Product p = getDefaultModelObject(); >> // p always null >> >> } >> >> >> AjaxLink() { >> onclick(target) { >> productPanel.setDefaultModel(getModel()); >> target.add(productPanel); >> }} >> >> >> When I click on the link the name is updated and displayed correctly. >> However in the ProductImage component the product is always null. I >> thought when setting the default model all the children are visited >> and model updated.? I;ve tried debugging but get cannot figure it out. >> >> Any ideas? >> >> - >> 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: Model problem with my own component
Hi, > add(new ProductImage("image", getDefaultModel()); this line is causing the null product. > I thought when setting the default model all the children are visited and model updated.? No, not at all. Either you have to do that by yourself or you have to give ProductImage a more intelligent model: add(new ProductImage("image", new AbstractReadOnlyModel() { public Product getObject() { return getDefaultModel().getObject(); } }); Hope this helps Sven Am 11.01.2012 08:01, schrieb Wayne W: Hello, I cannot get my component model to update correctly when being set. I have list of products and when I click on the name via ajax I update a Product panel to display the info. In that panel I have my component that displays the image of the product. sudo code: ProductPanel(id, IModel model) { super(id, new CompoundPropertyModel(model)); add(new Label("name"); add(new ProductImage("image", getDefaultModel()); } ProductImage extends Image { ProductImage(id, IModel model) { super( id, model); Product p = getDefaultModelObject(); // p always null } AjaxLink() { onclick(target) { productPanel.setDefaultModel(getModel()); target.add(productPanel); }} When I click on the link the name is updated and displayed correctly. However in the ProductImage component the product is always null. I thought when setting the default model all the children are visited and model updated.? I;ve tried debugging but get cannot figure it out. Any ideas? - 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
Model problem with my own component
Hello, I cannot get my component model to update correctly when being set. I have list of products and when I click on the name via ajax I update a Product panel to display the info. In that panel I have my component that displays the image of the product. sudo code: ProductPanel(id, IModel model) { super(id, new CompoundPropertyModel(model)); add(new Label("name"); add(new ProductImage("image", getDefaultModel()); } ProductImage extends Image { ProductImage(id, IModel model) { super( id, model); Product p = getDefaultModelObject(); // p always null } AjaxLink() { onclick(target) { productPanel.setDefaultModel(getModel()); target.add(productPanel); }} When I click on the link the name is updated and displayed correctly. However in the ProductImage component the product is always null. I thought when setting the default model all the children are visited and model updated.? I;ve tried debugging but get cannot figure it out. Any ideas? - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org