Hi all, I have a question concerning the difference between Component#setDefaultModelObject(final Object object) and getDefaultModel().setObject(object), like described in javadoc
/** * Sets the backing model object. Unlike <code>getDefaultModel().setObject(object)</code>, this * method checks authorisation and model comparator, and invokes <code>modelChanging</code> and * <code>modelChanged</code> if the value really changes. ... The default model comparator uses equals, to determine changes of the model. My question is, why setDefaultModelObject checks that? We often ran into problems when a form saves an new object, because in our programming model, we do not implement the persistence id into our equals, and when we write the onSubmit()-ed saved model into the form back, our model is not getting the "fresh" state (with id). (for us, its still equal, and we want it like this, but next clicks or savings create duplicate entry errors on database side) Yes, we can use form.getDefaultModel().setObject(object), but this often leads in bugs, because you easily forget it; setDefaultModelObject() is such a standard. My first thought, on finding the method setModelObject of the form itself, was: ah, this is the feature method, really changing the object, but on a second look setModelObject() of the form also just delegates to component.setDefaultModelObject(), rather then getDefaultModel().setObject(). Could someone explain why is it like it is? May I do not see the clue... Is it really wanted by wickets way of usage, calling getDefaultModel().setObject(object) if someone want to change the model of a form without equal-checks? kind regards Patrick --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org