KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > pets > PetShopValidationDelegate


1 package org.apache.tapestry.pets;
2
3 import org.apache.tapestry.IMarkupWriter;
4 import org.apache.tapestry.IRequestCycle;
5 import org.apache.tapestry.form.IFormComponent;
6 import org.apache.tapestry.valid.IValidator;
7 import org.apache.tapestry.valid.ValidationDelegate;
8
9 public class PetShopValidationDelegate extends ValidationDelegate {
10
11     public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle,
12             IFormComponent component, IValidator validator) {
13         if (isInError(component)) {
14             writer.attribute("class", "field-error");
15         }
16     }
17
18     public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle,
19             IFormComponent component, IValidator validator) {
20         if (isInError(component)) {
21             writer.print(" ");
22             writer.beginEmpty("img");
23             writer.attribute("src", "./images/bzzt_wrong.gif");
24             writer.attribute("height", 16);
25             writer.attribute("width", 16);
26         }
27     }
28
29     public void writeLabelPrefix(IFormComponent component,
30             IMarkupWriter writer, IRequestCycle cycle) {
31         if (isInError(component)) {
32             writer.begin("span");
33             writer.attribute("class", "label-error");
34         }
35     }
36
37     public void writeLabelSuffix(IFormComponent component,
38             IMarkupWriter writer, IRequestCycle cycle) {
39         if (isInError(component)) writer.end();
40         // <span>
41
}
42
43 }
Popular Tags