Currently, Click throws an exception if the same control is added multiple times to a Page or
Container. This ensures we don't accidentally have two controls with the same name, but it adds
usage problems for stateful Pages where we *do* want to replace existing controls and models. To
work with stateful pages we often end up with the following code:
private Field field;
public void onInit() {
if (!form.contains(field)) {
form.add(field);
}
}
or if you don't keep a reference to a control:
public void onInit() {
Field field = new Field();
if (!form.getControlMap().containsKey(field.getName())) {
container.add(field);
}
}
My feeling is that naming collisions within the same page/container is rather rare. So I propose we
change current behavior to replace the existing object instead of throwing an exception. If there is
a replacement we could log a message (in dev modes) that control x was replaced in container y,
providing some indication that a replacement took place.
regards
bob