The value "first" is a field on a template, that is retrieved as one
template from the list of all templates, from a db4o database using a DAO
class.

List<Template> templates = getTemplateFactory().getAll();

So, this list is *always* retrieved correctly. Each of the templates are
correctly backed by a database object and I can retrieve any field on any
one of them.
Each one of the template objects are wrapped in a thin wrapper where they
are converted from a "heavy" object (Template) to a thin webmodel
(TemplateWebModel)

List templatewebmodels = ModelConverter.getModelList(templates,
TemplateWebModel.class)

In the listview block, I set the model for each list iteration:

final TemplateWebModel templatewebmodel = (TemplateWebModel)
item.getModelObject();
item.setModel(new CompoundPropertyModel(templatewebmodel));

and when I want to access the database object, I use:

getModelObject().getEntity()

This approach works both in the listview block of code, but not in any
onClick() methods of Links that I include in the listview, just after I
started my application. The second time around, things work fine.

Is this possibly a wicket problem?

Rgrds,
Pieter



On Thu, Feb 12, 2009 at 3:06 PM, Martin Makundi <
[email protected]> wrote:

> Where do you set the value "first"?
>
> **
> Martin
>
> 2009/2/12 pieter claassen <[email protected]>:
> > 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