001 /* 002 * Copyright 2001,2004 The Apache Software Foundation. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017 package org.apache.commons.scaffold.util; 018 019 020 import java.io.Serializable; 021 import org.apache.commons.scaffold.lang.Tokens; 022 023 024 /** 025 * Concrete implementation of a business response 026 * [<code>org,apache.commons.util.BizResponse</code>] 027 * that can be used "as-is" to manage a response from the business tier. 028 * 029 * @author Ted Husted 030 * @author Synthis Corporation 031 * @version $Revision: 155464 $ $Date: 2005-02-26 13:26:54 +0000 (Sat, 26 Feb 2005) $ 032 */ 033 public class BizResponseImpl implements Serializable,BizResponse { 034 035 036 // ----------------------------------------------------------- Properties 037 038 /** 039 * The attribute name for the result [null]. 040 */ 041 private String name = null; 042 043 044 // See interface for JavaDoc 045 public String getName() { 046 return this.name; 047 } 048 049 050 // See interface for JavaDoc 051 public void setName(String name) { 052 this.name = name; 053 } 054 055 056 /** 057 * Field to store the scope property [request]. 058 */ 059 private String scope = Tokens.REQUEST; 060 061 062 // See interface for JavaDoc 063 public String getScope() { 064 return this.scope; 065 } 066 067 068 // See interface for JavaDoc 069 public void setScope(String scope) { 070 this.scope = scope; 071 } 072 073 074 /** 075 * Field to store single-form state [false]. 076 */ 077 private boolean singleForm = false; 078 079 080 // See interface for JavaDoc 081 public boolean isSingleForm() { 082 return this.singleForm; 083 } 084 085 086 // See interface for JavaDoc 087 public void setSingleForm(boolean singleForm) { 088 this.singleForm = singleForm; 089 } 090 091 092 /** 093 * Field to store exposed property [true]. 094 */ 095 private boolean exposed = true; 096 097 098 // See interface for JavaDoc 099 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