this code is very bad, you should use models so that you do not end up
serializing your entities...

item.setModel(new CompoundPropertyModel(  item.getmodel()  ));
    ...
               item.add(new Link("edit"   , item.getmodel()   ) {
                   @Override
                   public void onClick() {
                       System.out.println("TEMPLATE NAME IN onClick(): "
                               +     getmodelobject()   .getEntity().getName());
                       setResponsePage(new
TemplateEditPage(    getmodel()   ));
                   }
               });

-igor

On Thu, Feb 12, 2009 at 5:57 AM, pieter claassen <[email protected]> wrote:
> Listviews with Links in them, sometimes fail to retrieve the object in the
> onClick() method the first time around. When I reload the page, the code
> works fine.
>
> Here is a test. In the listview below, I load the page and in the listview
> loop code, I correctly retrieve the item. Note that in the onClick() the
> modelobject is null.
>
> TEMPLATE NAME IN listview: first
> TEMPLATE NAME IN onClick(): null
>
> Reloading the page, and the problem goes away.
>
> TEMPLATE NAME IN listview: first
> TEMPLATE NAME IN onClick(): first
>
>
> This is using wicket 1.3.5. and db4o 7.8. This problem is normally there
> when I restart my application.
>
> Any ideas?
>
> Example code:
>
> ListView templateList = new ListView("listview", ModelConverter
>                .getModelList(templates, TemplateWebModel.class)) {
>            @Override
>            protected void populateItem(ListItem item) {
>                final TemplateWebModel templatewebmodel = (TemplateWebModel)
> item
>                        .getModelObject();
>                System.out.println("TEMPLATE NAME IN listview: "
>                        + templatewebmodel.getEntity().getName());
>
>                item.setModel(new CompoundPropertyModel(templatewebmodel));
>     ...
>                item.add(new Link("edit") {
>                    @Override
>                    public void onClick() {
>                        System.out.println("TEMPLATE NAME IN onClick(): "
>                                + templatewebmodel.getEntity().getName());
>                        setResponsePage(new
> TemplateEditPage(templatewebmodel));
>                    }
>                });
> ...
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to