1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.extremecomponents.table.tag;
17
18 import javax.servlet.jsp.JspException;
19 import javax.servlet.jsp.tagext.TagSupport;
20
21 import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
22 import org.extremecomponents.table.FormAttributes;
23 import org.extremecomponents.table.bean.Form;
24
25
26
27 /***
28 * @author jeff johnston
29 */
30 public class FormTag extends TagSupport implements FormAttributes
31 {
32 private String name;
33 private String action;
34 private String method;
35 private String onsubmit;
36
37 public String getName()
38 {
39 return name;
40 }
41
42 public void setName(String name)
43 {
44 this.name = name;
45 }
46
47 public String getAction()
48 {
49 return action;
50 }
51
52 public void setAction(String action)
53 {
54 this.action = action;
55 }
56
57 public String getMethod()
58 {
59 return method;
60 }
61
62 public void setMethod(String method)
63 {
64 this.method = method;
65 }
66
67 public String getOnsubmit()
68 {
69 return onsubmit;
70 }
71
72 public void setOnsubmit(String onsubmit)
73 {
74 this.onsubmit = onsubmit;
75 }
76
77 public int doStartTag()
78 throws JspException
79 {
80 TableTag tableTag = (TableTag) findAncestorWithClass(this, TableTag.class);
81
82 if (tableTag.getModelRowsSize() > 0)
83 {
84 return SKIP_BODY;
85 }
86
87 if (action != null)
88 {
89 action = (String) ExpressionEvaluatorManager.evaluate("action", action, String.class, this, pageContext);
90 }
91
92 Form form = new Form(tableTag.getModel());
93 form.setName(name);
94 form.setAction(action);
95 form.setMethod(method);
96 form.setOnsubmit(onsubmit);
97 tableTag.addForm(form);
98
99 cleanup();
100
101 return EVAL_BODY_INCLUDE;
102 }
103
104 public void cleanup()
105 {
106 name = null;
107 action = null;
108 method = null;
109 onsubmit = null;
110 }
111 }