Thanks for your reply. I've tried it but it still gave the same error.
However I also tried the following modified version of your idea:
In AddressPanel.java:
@Override
protected void onInitialize() {
super.onInitialize();
Object o = getDefaultModelObject();
setDefaultModel(new CompoundPropertyModel(getDefaultModelObject()));
}
With the above code I can now load the page, also the getDefaultModelObject()
returns the correct Address instance. Unfortunately upon submitting the form I
get the same exception again ("No get method defined for class: class
foo.HomePage expression: street").
By the way: am I doing things "the Wicket way"? Is this how you would reuse
parts of a form in Wicket?
Best regards,
Bob
> Hi,
>
> I think you need to build a CompoundPropertyModel inside the component
> itself. Override onInitialize method of AddressPanel and try with
> something like this:
>
> @Override
> protected void onInitialize() {
> super.onInitialize();
> setDefaultModel(new CompoundPropertyModel(getDefaultModel()));
> }
>
>
> > Hi list,
> >
> > I've created a reusable form component for editing an address, called
> AddressPanel. It inherits from FormComponent and consists of multiple text
> fields for inputting data, instances of the component get added to a Form
> instance.
> >
> > How do I use this component together with a CompoundPropertyModel? I'm using
> the following code to add the component to the form:
> >
> > Form<HomePage> form = new Form<HomePage>("form", new
> CompoundPropertyModel<HomePage>(this)); // HomePage has an instance of Person
> called person
> > form.add(new TextField<String>("person.firstname"));
> > form.add(new AddressPanel("person.address"));
> >
> > However this gives the following exception: "Last cause: No get method
> defined for class: class foo.HomePage expression: street."
> >
> > "street" is a text field that is added to the AddressPanel. Is it possible
> to have the "street" field bound to person.address.street without renaming the
> text field inside AddressPanel? I don't want to rename it since this way I
> can't reuse the component for other entities that have addresses.
> >
> > Best regards,
> >
> > Bob
> >
> >
> > Think green - keep it on the screen.
> >
> > This e-mail and any attachment is for authorised use by the intended
> recipient(s) only. It may contain proprietary material, confidential
> information and/or be subject to legal privilege. It should not be copied,
> disclosed to, retained or used by, any other party. If you are not an intended
> recipient then please promptly delete this e-mail and any attachment and all
> copies and inform the sender. Thank you.
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
Think green - keep it on the screen.
This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an intended
recipient then please promptly delete this e-mail and any attachment and all
copies and inform the sender. Thank you.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]