1 16 package org.apache.cocoon.forms.formmodel; 17 18 import java.util.Iterator ; 19 import java.util.Locale ; 20 21 import org.apache.cocoon.forms.FormContext; 22 import org.apache.cocoon.forms.validation.ValidationError; 23 import org.xml.sax.ContentHandler ; 24 import org.xml.sax.SAXException ; 25 26 31 public abstract class AbstractContainerWidget extends AbstractWidget implements ContainerWidget { 32 33 36 protected WidgetList widgets; 37 38 41 protected ValidationError validationError; 42 43 46 public AbstractContainerWidget(AbstractContainerDefinition definition) { 47 super(definition); 48 widgets = new WidgetList(); 49 } 50 51 56 public void initialize() { 57 Iterator it = this.getChildren(); 58 while(it.hasNext()) { 59 ((Widget)it.next()).initialize(); 60 } 61 62 super.initialize(); 63 } 64 65 public void addChild(Widget widget) { 66 widgets.addWidget(widget); 68 widget.setParent(this); 69 } 70 71 public boolean hasChild(String id) { 72 return widgets.hasWidget(id); 73 } 74 75 public Widget getChild(String id) { 76 return widgets.getWidget(id); 77 } 78 79 public Iterator getChildren() { 80 return widgets.iterator(); 81 } 82 83 public int getSize() { 84 return widgets.getWidgetList().size(); 85 } 86 87 98 public void readFromRequest(FormContext formContext) { 99 if (getCombinedState().isAcceptingInputs()) { 100 widgets.readFromRequest(formContext); 101 } 102 } 103 104 115 public boolean validate() { 116 if (!getCombinedState().isValidatingValues()) { 117 this.wasValid = true; 118 return true; 119 } 120 final boolean valid = widgets.validate(); 122 this.wasValid = super.validate() && valid; 123 return this.wasValid; 124 } 125 126 134 public void generateItemSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException { 135 if (getCombinedState().isDisplayingValues()) { 136 widgets.generateSaxFragment(contentHandler, locale); 137 } 138 } 139 } 140 | Popular Tags |