basically what you have to understand is that compound models are shortcuts,
and what you are using them for is a kind of abuse.

that said here are some hints on how to do what you want

you do

class person { private Address address; }
class address { private string street; }

form f=new form(new compoundpropertymodel(person));
f.add(new addresspanel("address"));

class addresspanel extends panel {
public addresspanel(string id) {
     super(id);
     add(new textfield("street"));
}

the reason the above doesnt work is that textfield is bound to the "street"
property, so it will try to look up person.street. what you need it to do is
to lookup person.address.street. so what you need to do is to insert
"address" into the property path. you can do this by assigning a model to
the panel that performs the insertion. a good place to do this is by
overriding addresspanel.initmodel() and returning the model that does the
trick.

-igor



On 5/1/07, John RDF <[EMAIL PROTECTED]> wrote:


I am trying to create Panels that represent each of my domain objects i.e.
Address, Name, Referee (Contains Name and Address) etc..

I then have a CompoundPropertyModel over a value object which represents
the
entire form. In this I want to map its properties (and sub properties
etc)..
I am having trouble finding ways of nesting models or a single model to
get
the desired behaviour..

This is the hierarchy of Components I want is

MyForm
-->NamePanel
-->AddressPanel
-->RefereePanel
---->NamePanel
---->RefereePanel
---->email:TextField
---->telephone:TextField

The panels contain simple TextFields (not shown)

The hierarchy of value objects is

-->MyFormVO
---->name:NameDO
---->address:AddressDO
---->referee:RefereeDO
------>NameDO
------>AddressDO

What would be the most effective nesting of models?

As the panels need to be reusable and modifiable at a later date I don't
want to specify any properties in parents or children in pages/forms..

I was hoping that the component names would drill down depending on
nesting
but it seems that it is trying to find the expression "title" rather than
"name.title" or "referee.name.title" which is what I would hope nesting a
panels inside the form.

Is there a model that does this for nested panels?












                public MainForm(final String componentName) {
                        super(componentName, new CompoundPropertyModel(new
FormValueObject()));
...

                        add(new NamePanel("name", new
PropertyModel(getModel(), "name")));
                        add(new AddressPanel("currentAddress", new
PropertyModel(getModel(),
"currentAddress")));

In the name and address panels I have used a similar approach..





--
View this message in context:
http://www.nabble.com/Resuable-Panels-and-Model-nesting-tf3675608.html#a10270774
Sent from the Wicket - User mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to