are you sure the parent of the listitem is really the page, i find that unlikely.

but your code wouldnt work either way

you are adding the label without a model to the listitem. when the label renders it is going to look for the first component in its upwards hierarchy with the compound model, and what it should find is the panel with the person compound property model. then it is going to try to find [ person.street] property and fail.

to fix this you need to make the listitem's model compound as well. the easiest way is to  extend PropertyListView instead of ListView

makes sense?

-igor


On 10/30/06, Erik van Oosten <[EMAIL PROTECTED]> wrote:
Here is the same pseudo code, but now laid out for better readability.
I appreciate any background before I file this as a bug.

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

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

        add(new ListView("addresses")) {
            protected void populateItem(ListItem item) {
                // assertion succeeds, model object is an *Address*
                assert item.getModelObject () instanceof Address;
                // *WicketException* during rendering phase
                item.add(new Label("street"));
            }
        }
    }
}

--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.

I am missing something or is this a bug?

Regards,
     Erik.

--
Erik van Oosten
http://day-to-day-stuff.blogspot.com/


-------------------------------------------------------------------------
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

-------------------------------------------------------------------------
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