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 org.dbforms.taglib;
25
26 import org.dbforms.config.GrantedPrivileges;
27 import org.dbforms.config.ResultSetVector;
28
29 import org.dbforms.event.eventtype.EventType;
30
31 import org.dbforms.util.Util;
32
33 import javax.servlet.http.HttpServletRequest;
34 import javax.servlet.jsp.JspException;
35
36
37
38 /***
39 * this tag renders an "new"-button.
40 *
41 * @author Joachim Peer
42 */
43 public class DbNavNewButtonTag extends AbstractDbBaseButtonTag
44 implements javax.servlet.jsp.tagext.TryCatchFinally {
45 private String destTable;
46
47 /*** Holds value of property showAlwaysInFooter. */
48 private String showAlwaysInFooter = "true";
49
50 /***
51 * Sets the destTable
52 *
53 * @param destTable The destTable to set
54 */
55 public void setDestTable(String destTable) {
56 this.destTable = destTable;
57 }
58
59
60 /***
61 * Gets the destTable
62 *
63 * @return Returns a String
64 */
65 public String getDestTable() {
66 return destTable;
67 }
68
69
70 /***
71 * Setter for property showAlwaysInFooter.
72 *
73 * @param showAlwaysInFooter New value of property showAlwaysInFooter.
74 */
75 public void setShowAlwaysInFooter(String showAlwaysInFooter) {
76 this.showAlwaysInFooter = showAlwaysInFooter;
77 }
78
79
80 /***
81 * Getter for property showAlwaysInFooter.
82 *
83 * @return Value of property showAlwaysInFooter.
84 */
85 public String getShowAlwaysInFooter() {
86 return this.showAlwaysInFooter;
87 }
88
89
90 /***
91 * DOCUMENT ME!
92 */
93 public void doFinally() {
94 destTable = null;
95 showAlwaysInFooter = "true";
96 super.doFinally();
97 }
98
99
100 /***
101 * DOCUMENT ME!
102 *
103 * @return DOCUMENT ME!
104 *
105 * @throws javax.servlet.jsp.JspException DOCUMENT ME!
106 * @throws JspException DOCUMENT ME!
107 */
108 public int doStartTag() throws javax.servlet.jsp.JspException {
109 super.doStartTag();
110
111
112
113
114
115
116 if ((getTable() != null) && !getTable().hasUserPrivileg((HttpServletRequest)this.pageContext.getRequest(), GrantedPrivileges.PRIVILEG_INSERT)){
117 return SKIP_BODY;
118 }
119
120 if (getParentForm()
121 .isFooterReached()
122 && ResultSetVector.isNull(getParentForm().getResultSetVector())
123 && !Util.getTrue(showAlwaysInFooter)) {
124
125 return SKIP_BODY;
126 }
127
128 try {
129 StringBuffer tagBuf = new StringBuffer();
130
131
132
133 int tableId = ((destTable != null) && (destTable.length() != 0))
134 ? getConfig()
135 .getTableByName(destTable)
136 .getId()
137 : getTable()
138 .getId();
139
140 String tagName = EventType.EVENT_NAVIGATION_TRANSFER_NEW + tableId
141 + "_" + Integer.toString(getUniqueID());
142
143 if (getFollowUp() != null) {
144 tagBuf.append(getDataTag(tagName, "fu", getFollowUp()));
145 }
146
147 if (getFollowUpOnError() != null) {
148 tagBuf.append(getDataTag(tagName, "fue", getFollowUpOnError()));
149 }
150
151 tagBuf.append(getButtonBegin());
152 tagBuf.append(" name=\"");
153 tagBuf.append(tagName);
154 tagBuf.append(getButtonEnd());
155
156 pageContext.getOut()
157 .write(tagBuf.toString());
158 } catch (java.io.IOException ioe) {
159 throw new JspException("IO Error: " + ioe.getMessage());
160 }
161
162 if (getChoosenFlavor() == FLAVOR_MODERN) {
163 return EVAL_BODY_BUFFERED;
164 } else {
165 return SKIP_BODY;
166 }
167 }
168 }