protected void init() throws Exception {
super.init();
selectTag = (SelectTag)findAncestor(SelectTag.class);
if (selectTag == null) {
throw new ConfigException("A listoptions tag must be nested in a select tag!");
}
if (selectTag.getListModel() == null) {
throw new ConfigException("A listoptions tag requires a listModel in select tag '" + selectTag.getName() + "'!");
}
if (selection != null && !selectTag.getGroupModel().isSelectionAvailable()) {
if (selection instanceof String) {
key = (String)selection;
if (!selectTag.isSelectable(key)) {
throw new ConfigException("A selected list option for select '" + selectTag.getName() + "' contains invalid value '" + key + "'!");
}
} else if (selection instanceof String[]) {
String[] strings = (String[])selection;
if (!selectTag.getGroupModel().isMultiple() && strings.length > 1) {
throw new ConfigException("A single selection must be of size <= 1 in '" + selectTag.getName() + "'!");
}
keys = new HashSet(strings.length);
for (int i = 0; i < strings.length; i++) {
if (!selectTag.isSelectable(strings[i])) {
throw new ConfigException("A selected list option for select '" + selectTag.getName() + "' contains invalid value '" + strings[i] + "'!");
}
keys.add(strings[i]);
}
} else {
throw new ConfigException("Unsupported object type in selection: " + keys.getClass() + " (must be String or String[])");
}
}
}