This works!!! Thanks SO much. But is it the right and easiest way? Any other suggestions?
Thaaaaaanks! :) Eugene Malan wrote: > > Try replacing the Model's object instead of the actual Model. > > private EditFormModel editFormModel = new > CompoundPropertyModel<Functionsbereich>(el); > > replace > //f.setModel(new CompoundPropertyModel<Functionsbereich>(el)); > editFormModel.setObject(el); > > > On 16 Dec 2009, at 6:27 AM, Martin U wrote: > >> Iam totally confused. >> >> Iam using the Todo-List-Example from here : >> http://www.wicket-library.com/wicket-examples/ajax/todo-list.0 >> to play around with wicket. >> >> This example works, but i want to display a list of Entities from the >> Backend and edit one of them with my "new-entity"-Form. >> So i want to click on "edit" in a row and want to use the *same* >> *form *as i >> use to add a entity. How could i handle this? >> >> I tried sooo much but nothing works right. >> >> >> The "addForm" (showForm(target)) function works right. But in public >> void >> showForm(AjaxRequestTarget _t, Functionsbereich el) >> i deliver "el" which is my POJO and i cant figure out how to treat >> the Form >> to use now my new "Model"... >> I tried with modelChange() und mondelChanging() but nothing works >> =( allways >> the "empty Form" is shown ;( >> >> Thanks a lot for any help!! >> >> private final class FormContainer extends WebMarkupContainer{ >> >> private EditForm f; >> >> public FormContainer(String id) { >> super(id); >> setOutputMarkupId(true); >> >> >> add(f = (EditForm) new EditForm("form").setVisible(false)); >> add(new AjaxFallbackLink("link"){ >> >> @Override >> public void onClick(AjaxRequestTarget target) { >> showForm(target); >> } >> >> }); >> } >> >> public void showForm(AjaxRequestTarget _t){ >> f.setVisible(true); >> _t.addComponent(this); >> >> } >> >> /** Shows form with entity **/ >> public void showForm(AjaxRequestTarget _t, Functionsbereich >> el){ >> // add(f = new EditForm("link", el)); >> f.modelChanging(); >> f.setModel(new >> CompoundPropertyModel<Functionsbereich>(el)); >> >> >> f.modelChanged(); >> f.setVisible(true); >> >> _t.addComponent(this); >> >> } >> >> >> } >> >> private final class EditForm extends Form<Functionsbereich>{ >> >> public EditForm(String id){ >> this(id, new CompoundPropertyModel<Functionsbereich>(new >> Functionsbereich())); >> } >> >> public EditForm(String id, Functionsbereich _el){ >> super(id,new >> CompoundPropertyModel<Functionsbereich>(_el) ); >> } >> >> public EditForm(String id, >> CompoundPropertyModel<Functionsbereich> >> _model) { >> super(id, _model); >> >> >> setOutputMarkupId(true); >> add( new TextField("form_text", >> _model.bind("label"))); >> >> //add(new Label("vendor", _model.bind("vendor.name"))); >> >> >> } >> >> } > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > > -- View this message in context: http://old.nabble.com/Updating-Form-Elements-by-Ajax-with-new-POJO-Model-tp26810357p26811076.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
