// FormDefinition is the *only* kind of widget that has an optional id
widgetDefinition.setId(DomHelper.getAttribute(widgetElement, "id", ""));
} else {
String id = DomHelper.getAttribute(widgetElement, "id");
if (id.indexOf('/') != -1 || id.indexOf('.') != -1) {
throw new FormsException("A widget name cannot contain '.' or '/' as this conflicts with widget paths.",
DomHelper.getLocationObject(widgetElement));
}
// NewDefinitions are allowed to have a : in their id because they can look up
// class widgets from the library directly
if (id.indexOf(':') != -1 && !(widgetDefinition instanceof NewDefinition)) {
throw new FormsException("A widget name cannot contain ':' as this conflicts with library prefixes",
DomHelper.getLocationObject(widgetElement));
}
widgetDefinition.setId(id);
}
// state
String stateValue = DomHelper.getAttribute(widgetElement, "state", null);
if (stateValue != null) {
WidgetState state = WidgetState.stateForName(stateValue);
if (state == null) {
throw new FormsException("Unknown value '" + stateValue +"' for state attribute.",
DomHelper.getLocationObject(widgetElement));
}
widgetDefinition.setState(state);
}