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    // ----------------------------------------------------------------------
021    
022    /**
023     * Convenient wrapper for the result of a business process.
024     * <p>
025     * The <b>result</b> property returns any object generated by the
026     * process that is to be returned to the presentation tier.
027     *
028     * The <b>messages</b> property is a list of any confirmation
029     * messages to be displayed by the presentation tier.
030     * These may be keys into a resource bundle, or literal text,
031     * depending on whether the application is localized.
032     *
033     * The <b>dispatchPath</b> property returns any special advice regarding
034     * the next step in the workflow. Null indicates the nominal "success"
035     * path should be followed.
036     *
037     * The <b>data</b> property is any actual data returned from storage.
038     * This may be a single record or a collection of records
039     * (see <code>isSingleForm()</code>).
040     *
041     * @author Ted Husted
042     * @author Synthis Corporation
043     * @author Nationwide Insurance Company
044     * @version $Revision: 155464 $ $Date: 2005-02-26 13:26:54 +0000 (Sat, 26 Feb 2005) $
045     */
046    public interface BizResponse {
047    
048        /**
049         * Return the attribute name for the result object.
050         * <p>
051         * Typically, this will be set by the caller but is provided
052         * in case a special name must be used or a way is needed to
053         * distingish between result objects.
054         *
055         * @return the name
056         */
057        public String getName();
058    
059    
060        /**
061         * Set the attribute name for this result object.
062         *
063         * @param name The new name
064         */
065        public void setName(String name);
066    
067    
068        /**
069         * Return the scope under which to store this result object.
070         *
071         * @return the scope
072         */
073        public String getScope();
074    
075    
076        /**
077         * Set the scope under which to store this result object.
078         *
079         * @param scope The new scope
080         */
081        public void setScope(String scope);
082    
083    
084    
085        /**
086         * Return the single-form state:
087         * list of 0 or more records=FALSE, exactly one record=TRUE.
088         *
089         * @returns True if this is a single record
090         */
091        public boolean isSingleForm();
092    
093    
094        /**
095         * Set the single-form state:
096         * list of 0 or more records=FALSE, exactly one record=TRUE.
097         *
098         * @param Set to true for single form.
099         */
100        public void setSingleForm(boolean singleForm);
101    
102    
103        /**
104         * Return the exposed state.
105         *
106         * @return True if the result should be exposed
107         */
108        public boolean isExposed();
109    
110    
111        /**
112         * Indicates whether the result should be exposed
113         * to the rest of the application through a context.
114         *
115         * @param multiple The new exposed
116         */
117        public void setExposed(boolean exposed);
118    
119    
120        /**
121         * Return the data object.
122         *
123         * @returns The data object
124         */
125        public Object getData();
126    
127    
128        /**
129         * Assign a new data object.
130         *
131         * @param data The new data object
132         */
133        public void setData(Object data);
134    
135    
136        /**
137         * Return whether data object has been set.
138         *
139         * @returns True if this result contains a data object
140         */
141        public boolean isData();
142    
143    
144        /**
145         * Return whether the result of this ProcessResult is a collection of
146         * contains other ProcessResult objects to be handled individually.
147         * This allows processes to be combined on the business tier and
148         * returned to controller as a single operation.
149         *
150         * @returns True if this ProcessResult contains other ProcessResults
151         * objects
152         */
153        public boolean isAggregate();
154    
155    
156        /**
157         * Assign a new container state.
158         *
159         * @param aggregate Set to true for aggregate result
160         */
161        public void setAggregate(boolean aggregate);
162    
163    
164        /**
165         * Return the messages list.
166         *
167         * @returns The message list
168         */
169        public Messages getMessages();
170    
171    
172        /**
173         * Return whether there are any messages queued.
174         *
175         * @returns True if there are messages queued.
176         */
177        public boolean isMessages();
178    
179    
180        /**
181         * Add a message to the list.
182         * Instantiate messages if it does not already exist.
183         */
184        public void addMessage(Message message, String property);
185    
186    
187        /**
188         * Add a message to the list.
189         * Instantiate messages if it does not already exist.
190         */
191        public void addMessage(Message message);
192    
193    
194        /**
195         * The dispatch property can be used to re-route control to an non-default location,
196         * either as a system path or via a logical name (e.g ActionForward).
197         *
198         * @see <code>setDispatchPath()</code>
199         *
200         * @returns The dispatch advice
201         */
202        public String getDispatch();
203    
204    
205        /**
206         * Field to store dispatch property.
207         */
208        public void setDispatch(String dispatch);
209    
210    
211        /**
212         * Return whether dispatch advice has been set.
213         *
214         * @returns True if dispatch advice has been set.
215         */
216        public boolean isDispatch();
217    
218    
219        /**
220         * Return whether dispatch advice is suppose to be a
221         * true path or a logical name (e.g. ActionForward)
222         *
223         * @returns True if dispatch advice is an actual path
224         */
225        public boolean isDispatchPath();
226    
227    
228        /**
229         * Indicates whether dispatch advice (if any) is suppose to be a
230         * path or a logical name (e.g. ActionForward).
231         *
232         * @param dispatchPath The new dispatch advice
233         */
234        public void setDispatchPath(boolean dispatchPath);
235    
236    } // end BizResponse