Igor Vaynberg wrote:Aha, but I solved a problem with a back button yesterday which was caused by the model (that I saved as a private instance variable of the page) getting out of sync with the actual model. The problem was that wicket components only call getters and setters on the model, but they cannot manage associations. In my case, I had a one to many relation in my model which was manipulated by the user (adding and removing items). In this case, just accessing the model from my private instance variable for the final save action on form submission gave the wrong result, even though the model as seen by the components on the page was correct (it was a copy of an old version including the relations). So what I learned from this is that the page objects themselves are not versioned, only the component models are. In other words, saving a model as a private instance variable can cause problems if the model has more operations than just getters and setters. In this particular case I am wondering about back button support for the selections instance variable. Here, if a user goes back to the previous version of the page and submits it, the selections instance variable is not updated to reflect the current version, even though the checkbox models are. The problem is that the selections instance variable is not retrieved from a model. If it would be part of a model and we would retrieve the selections through a component model then it would be ok. Is there a simple way to put the selections in a model of some dummy component just to get back button support? Thinking about this, I think it would also solve my previous problem with the back button. For instance: VersionedObject<Set> selections; // private instance variable // pseudo code class VersionedObject<T extends Serializable> extends Component { VersionedObject(String aId, T aObject) { super(aId, new Model(aObject)); } T get() { return (T) getModel().getObject(null); } } In this way, I can store any type of object as private instance variable and make sure that its properly versioned no matter what. Cheers Erik
|
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ Wicket-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-user
