On Wed, Nov 3, 2010 at 10:34 PM, Troy Cauble <[email protected]> wrote:
> Typically, one sets a FormComponent's ID to match the data model. > My form is generated from data, so the IDs are a recursive set of > "fieldFrag", > "list", "blockFrag", "label", "value" and RepeatingView#newChildID(). > > My data on the other hand is represented by HashMap<String,String> > and CompoundPropertyModel. The keys are generated. > > This works fine when my form has a Model before I construct it. > Where each FormComponent is constructed I do this. > > new PropertyModel<String>(getDefaultModel(), key); > > Anyway, PM doesn't like it when the first arg is null. So I can't support > using setDefaultModel() after the form components are instantiated. > > How can I support setDefaultModel() ? ComponentPropertyModel looks > like it might work if it wasn't read only. > > Thanks, > -troy > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > If your form is using a compoundpropertymodel, your form components don't need an explicit property model. class YourForm extends Form { setModel(IModel model) { // ensure that you always get a compoundpropertymodel: super.setModel(new CompoundPropertyModel(model)); } } Form form = new YourForm(); form.setModel(new LoadableDetachableFooBarSomethingOrOtherModel()); form.add(new TextField("someKeyThatRepresentsAPropertyOnTheThingReturnedByAboveModel")); That should work. -- Jeremy Thomerson http://wickettraining.com *Need a CMS for Wicket? Use Brix! http://brixcms.org*
