Hi there,

I need to track all modifications made to FormComponents' target objects in 
order to generate some kind of changelog when saving my entity. Therefore I 
created a custom Model that wraps the components' default model and remembers 
the original value when setObject is called.

This works fine but breaks for FormComponents that use 
FormComponent#updateCollectionModel to update their model object (CheckGroup, 
ListMultipleChoice, MultiFileUploadField) because of the implementation of 
updateCollectionModel, which manipulates the collection in place and calls 
setObject with the already updated collection (see here: http://bit.ly/1nPoniW 
<http://bit.ly/1nPoniW>).

I tried to find another way to react upon model object changes and found 
Page#componentModelChanging (http://bit.ly/ZZdiRr), which is called from within 
Component#modelChanging. Unfortunately this method is final void, and thus 
can’t be overridden (does this make sense? Nothing can’t be done with the 
„component" parameter …).

Any pointer where I should look to get this done with the existing Wicket code 
(I use Wicket 6.17.0)?

I could think of several solutions for supporting that usecase:

* FormComponent#updateCollectionModel: don’t update the collection in place but 
hand the unmodified collection to setObject
* remove the „final“ from Page#componentModelChanging and add at least a 
„protected“
* my favorite: introduce a new listener for component model changes, so that 
it’s easy to hook into that process, analogue to 
IComponentOnBeforeRenderListener and friends (e.g. IModelUpdateListener, called 
before and after model updates ...)

What do you think?

Cheers,
   -Tom


Reply via email to