Hi there,
I'm new to wicket and got a problem, I searched google and the mailing list for
2 days now but can't find what I'm searching for, here is an reduced example of
what I'm trying to do.
This is very simplified and not the domain I'm working in, this is just used for
ease. I'm using wicket:6:16:0.
The Example in short: I have a person with multiple addresses. For the person
there is a form with a textfield for the name. Under that textfield is an ajax
link to add a panel containing an form for an address. The background-model is a
class person with a name string and a list of addresses and an address class
with a street/city string.
My problem now is how i can dynamically add addresses to that person.

private String name;
private List<Address> addresses;
private String street;
private String city;

public Address(String id, IModel<Address> model) {
  super(id, model);
  Form<?> form = new Form<Void>("form");
  TextField<String> street = new TextField<String>("street");
  TextField<String> city = new TextField<String>("city");
    <form wicket:id="form">
      <input type="text" wicket:id="street"/>
      <input type="text" wicket:id="city"/>

    <form wicket:id="form">
      <input type="text" wicket:id="name"/>
      <div wicket:id="addresses"/>
      <a href="#" wicket:id="addAddress">add address</a>
public class PersonPage extends WebPage {
    Person person;
    public PersonPage() {
      person = new Person();
      setDefaultModel(new CompoundPropertyModel<Person>(person);
      Form<?> form = new Form<Void>("form");
      TextField<String> name = new TextField<String>("name");

     //And here the troube begins, do I use an ListView? If so for AddressPanel
I think, but which model do I give to it?

      AjaxSubmitLink addLink = new AjaxSubmitLink("addAddress", form) {
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
          // Do I now create a new Address or AddressPanel? If I create an
AddressPanel which Model do I use? How is the Address appended to the addresses
list in Person?

many thanks in advance

Reply via email to