1 16 package org.apache.cocoon.forms.formmodel; 17 18 import org.apache.avalon.framework.configuration.ConfigurationException; 19 import org.apache.cocoon.forms.util.DomHelper; 20 import org.w3c.dom.Element ; 21 22 27 public final class RepeaterDefinitionBuilder extends AbstractContainerDefinitionBuilder { 28 29 public WidgetDefinition buildWidgetDefinition(Element repeaterElement) throws Exception { 30 31 int initialSize = DomHelper.getAttributeAsInteger(repeaterElement, "initial-size", 0); 32 int minSize = DomHelper.getAttributeAsInteger(repeaterElement, "min-size", 0); 33 int maxSize = DomHelper.getAttributeAsInteger(repeaterElement, "max-size", Integer.MAX_VALUE); 34 35 if (minSize < 0) { 37 throw new ConfigurationException("min-size should be positive, at " + DomHelper.getLocationObject(repeaterElement)); 38 } 39 40 if (maxSize < 0) { 41 throw new ConfigurationException("max-size should be positive, at " + DomHelper.getLocationObject(repeaterElement)); 42 } 43 44 if (maxSize < minSize) { 45 throw new ConfigurationException("max-size should be greater that or equal to min-size, at " + DomHelper.getLocationObject(repeaterElement)); 46 } 47 48 initialSize = minSize > initialSize ? minSize : initialSize; 50 51 RepeaterDefinition repeaterDefinition = new RepeaterDefinition(initialSize, minSize, maxSize); 52 super.setupDefinition(repeaterElement, repeaterDefinition); 53 setDisplayData(repeaterElement, repeaterDefinition); 54 55 setupContainer(repeaterElement,"widgets",repeaterDefinition); 56 57 repeaterDefinition.makeImmutable(); 58 return repeaterDefinition; 59 } 60 } 61 | Popular Tags |