The problem is that populateItem() is called at render time, and that the onClick() is called when you have been to the client and are processing the component listener. I have falled into this trap myself, and I can only advise you to use the following code, which is a lot more safer in any context:

final PageableListView list = new PageableListView("rows", data, 10)
{
   public void populateItem(ListItem listItem)
      {
         listItem.add(new Link("sjs") {
            public void onClick() {
               MyObject value = (MyObject) getParent().getModelObject();
               System.out.println(value.getName());
            }
      }
};

Note that all final keywords have disappeared and no hidden magic is remaining on keeping references to object between render and handling time.

Martijn


Phil Kulak wrote:

Maybe it's just late, but I can't seem to answer this question myself.
Will each model object in my list exist after the request has finished
with the following code, assuming that the list is wrapped in a
detachable model:

final PageableListView list = new PageableListView("rows", data, 10)
{
         public void populateItem(final ListItem listItem)
         {
                  final MyObject value = (MyObject) listItem.getModelObject();
                  listItem.add(new Link("sjs") {
                                public void onClick() {
                                         System.out.println(value.getName());
                                }
                  });
         }
};

or how about this:

final PageableListView list = new PageableListView("rows", data, 10)
{
         public void populateItem(final ListItem listItem)
         {
                  final MyObject value = (MyObject) listItem.getModelObject();
                  final String name = value.getName();
listItem.add(new Link("sjs") {
                                public void onClick() {
                                         System.out.println(name);
                                }
                  });
         }
};


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user




-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to