Warren, Something like this?
public class HomePage extends WebPage { private List<Vendor> vendors = Arrays.asList(new Vendor("v1"), new Vendor("v2")); private Vendor vendor = new Vendor("default vendor"); public HomePage(final PageParameters parameters) { Form<Void> form = new Form<Void>("form"); add(form); // use your existing LDM instead of this hard-wired List of vendors but // make sure you merge your edits properly! form.add(new ListChoice<Vendor>("vendors", new PropertyModel<Vendor>(this, "vendor"), vendors)); Form<Void> editForm = new Form<Void>("vendorEditForm"); add(editForm); editForm.add(new TextField<Vendor>("name", new PropertyModel<Vendor>(this, "vendor.name"))); } private class Vendor implements Serializable{ private String name; protected Vendor(String name) {this.name = name;} public String toString(){return name;} // safer to have accessors & mutators } // safer to have accessors & mutators } Regards - Cemal jWeekend OO & Java Technologies, Wicket Training and Development http://jWeekend.com Warren Bell-3 wrote: > > How should I set up my model for the following situation. I have a form > with a ListChoice and a TextField. The TextField needs to access a > property of the object selected of the ListChoice. I have it all working > using a ValueMap, but that seems like overkill to use a ValueMap for one > object. Here is how I have it: > > super(new CompoundPropertyModel<ValueMap>(new ValueMap())); > > ListChoice<Vendor> vendorListChoice = new ListChoice<Vendor>("vendor", > new LoadableDetachableModel<List<Vendor>>(){...}, new > IChoiceRenderer<Vendor>(){...}); > > TextField<String> accountNumberField = new > TextField<String>("vendor.accountNumber"); > > I thought I could do something like this: > > super(new CompoundPropertyModel<Vendor>(new Vendor())); > > The ListChoice is the same as above and the TextField like this: > > TextField<String> accountNumberField = new > TextField<String>("accountNumber"); > > The problem with this is that the ListChoice is trying to set a property > on the model named vendor when I realy want the selected ListChoice > vendor object be the model object and have the TextField access the > accountNumber property of the ListChoice vendor. > > How should I set up my model to deal with this type of situation or is a > ValueMap the best way? > > Thanks, > > Warren > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > > -- View this message in context: http://www.nabble.com/Model-question---tp24978225p24979290.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org