I am hoping that someone can shed some light upon a few questions I have around how Borders affect form processing. I have a Border that I commonly use within my application. When using this Border, I have noticed that all my FormComponents are being processed twice (validateRequired, convertInput, validateValidators, and updateModel all are called twice).
I have traced this down to the fact that both Form.visitFormComponentsPostOrder and Form.internalUpdateFormComponentModels initiate a second pass when the form's parent is a Border object (although these methods are slightly different -> one only looks to the immediate parent while the other traverses up all parents looking for a Border). First of all, is it expected behavior that conversion, validation, and updateModel can be called more than once per FormComponent during form processing? I would have expected that these methods would only be called once per request cycle (in particular, with updateModel). If this is not the case, I need to change my mindset a bit when it comes to developing FormComponents. Generally speaking, my implementations as well as Wicket's default FormComponent subclasses work fine when these methods are called twice. However, this is not always the case. For example, with ListMultipleChoice, a second call to these methods ends up updating the model incorrectly if my original model object value is null. The first call to updateModel in this case sets my model value to be the same instance as getConvertedInput(), which appropriately places my selected items in the model. However, on the second call to updateModel, one of the first things done is to call clear() on my model object, which clears the converted input as well (since they are the same collection). This results in the loss of my converted input, which in turn, blanks out my model. I have worked around this particular issue by insuring that my model object is never null in the first place -> if null, I make sure it is an empty collection in onBeforeRender... So I have two primary questions: 1.) Should I always code expecting that it is normal behavior for convertInput/updateModel to be called on my FormComponent instances more than once? 2.) Is it necessary that Borders cause a second pass? Part of me tends to want to steer away from Borders if this is the case... although I really love what they provide me. Thanks for any insight!
