Source Code Cross Referenced for FinderComponent.java in  » J2EE » Jaffa » org » jaffa » components » finder » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » Jaffa » org.jaffa.components.finder 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ====================================================================
003:         * JAFFA - Java Application Framework For All
004:         *
005:         * Copyright (C) 2002 JAFFA Development Group
006:         *
007:         *     This library is free software; you can redistribute it and/or
008:         *     modify it under the terms of the GNU Lesser General Public
009:         *     License as published by the Free Software Foundation; either
010:         *     version 2.1 of the License, or (at your option) any later version.
011:         *
012:         *     This library is distributed in the hope that it will be useful,
013:         *     but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         *     Lesser General Public License for more details.
016:         *
017:         *     You should have received a copy of the GNU Lesser General Public
018:         *     License along with this library; if not, write to the Free Software
019:         *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
020:         *
021:         * Redistribution and use of this software and associated documentation ("Software"),
022:         * with or without modification, are permitted provided that the following conditions are met:
023:         * 1.	Redistributions of source code must retain copyright statements and notices.
024:         *         Redistributions must also contain a copy of this document.
025:         * 2.	Redistributions in binary form must reproduce the above copyright notice,
026:         * 	this list of conditions and the following disclaimer in the documentation
027:         * 	and/or other materials provided with the distribution.
028:         * 3.	The name "JAFFA" must not be used to endorse or promote products derived from
029:         * 	this Software without prior written permission. For written permission,
030:         * 	please contact mail to: jaffagroup@yahoo.com.
031:         * 4.	Products derived from this Software may not be called "JAFFA" nor may "JAFFA"
032:         * 	appear in their names without prior written permission.
033:         * 5.	Due credit should be given to the JAFFA Project (http://jaffa.sourceforge.net).
034:         *
035:         * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
036:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
037:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
038:         * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
039:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
040:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
041:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
042:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
043:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
044:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
045:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
046:         * SUCH DAMAGE.
047:         * ====================================================================
048:         */
049:
050:        package org.jaffa.components.finder;
051:
052:        import org.apache.log4j.Logger;
053:        import java.util.*;
054:        import org.jaffa.presentation.portlet.component.Component;
055:        import org.jaffa.components.dto.HeaderDto;
056:        import org.jaffa.presentation.portlet.widgets.controller.DropDownController;
057:        import org.jaffa.presentation.portlet.widgets.model.DropDownModel;
058:
059:        /** This is the base class for all Finder components.
060:         * It has the following properties -
061:         *    1- displayResultsScreen : If set to true, then the Results screen will directly brought up, bypassing the Criteria screen.
062:         *    2- sortDropDown : The sort criteria to use for the inquiry
063:         *    3- exportType : The export option to use for the inquiry (initialized to regular Web Pages)
064:         *    4- maxRecords: The maximum number of records to retrieve. All records will be retrieved, if no value is specified.
065:         *    5- finderListener : The Listener object, which will refresh the Results screen, on a new inquiry
066:         *    6- headerDto : This is a convenience property to pass to Tx, where required
067:         * @author  GautamJ
068:         * @deprecated This class is required by the object_finder_1_0 pattern. The object_finder_2_0 pattern has made this class redundant.
069:         */
070:        public abstract class FinderComponent extends Component {
071:
072:            private static final Logger log = Logger
073:                    .getLogger(FinderComponent.class);
074:
075:            /** A global constant for the Web Page export option.*/
076:            public final static String EXPORT_TYPE_WEB_PAGE = "W";
077:            /** A global constant for the Excel export option.*/
078:            public final static String EXPORT_TYPE_EXCEL = "E";
079:            /** A global constant for the XML export option.*/
080:            public final static String EXPORT_TYPE_XML = "X";
081:            /** This request stream attribute is set by a FinderCriteriaForm, after a query, and if the exportType is XML.
082:             * The ResultsJsp will use display the XML stored by this attribute. */
083:            public static final String ATTRIBUTE_EXPORT_TYPE_XML = "org.jaffa.components.finder.FinderComponent.attributeExportTypeXml";
084:
085:            private static final String SPACE = " ";
086:            private static final String COMMA = ",";
087:            private static final String DESC = "DESC";
088:
089:            private Boolean m_displayResultsScreen = null;
090:            private String m_sortDropDown = null;
091:            private String m_exportType = EXPORT_TYPE_WEB_PAGE;
092:            private Integer m_maxRecords = new Integer(
093:                    ((Number) CriteriaDropDownOptions
094:                            .getDefaultMaxRecordsDropDownOption()).intValue());
095:            private IFinderListener m_finderListener = null;
096:            private HeaderDto m_headerDto = null;
097:
098:            /** This clears the listener and then invokes the quit() method of the base class.
099:             */
100:            public void quit() {
101:                m_finderListener = null;
102:                super .quit();
103:            }
104:
105:            /** Getter for property displayResultsScreen.
106:             * @return Value of property displayResultsScreen.
107:             */
108:            public Boolean getDisplayResultsScreen() {
109:                return m_displayResultsScreen;
110:            }
111:
112:            /** Setter for property displayResultsScreen.
113:             * @param displayResultsScreen New value of property displayResultsScreen.
114:             */
115:            public void setDisplayResultsScreen(Boolean displayResultsScreen) {
116:                m_displayResultsScreen = displayResultsScreen;
117:            }
118:
119:            /** Getter for property sortDropDown.
120:             * @return Value of property sortDropDown.
121:             */
122:            public String getSortDropDown() {
123:                return m_sortDropDown;
124:            }
125:
126:            /** Setter for property sortDropDown.
127:             * @param sortDropDown New value of property sortDropDown.
128:             */
129:            public void setSortDropDown(String sortDropDown) {
130:                m_sortDropDown = sortDropDown;
131:            }
132:
133:            /** Getter for property exportType.
134:             * @return Value of property exportType.
135:             */
136:            public String getExportType() {
137:                return m_exportType;
138:            }
139:
140:            /** Setter for property exportType.
141:             * @param exportType New value of property exportType.
142:             */
143:            public void setExportType(String exportType) {
144:                m_exportType = exportType;
145:            }
146:
147:            /** Getter for property maxRecords.
148:             * @return Value of property maxRecords.
149:             */
150:            public Integer getMaxRecords() {
151:                return m_maxRecords;
152:            }
153:
154:            /** Setter for property maxRecords.
155:             * @param maxRecords New value of property maxRecords.
156:             */
157:            public void setMaxRecords(Integer maxRecords) {
158:                m_maxRecords = maxRecords;
159:            }
160:
161:            /** This will set the property 'maxRecords' to the value following the current one, in the list of values returned by CriteriaDropDownOptions.getMaxRecordsDropDownOptions().
162:             */
163:            public void incrementMaxRecords() {
164:                int currentValue = m_maxRecords != null ? m_maxRecords
165:                        .intValue() : 0;
166:                for (Iterator i = CriteriaDropDownOptions
167:                        .getMaxRecordsDropDownOptions().keySet().iterator(); i
168:                        .hasNext();) {
169:                    int dropDownValue = ((Number) i.next()).intValue();
170:                    if (m_maxRecords == null) {
171:                        m_maxRecords = new Integer(dropDownValue);
172:                        updateMaxRecordsModel();
173:                        break;
174:                    } else if (currentValue == dropDownValue) {
175:                        if (i.hasNext()) {
176:                            m_maxRecords = new Integer(((Number) i.next())
177:                                    .intValue());
178:                            updateMaxRecordsModel();
179:                        }
180:                        break;
181:                    }
182:                }
183:            }
184:
185:            /** Getter for property finderListener.
186:             * @return Value of property finderListener.
187:             */
188:            public IFinderListener getFinderListener() {
189:                return m_finderListener;
190:            }
191:
192:            /** Setter for property finderListener.
193:             * @param finderListener New value of property finderListener.
194:             */
195:            public void setFinderListener(IFinderListener finderListener) {
196:                m_finderListener = finderListener;
197:            }
198:
199:            /** Invokes the inquiryDone() method of the registered IFinderListener object in the same thread.
200:             */
201:            protected void invokeFinderListener() {
202:                invokeFinderListener(null);
203:            }
204:
205:            /** Invokes the inquiryDone() method of the registered IFinderListener object in the same thread.
206:             * @param eventObject The EventObject which will probably contain the component itself.
207:             */
208:            protected void invokeFinderListener(EventObject eventObject) {
209:                if (m_finderListener != null) {
210:                    if (eventObject == null)
211:                        eventObject = new EventObject(this );
212:
213:                    m_finderListener.inquiryDone(eventObject);
214:                }
215:            }
216:
217:            /** Returns the HeaderDto. This can be used for passing the header info to the Tx, where required.
218:             * @return the HeaderDto.
219:             */
220:            protected HeaderDto getHeaderDto() {
221:                if (m_headerDto == null) {
222:                    m_headerDto = new HeaderDto();
223:                    m_headerDto.setUserId(getUserSession().getUserId());
224:                }
225:                return m_headerDto;
226:            }
227:
228:            /** Interprets the value of the 'sortDropDown' property adding suitable values to the input Dto.
229:             * @param inputDto The Dto to which the orderby fields will be added.
230:             */
231:            protected void addSortCriteria(FinderInDto inputDto) {
232:                if (getSortDropDown() != null) {
233:                    // these variables will be used while interpreting the sort field
234:                    String token = null;
235:                    boolean startOfField = true;
236:                    String field = null;
237:                    Boolean isAscending = null;
238:
239:                    StringTokenizer str = new StringTokenizer(
240:                            getSortDropDown(), " ,", true);
241:                    while (str.hasMoreTokens()) {
242:                        token = str.nextToken();
243:                        if (token.equals(COMMA)) {
244:                            // check for an existing field
245:                            if (field != null) {
246:                                if (isAscending != null)
247:                                    inputDto.addOrderByFields(new OrderByField(
248:                                            field, isAscending));
249:                                else
250:                                    inputDto.addOrderByFields(new OrderByField(
251:                                            field));
252:                                // reset the fields
253:                                field = null;
254:                                isAscending = null;
255:                            }
256:                            startOfField = true;
257:                        } else if (token.equals(SPACE)) {
258:                            // do nothing
259:                        } else if (startOfField) {
260:                            field = token;
261:                            startOfField = false;
262:                        } else {
263:                            if (token.toUpperCase().equals(DESC))
264:                                isAscending = Boolean.FALSE;
265:                            else
266:                                isAscending = Boolean.TRUE;
267:                            if (field != null) {
268:                                if (isAscending != null)
269:                                    inputDto.addOrderByFields(new OrderByField(
270:                                            field, isAscending));
271:                                else
272:                                    inputDto.addOrderByFields(new OrderByField(
273:                                            field));
274:                                // reset the fields
275:                                field = null;
276:                                isAscending = null;
277:                            }
278:                        }
279:                    }
280:                    // one final check
281:                    if (field != null) {
282:                        if (isAscending != null)
283:                            inputDto.addOrderByFields(new OrderByField(field,
284:                                    isAscending));
285:                        else
286:                            inputDto.addOrderByFields(new OrderByField(field));
287:                    }
288:                }
289:            }
290:
291:            /** Update the DropDownModel for the MaxRecords field, if one already exists. */
292:            private void updateMaxRecordsModel() {
293:                DropDownModel wm = (DropDownModel) getUserSession()
294:                        .getWidgetCache(getComponentId())
295:                        .getModel("maxRecords");
296:                if (wm != null)
297:                    DropDownController.updateModel(m_maxRecords.toString(), wm);
298:            }
299:
300:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.