protected void populateItem(ListItem<ComponentFactory> item) {
final int underlyingViewNum = item.getIndex();
final ComponentFactory componentFactory = item.getModelObject();
final AbstractLink link = new AjaxLink<Void>(ID_VIEW_LINK) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
for(int i=0; i<MAX_NUM_UNDERLYING_VIEWS; i++) {
final Component component = underlyingViews[i];
T dummyModel = dummyOf(model);
if(component != null) {
final boolean isSelected = i == underlyingViewNum;
applyCssVisibility(component, isSelected);
component.setDefaultModel(isSelected? model: dummyModel);
}
}
selectorPanel.selectedComponentFactory = componentFactory;
target.add(selectorPanel, views);
}
};
String name = nameFor(componentFactory);
Label viewTitleLabel = new Label(ID_VIEW_TITLE, name);
viewTitleLabel.add(new CssClassAppender(StringExtensions.asLowerDashed(name)));
link.add(viewTitleLabel);
item.add(link);
link.setEnabled(componentFactory != selectorPanel.selectedComponentFactory);
}
private String nameFor(final ComponentFactory componentFactory) {
return componentFactory instanceof CollectionContentsAsUnresolvedPanelFactory ? "hide" : componentFactory.getName();
}