1 16 package org.apache.cocoon.forms.formmodel; 17 18 import org.apache.avalon.framework.context.Context; 19 20 26 public class CaptchaFieldDefinition extends FieldDefinition { 27 28 private Context avalonContext; 29 private int length; 30 31 public CaptchaFieldDefinition(Context avalonContext) { 32 this.avalonContext = avalonContext; 33 } 34 35 38 public void initializeFrom(WidgetDefinition definition) throws Exception { 39 super.initializeFrom(definition); 40 41 if(definition instanceof CaptchaFieldDefinition) { 42 CaptchaFieldDefinition other = (CaptchaFieldDefinition)definition; 43 44 this.length = other.length; 45 46 } else { 47 throw new Exception ("Definition to inherit from is not of the right type! (at "+getLocation()+")"); 48 } 49 } 50 51 public Widget createInstance() { 52 CaptchaField field = new CaptchaField(this, avalonContext); 53 return field; 54 } 55 56 public int getLength() { 57 return length; 58 } 59 60 public void setLength(int length) { 61 checkMutable(); 62 this.length = length; 63 } 64 65 } 66 | Popular Tags |