WICKET-2684 is titled 'Provide a way to disable "Child component has a non-safe child id"'. It was closed as "invalid", but I think I have a use-case that wasn't considered when it was closed.

In our application we're moving to an approach of building most of our UI by adding panels to RepeatingViews. This allows us to build our pages without creating HTML files for each page, making it easy to keep HTML patterns consistent across the app.

As part of this strategy we've implemented a series of panels that each house a single input control and it's associated label. We might build a form like this:

---
FormPanel form = new FormPanel(newPanelId(), new CompoundPropertyModel(empModel));
addPanel(form);
form.addPanel(new TextFieldPanel("firstName"));
form.addPanel(new TextFieldPanel("lastName"));
---

"addPanel(...)" is a method we implement on our pages and container panels that simply adds the given component to a RepeatingView on the parent. The non-numeric child ID warning would be triggered twice here, for the text field panels, but these IDs are required for the example to work with CompoundPropertyModel.

BTW to use CompoundPropertyModel as shown above, we've created something called a DelegateModel:

---
public class DelegateModel<T> implements IModel<T> {

    private Component component;

    public DelegateModel(Component component) {
        this.component = component;
    }
    public T getObject() {
        IModel<T> model = (IModel<T>) component.getDefaultModel();
        return model != null ? model.getObject() : null;
    }
    public void setObject(T object) {
        IModel<T> model = (IModel<T>) component.getDefaultModel();
        if (model != null) {
            model.setObject(object);
        }
    }
}
---

We then create our TextFieldPanel like this:

---
public TextFieldPanel(String id) {
    this(id, null);
}
public TextFieldPanel(String id, IModel model) {
    super(id, model);
    add(new TextField("field", new DelegateModel(this)));
}
---

This seems to work well, except for the slew of warnings about non-safe child IDs.

In WICKET-2684, Igor advised to "use a low-level repeater where you have total control - RepeatingView", which we're doing, but later warned "you do realize that if you use nonnumeric ids some things will break".

So I have two questions:

1. Is this use-case enough to re-open WICKET-2684 to remove the warning (or at least relocate it if, for example, ListView depends on it)? Or should I just silence the warning in my log4j config and move on? 2. Is there really something in AbstractRepeater/RepeatingView that depends on numeric IDs? I can't see anything myself, but I'd like to know in case it interferes with our panel-based approach.

Thanks and sorry for the longish post.

jk


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to