You need to set the CompoundPropertyModel on the parent object. In your
example the page. Try the following code:

           customer = new Customer();
           customer.setFirstName("Jimmy");
           customer.setLastName("Dean");
           customer.getAddress().setStreet("123 Easy Street");

           myModel = new CompoundPropertyModel<Customer>(customer);
           setDefaultModel(myModel); //This sets the page's model, which is
the parent to the label's in question

           add(new Label("firstName"));
           add(new Label("lastName"));
           add(new Label("street.address"))


On Sun, Jun 12, 2011 at 6:14 PM, Brian Lavender <[email protected]> wrote:

> Is it possible to use a compound property model for a label?
>
> I tried adding labels using the following, but when I run it,
> the label comes out with what appears to be a reference to the
> model.
>
>            customer = new Customer();
>            customer.setFirstName("Jimmy");
>            customer.setLastName("Dean");
>            customer.getAddress().setStreet("123 Easy Street");
>
>            myModel = new CompoundPropertyModel<Customer>(customer);
>
>            firstNameLabel = new Label("firstName",myModel);
>            add(firstNameLabel);
>            lastNameLabel = new Label("lastName",myModel);
>            add(lastNameLabel);
>            add(new Label("street.address", myModel))
>
> Code                                            Result
> firstName from Compound Property Model
>  com.brie.dtoo.Customer@7cb44d
> lastName from Compound Property Model
> com.brie.dtoo.Customer@7cb44d
> street.address from Compound Property Model
> com.brie.dtoo.Customer@7cb44d
>
> brian
> --
> Brian Lavender
> http://www.brie.com/brian/
>
> "There are two ways of constructing a software design. One way is to
> make it so simple that there are obviously no deficiencies. And the other
> way is to make it so complicated that there are no obvious deficiencies."
>
> Professor C. A. R. Hoare
> The 1980 Turing award lecture
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to