Hi,

I see some very unexpected behavior in getting the model object inside a 
list view. Here is my case:

-- The data classes
class Course {...}
class Person { private List addresses; ...getter/setters...}
class Address { private String street; private String city; 
...getter/setters... }

-- The components
class MyPage extends Page {
   public MyPage(...) {
       ...
       setModel(new CompoundPropertyModel(new Course(...)));     // 
<-------- setting Course as model object
       add(new MyPanel(...));
   }
}
class MyPanel extends Panel {
    public MyPanel(...) {
        setModel(new CompoundPropertyModel(new Person()));       // 
<------- setting Person as model object

        add(new ListView("addresses")) {
            protected void populateItem(ListItem item) {
                assert item.getModelObject() instanceof Address;      // 
<----- assert succeeds
                item.add(new 
Label("street"));                                    // <----- 
WicketException during rendering
            }
        }
    }
}

--The problem.
The assert in the method populateItem holds. However, the label will try 
to get the "street" property from a 'Course' instance. I expected it to 
get the property from the Address instance that was also seen in the assert.

--A possible cause.
If you debug the method onComponentTagBody() in Label(), you eventually 
see that the parent of the Label is a ListItem, but the parent of the 
ListItem is MyPage! I expected the parents to be a ListView, and then a 
MyPanel and only then a MyPage.

Is this a bug or I am missing something?

Regards,
     Erik.


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to