1 16 package org.apache.cocoon.forms.formmodel; 17 18 import org.apache.cocoon.forms.datatype.SelectionList; 19 20 25 public class FieldDefinition extends AbstractDatatypeWidgetDefinition { 26 private boolean required; 27 private SelectionList suggestionList; 28 29 public Widget createInstance() { 30 Field field = new Field(this); 31 return field; 32 } 33 34 37 public void initializeFrom(WidgetDefinition definition) throws Exception { 38 if(!(definition instanceof FieldDefinition)) { 39 throw new Exception ("Definition to inherit from is not of the right type! (at "+getLocation()+")"); 40 } 41 super.initializeFrom(definition); 42 43 FieldDefinition other = (FieldDefinition)definition; 44 45 this.required = other.required; 46 47 if (suggestionList == null) { 48 suggestionList = other.getSuggestionList(); 49 } 50 } 51 52 public boolean isRequired() { 53 return required; 54 } 55 56 public void setRequired(boolean required) { 57 checkMutable(); 58 this.required = required; 59 } 60 61 public SelectionList getSuggestionList() { 62 return this.suggestionList; 63 } 64 65 public void setSuggestionList(SelectionList list) { 66 this.suggestionList = list; 67 } 68 } 69 | Popular Tags |