I am currently facing an issue for which I would appreciate the input of more experienced wicket developers. As they are sparse in the company I work for I turn to this mailinglist.
I have in my implementation a classic master-detail page. The master part is a RefreshingView, the detail view is a Panel with a Form on it to allow for updates. I have 1 single Model which is shared between the Page and the Panel. (Defined as member of the Page, passed into the Panel and the Form via their constructors) This all works like a charm (selecting, creating, updating, deleting, the works) even with some nice Ajax features thrown into the mix and everything. There is however 1 scenario that I can't get right. Things go pear shaped if the user gets validation errors during an update and then instead of correcting the validation errors he selects another detail in the master view. I'd obviously then want the detail to display the values of the newly selected ModelObject, instead I get the convertedValues from the previously selected ModelObject. I do know why this is happening: Model.setObject() doesn't do all the stuff that Form.setModelObject() does. (ie: clearing the convertedValues) What I don't know however is how to properly solve it. Calling Form.setModelObject() is not an option as it would mean exposing my form to the Page, which I do not want to do. It's supposed to be internal kitchen to the panel. What I would like to do is call Form.clearInput() whenever the ModelObject has been changed from outside the Panel. (ie A click on a row in the Refreshing view) But how can I detect this? Can anybody point me in the right direction of solving this the "wicket" way? So in Short: public Page { private Model selected = new Model(); public Page() { RefreshingView master = new RefreshingView("master") { protected void populateItem(Item item){ item.add(new AjaxEventBehavior("onClick"){ // Problem occurs here!!! Under normal circumstances DetailPanel is // updated correctly with values of the new item. // But after a validation error it is not, then the convertedValues // of the previous item are displayed instead selected.setObject(item) } // rest of master code not relevant // ... } } Panel detail = new DetailPanel("detail", selected); } } public DetailPanel() implements Panel { public DetailPanel(String id, Model model) { Form detailForm = new Form("detailForm", model); // rest of detail code not relevant // ... } }