String target = widgetEle.getAttribute("target");
String mode = widgetEle.getAttribute("mode");
String cache = widgetEle.getAttribute("cache");
String order = widgetEle.getAttribute("order");
//
WidgetConfig widgetConfig = new WidgetConfig(positionConfig);
widgetConfig.setStyleId(styleId);
widgetConfig.setStyleClass(styleClass);
widgetConfig.setContext(context);
widgetConfig.setTarget(target);
widgetConfig.setMode(mode);
widgetConfig.setCache("".equals(cache) ? 0 : Integer.parseInt(cache));
widgetConfig.setOrder("".equals(order) ? 0 : Integer.parseInt(order));
// preference element
Element preferenceEle = DomUtils.getChildElementByTagName(widgetEle, "preference");
if (preferenceEle != null) {
for (Element prefEle : DomUtils.getChildElements(preferenceEle)) {
String name = prefEle.getAttribute("name");
String value = DomUtils.getTextValue(prefEle);
widgetConfig.getPreferences().put(name, value);
}
}
// navigation
Element navigationEle = DomUtils.getChildElementByTagName(widgetEle, "navigation");
if (navigationEle != null) {
Map<String, String> navigationMap = new HashMap<String, String>();
List<Element> eventEles = DomUtils.getChildElementsByTagName(navigationEle, "event");
for (Element eventEle : eventEles) {
String eventOn = eventEle.getAttribute("on");
String eventTo = DomUtils.getTextValue(eventEle);
navigationMap.put(eventOn, eventTo);
}
widgetConfig.setNavigationMap(navigationMap);
}
// validation
Element validationEle = DomUtils.getChildElementByTagName(widgetEle, "validation");
if (validationEle != null) {
widgetConfig.setValidationForm(validationEle.getAttribute("formId"));
Element targetEle = DomUtils.getChildElementByTagName(validationEle, "target");
if (targetEle != null) {
widgetConfig.setValidationTarget(DomUtils.getTextValue(targetEle).trim());
}
Element groupsEle = DomUtils.getChildElementByTagName(validationEle, "groups");
if (groupsEle != null) {
List<String> validationGroups = new ArrayList<String>();
List<Element> groupEles = DomUtils.getChildElementsByTagName(groupsEle, "group");
for (Element groupEle : groupEles) {
validationGroups.add(DomUtils.getTextValue(groupEle).trim());
}
widgetConfig.setValidationGroups(validationGroups);
}
}
//
positionConfig.addWidgetConfig(widgetConfig);
// pageConfig.addWidgetConfig(position, widgetConfig);