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.io.Writer;
27
28 import javax.servlet.jsp.JspException;
29 import javax.servlet.jsp.JspTagException;
30
31 import net.smartlab.web.EmptyMarkerTag;
32
33 import org.apache.commons.beanutils.BeanUtils;
34 import org.apache.struts.taglib.TagUtils;
35 import org.apache.struts.taglib.html.Constants;
36
37
38
39
40
41
42
43 public class ReminderTag extends AbstractTag {
44
45
46
47
48 private String property;
49
50
51
52
53 private String value;
54
55
56
57
58
59 public void setValue(String value) {
60 this.value = value;
61 }
62
63
64
65
66
67 public void setProperty(String property) {
68 this.property = property;
69 }
70
71
72
73
74 public int doStartTag() throws JspException {
75 String[] items = null;
76 try {
77 String[] values = (String[])TagUtils.getInstance().lookup(super.context, Constants.BEAN_KEY, property, null);
78 items = new String[values.length];
79 System.arraycopy(values, 0, items, 0, items.length);
80 } catch (Exception e) {
81 items = context.getRequest().getParameterValues(property);
82 }
83 if (items != null) {
84 try {
85 Paginator paginator = super.getPaginator();
86 paginator.reset();
87 while (paginator.hasNext()) {
88 Object item = BeanUtils.getProperty(paginator.next(), value);
89 for (int i = 0; i < items.length; i++) {
90 if (item != null && items[i] != null && (items[i].equals(EmptyMarkerTag.EMPTY_MARKER) || items[i].equals(item.toString()))) {
91 items[i] = null;
92 break;
93 }
94 }
95 }
96 paginator.reset();
97 Writer out = context.getOut();
98 for (int i = 0; i < items.length; i++) {
99 if (items[i] != null) {
100 out.write("<input type=\"hidden\" name=\"" + property + "\" value=\"" + items[i] + "\"/>");
101 }
102 }
103 } catch (Exception e) {
104 throw new JspTagException(e);
105 }
106 }
107 return EVAL_PAGE;
108 }
109 }