1 15 package org.apache.tapestry.form; 16 17 import java.util.List ; 18 19 import org.apache.tapestry.IMarkupWriter; 20 import org.apache.tapestry.IRender; 21 import org.apache.tapestry.IRequestCycle; 22 import org.apache.tapestry.valid.IFieldTracking; 23 import org.apache.tapestry.valid.IValidationDelegate; 24 import org.apache.tapestry.valid.IValidator; 25 import org.apache.tapestry.valid.ValidationConstraint; 26 import org.apache.tapestry.valid.ValidatorException; 27 28 35 public class MockDelegate implements IValidationDelegate 36 { 37 private IFormComponent _component; 38 39 private String _input; 40 41 private boolean _inError; 42 43 public MockDelegate() 44 { 45 this(false); 46 } 47 48 public MockDelegate(boolean inError) 49 { 50 _inError = inError; 51 } 52 53 public IFormComponent getFormComponent() 54 { 55 return _component; 56 } 57 58 public void setFormComponent(IFormComponent component) 59 { 60 _component = component; 61 } 62 63 public boolean isInError() 64 { 65 return _inError; 66 } 67 68 public String getFieldInputValue() 69 { 70 return _input; 71 } 72 73 public List getFieldTracking() 74 { 75 return null; 76 } 77 78 public void reset() 79 { 80 } 81 82 public void clear() 83 { 84 } 85 86 public void recordFieldInputValue(String input) 87 { 88 _input = input; 89 } 90 91 public void record(ValidatorException ex) 92 { 93 } 94 95 public void record(String message, ValidationConstraint constraint) 96 { 97 } 98 99 public void record(IRender errorRenderer, ValidationConstraint constraint) 100 { 101 } 102 103 public void writePrefix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, 104 IValidator validator) 105 { 106 writer.begin("span"); 107 writer.attribute("class", "prefix"); 108 } 109 110 public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle, 111 IFormComponent component, IValidator validator) 112 { 113 writer.attribute("class", "validation-delegate"); 114 } 115 116 public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, 117 IValidator validator) 118 { 119 writer.end(); 120 } 121 122 public void writeLabelPrefix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle) 123 { 124 } 125 126 public void writeLabelSuffix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle) 127 { 128 } 129 130 public boolean getHasErrors() 131 { 132 return false; 133 } 134 135 public IFieldTracking getCurrentFieldTracking() 136 { 137 return null; 138 } 139 140 public List getErrorRenderers() 141 { 142 return null; 143 } 144 145 } 146 | Popular Tags |