You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Romain Pelisse <be...@gmail.com> on 2010/06/01 15:41:20 UTC

populateItem() not invoked on my custom list

Hi,

I got a rather dumb issue. As I've been using Wicket only for 2 weeks,
I'm pretty sure that my issue is just a misuse more than a bug.
I implemented a Custom list by inheriting PropertyViewList. This
custom list is then placed into a Panel, which it is itself added to
the Page.

       // The panel constructor
       public MapResultsPanel(String id, Map<String,
List<ServiceTreeValue>> results) {
               super(id);
        // Construct the list of Entry
        List<MyEntry> myEntries = new ArrayList<MyEntry>();
        for (Entry<String, List<ServiceTreeValue>> servicesEntry :
results.entrySet()) {
         myEntries.add(new
MyEntry(servicesEntry.getKey(),servicesEntry.getValue()));

        }
        // Here comes my custom list
        Entries e = new Entries("entryList", myEntries);
        // Adding entries to the panel
        add(e);
    }


class Entries extends PropertyListView<MyEntry> {
        private static final long serialVersionUID = 1L;
        private final List<MyEntry> entries;
        public Entries(String id, List<MyEntry> entries) {
            super(id);
            this.entries = entries;
        }
       // This is not invoked at run time ...
        @Override
        protected void populateItem(ListItem<MyEntry> item) {
            for (MyEntry entry : entries) {
                item.add(new Label("key", entry.id));
                // ...
            }
        }
    }


However, at run time, nothing is displayed on my page and if I debug
the populateItem() method on my custom list implementation is not
called. Somebody on IRC suspected that my model might be empty but how
comes ?

I posted this code on paste bin also : http://pastebin.com/vEVrmDM4
(in case you want to tweak it)

Thanks for any help you can gave me, because I have exhausted most of
my options here...

--
Romain PELISSE,
"The trouble with having an open mind, of course, is that people will
insist on coming along and trying to put things in it" -- Terry
Pratchett
http://belaran.eu/

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


Re: populateItem() not invoked on my custom list

Posted by Sven Meier <sv...@meiers.net>.
You're not passing the entries to the super implementation - how should 
the PropertListView know what objects to iterate over?

public Entries(String id, List<MyEntry> entries) {

    super(id, entries);
}

protected  void  populateItem(ListItem<MyEntry>  item)  {
   MyEntry entry =  item.getModelObject();

   item.add(new  Label("key", entry.id));
   item.add(new  ServiceTreeValuesList("serviceTreeList", entry.services));
}

Sven



On 06/01/2010 03:41 PM, Romain Pelisse wrote:
> Hi,
>
> I got a rather dumb issue. As I've been using Wicket only for 2 weeks,
> I'm pretty sure that my issue is just a misuse more than a bug.
> I implemented a Custom list by inheriting PropertyViewList. This
> custom list is then placed into a Panel, which it is itself added to
> the Page.
>
>         // The panel constructor
>         public MapResultsPanel(String id, Map<String,
> List<ServiceTreeValue>>  results) {
>                 super(id);
>          // Construct the list of Entry
>          List<MyEntry>  myEntries = new ArrayList<MyEntry>();
>          for (Entry<String, List<ServiceTreeValue>>  servicesEntry :
> results.entrySet()) {
>           myEntries.add(new
> MyEntry(servicesEntry.getKey(),servicesEntry.getValue()));
>
>          }
>          // Here comes my custom list
>          Entries e = new Entries("entryList", myEntries);
>          // Adding entries to the panel
>          add(e);
>      }
>
>
> class Entries extends PropertyListView<MyEntry>  {
>          private static final long serialVersionUID = 1L;
>          private final List<MyEntry>  entries;
>          public Entries(String id, List<MyEntry>  entries) {
>              super(id);
>              this.entries = entries;
>          }
>         // This is not invoked at run time ...
>          @Override
>          protected void populateItem(ListItem<MyEntry>  item) {
>              for (MyEntry entry : entries) {
>                  item.add(new Label("key", entry.id));
>                  // ...
>              }
>          }
>      }
>
>
> However, at run time, nothing is displayed on my page and if I debug
> the populateItem() method on my custom list implementation is not
> called. Somebody on IRC suspected that my model might be empty but how
> comes ?
>
> I posted this code on paste bin also : http://pastebin.com/vEVrmDM4
> (in case you want to tweak it)
>
> Thanks for any help you can gave me, because I have exhausted most of
> my options here...
>
> --
> Romain PELISSE,
> "The trouble with having an open mind, of course, is that people will
> insist on coming along and trying to put things in it" -- Terry
> Pratchett
> http://belaran.eu/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>    


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