1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package net.smartlab.web.page;
25
26 import java.util.Enumeration;
27
28 import javax.servlet.jsp.tagext.TagData;
29 import javax.servlet.jsp.tagext.TagExtraInfo;
30 import javax.servlet.jsp.tagext.ValidationMessage;
31 import javax.servlet.jsp.tagext.VariableInfo;
32
33
34
35
36
37
38 public class PaginateTei extends TagExtraInfo {
39
40
41
42
43 public final VariableInfo[] getVariableInfo(TagData data) {
44 return new VariableInfo[] {new VariableInfo("paginator", "net.smartlab.web.page.Paginator", true, VariableInfo.NESTED)};
45 }
46
47
48
49
50 public boolean isValid(TagData tagData) {
51 boolean hasHref = false;
52 boolean hasForm = false;
53
54 Enumeration attributes = tagData.getAttributes();
55 while (attributes.hasMoreElements()) {
56 String attribute = (String)attributes.nextElement();
57 if (attribute.equals("href")) {
58 hasHref = true;
59 } else if (attribute.equals("form")) {
60 hasForm = true;
61 }
62 }
63 if (hasHref && hasForm) {
64
65 return false;
66 }
67 return true;
68 }
69
70
71
72
73 public ValidationMessage[] validate(TagData tagData) {
74 boolean hasHref = false;
75 boolean hasForm = false;
76
77 Enumeration attributes = tagData.getAttributes();
78 while (attributes.hasMoreElements()) {
79 String attribute = (String)attributes.nextElement();
80 if (attribute.equals("href")) {
81 hasHref = true;
82 } else if (attribute.equals("form")) {
83 hasForm = true;
84 }
85 }
86 if (hasHref && hasForm) {
87 return new ValidationMessage[] {new ValidationMessage(tagData.getId(), "Page tag has both href and form attributes")};
88 }
89 return null;
90 }
91
92 }