1 16 package org.apache.cocoon.woody.formmodel; 17 18 import org.apache.cocoon.woody.util.DomHelper; 19 import org.apache.cocoon.woody.Constants; 20 import org.w3c.dom.Element ; 21 22 27 public class RepeaterDefinitionBuilder extends AbstractWidgetDefinitionBuilder { 28 29 public WidgetDefinition buildWidgetDefinition(Element repeaterElement) throws Exception { 30 31 int initialSize = DomHelper.getAttributeAsInteger(repeaterElement, "initial-size", 0); 32 33 RepeaterDefinition repeaterDefinition = new RepeaterDefinition(initialSize); 34 setLocation(repeaterElement, repeaterDefinition); 35 setId(repeaterElement, repeaterDefinition); 36 setDisplayData(repeaterElement, repeaterDefinition); 37 setValidators(repeaterElement, repeaterDefinition); 38 39 Element widgetsElement = DomHelper.getChildElement(repeaterElement, Constants.WD_NS, "widgets", true); 40 Element [] widgetElements = DomHelper.getChildElements(widgetsElement, Constants.WD_NS); 42 for (int i = 0; i < widgetElements.length; i++) { 43 WidgetDefinition widgetDefinition = buildAnotherWidgetDefinition(widgetElements[i]); 44 repeaterDefinition.addWidgetDefinition(widgetDefinition); 45 } 46 47 return repeaterDefinition; 48 } 49 } 50 | Popular Tags |