if (datatypeElement == null) {
throw new Exception("A nested datatype element is required for the widget "
+ widgetElement.getTagName() + " at " + DomHelper.getLocation(widgetElement));
}
Datatype datatype = datatypeManager.createDatatype(datatypeElement, false);
//---- parse "initial-value"
Object initialValue = null;
Element initialValueElement = DomHelper.getChildElement(widgetElement, Constants.DEFINITION_NS, "initial-value", false);
if (initialValueElement != null) {
String localeValue = DomHelper.getAttribute(initialValueElement, "locale", null);
Locale locale = localeValue == null ? null : I18nUtils.parseLocale(localeValue);
String value = DomHelper.getElementText(initialValueElement);
ConversionResult result = datatype.convertFromString(value, locale);
if (!result.isSuccessful()) {
throw new Exception("Cannot parse initial value '" + value + "' at " +
DomHelper.getLocation(initialValueElement));
}
initialValue = result.getResult();