thanks Sven

On Wed, Jan 11, 2012 at 6:46 PM, Sven Meier <s...@meiers.net> 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<Product>() {
>          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<Product>  model) {
>>   super(id, new CompoundPropertyModel(model));
>>
>>   add(new Label("name");
>>   add(new ProductImage("image", getDefaultModel());
>> }
>>
>> ProductImage extends Image {
>>   ProductImage(id, IModel<Product>  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

Reply via email to