1 /*
2 * Copyright 2001,2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.apache.commons.scaffold.util;
18
19
20 import java.io.Serializable;
21 import org.apache.commons.scaffold.lang.Tokens;
22
23
24 /**
25 * Concrete implementation of a business response
26 * [<code>org,apache.commons.util.BizResponse</code>]
27 * that can be used "as-is" to manage a response from the business tier.
28 *
29 * @author Ted Husted
30 * @author Synthis Corporation
31 * @version $Revision: 155464 $ $Date: 2005-02-26 13:26:54 +0000 (Sat, 26 Feb 2005) $
32 */
33 public class BizResponseImpl implements Serializable,BizResponse {
34
35
36 // ----------------------------------------------------------- Properties
37
38 /**
39 * The attribute name for the result [null].
40 */
41 private String name = null;
42
43
44 // See interface for JavaDoc
45 public String getName() {
46 return this.name;
47 }
48
49
50 // See interface for JavaDoc
51 public void setName(String name) {
52 this.name = name;
53 }
54
55
56 /**
57 * Field to store the scope property [request].
58 */
59 private String scope = Tokens.REQUEST;
60
61
62 // See interface for JavaDoc
63 public String getScope() {
64 return this.scope;
65 }
66
67
68 // See interface for JavaDoc
69 public void setScope(String scope) {
70 this.scope = scope;
71 }
72
73
74 /**
75 * Field to store single-form state [false].
76 */
77 private boolean singleForm = false;
78
79
80 // See interface for JavaDoc
81 public boolean isSingleForm() {
82 return this.singleForm;
83 }
84
85
86 // See interface for JavaDoc
87 public void setSingleForm(boolean singleForm) {
88 this.singleForm = singleForm;
89 }
90
91
92 /**
93 * Field to store exposed property [true].
94 */
95 private boolean exposed = true;
96
97
98 // See interface for JavaDoc
99 public boolean isExposed() {
100 return this.exposed;
101 }
102
103
104 // See interface for JavaDoc
105 public void setExposed(boolean exposed) {
106 this.exposed = exposed;
107 }
108
109
110 /**
111 * Field to store the data property [null].
112 */
113 private Object data = null;
114
115
116 // See interface for JavaDoc
117 public Object getData() {
118 return this.data;
119 }
120
121
122 // See interface for JavaDoc
123 public void setData(Object data) {
124 this.data = data;
125 }
126
127
128 // See interface for JavaDoc
129 public boolean isData() {
130 return (getData()!=null);
131 }
132
133
134 /**
135 * Field to store the aggregate state [false].
136 */
137 protected boolean aggregate = false;
138
139
140 // See interface for JavaDoc
141 public boolean isAggregate() {
142 return aggregate;
143 }
144
145
146 // See interface for JavaDoc
147 public void setAggregate(boolean aggregate) {
148 this.aggregate = aggregate;
149 }
150
151
152 /**
153 * Field to store the message property [ArrayList].
154 */
155 private Messages messages = new MessagesImpl();
156
157
158 // See interface for JavaDoc
159 public boolean isMessages() {
160
161 Messages messages = getMessages();
162
163 if (null==messages) return false;
164
165 return !(messages.isEmpty());
166
167 } // end isMessages()
168
169
170 // See interface for JavaDoc
171 public void addMessage(Message message, String property) {
172 Messages messages = getMessages();
173 messages.add(property,message);
174 }
175
176
177 // See interface for JavaDoc
178 public void addMessage(Message message) {
179 addMessage(message, Messages.GLOBAL_MESSAGE_KEY);
180 }
181
182
183 // See interface for JavaDoc
184 public Messages getMessages() {
185 return this.messages;
186 }
187
188
189 // See interface for JavaDoc
190 public void setMessages(Messages messages) {
191 this.messages = messages;
192 }
193
194
195 /**
196 * Field to store dispatch property [null].
197 */
198 private String dispatch = null;
199
200
201 // See interface for JavaDoc
202 public String getDispatch() {
203 return (this.dispatch);
204 }
205
206
207 // See interface for JavaDoc
208 public void setDispatch(String dispatch) {
209 this.dispatch = dispatch;
210 }
211
212
213 // See interface for JavaDoc
214 public boolean isDispatch() {
215 return (getDispatch()!=null);
216 }
217
218
219 /**
220 * Field to store dispatchPath property [false].
221 */
222 private boolean dispatchPath = false;
223
224
225 // See interface for JavaDoc
226 public boolean isDispatchPath() {
227 return this.dispatchPath;
228 }
229
230
231 // See interface for JavaDoc
232 public void setDispatchPath(boolean dispatchPath) {
233 this.dispatchPath = dispatchPath;
234 }
235
236
237 /**
238 * Our scroller object for paging through lists.
239 */
240 protected Scroller scroller = null;
241
242
243 // See interface for JavaDoc
244 public void setScroller(Scroller scroller){
245 this.scroller = scroller;
246 }
247
248
249 // See interface for JavaDoc
250 public Scroller getScroller() {
251 return this.scroller;
252 }
253
254
255 // ----------------------------------------------------------- Constructors
256
257
258 /**
259 * Default constructor.
260 */
261 public BizResponseImpl() {
262 super();
263 }
264
265
266 /**
267 * Convenience constructor to set result object.
268 *
269 * @param data The default data object
270 */
271 public BizResponseImpl(Object data) {
272
273 super();
274 setData(data);
275
276 } // end BizResponseImpl
277
278
279 /**
280 * Convenience constructor to set result object
281 * and singleForm status.
282 *
283 * @param data The default data object
284 */
285 public BizResponseImpl(Object data, boolean singleForm) {
286
287 super();
288 setData(data);
289 setSingleForm(singleForm);
290
291 } // end BizResponseImpl
292
293
294 /**
295 * Convenience constructor to set forwarding advice.
296 *
297 * @param dispatch The default dispatch advice
298 */
299 public BizResponseImpl(String dispatch) {
300
301 super();
302 setDispatch(dispatch);
303
304 } // end BizResponseImpl
305
306 } // end BizResponseImpl