Source Code Cross Referenced for SearchActionForm.java in  » J2EE » Mdarad » org » mdarad » framework » util » struts » action » 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 » Mdarad » org.mdarad.framework.util.struts.action 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:            Mdarad-Toolobox is a collection of tools for Architected RAD
003:            (Rapid Application Development) based on an MDA approach.
004:            The toolbox contains frameworks and generators for many environments
005:            (JAVA, J2EE, Hibernate, .NET, C++, etc.) which allow to generate
006:            applications from a design Model
007:            Copyright (C) 2004-2005  Elapse Technologies Inc.
008:
009:            This library is free software; you can redistribute it and/or
010:            modify it under the terms of the GNU General Public
011:            License as published by the Free Software Foundation; either
012:            version 2.1 of the License, or (at your option) any later version.
013:
014:            This library is distributed in the hope that it will be useful,
015:            but WITHOUT ANY WARRANTY; without even the implied warranty of
016:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:            General Public License for more details.
018:
019:            You should have received a copy of the GNU General Public
020:            License along with this library; if not, write to the Free Software
021:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
022:         */
023:        package org.mdarad.framework.util.struts.action;
024:
025:        import java.util.Collection;
026:        import java.util.List;
027:        import java.util.Vector;
028:
029:        import javax.servlet.http.HttpServletRequest;
030:        import javax.servlet.http.HttpServletResponse;
031:
032:        import org.mdarad.framework.util.ClassUtils;
033:        import org.mdarad.framework.util.ClassUtilsException;
034:        import org.mdarad.framework.util.struts.criteria.CriterionException;
035:        import org.mdarad.framework.util.struts.criteria.FormCriterion;
036:
037:        /**
038:         * This class to display a search form to specify criteria
039:         * that will probably be listed in a <code>ListForm</code>
040:         * 
041:         * @author Philippe Brouillette
042:         * @version 1.0
043:         */
044:        public abstract class SearchActionForm extends MdaradActionForm {
045:
046:            /**
047:             * Abstract method that must be implemented to returns 
048:             * the list of allowable criteria.  In other words, it 
049:             * returns the types of criteria that can be instanciated.
050:             * 
051:             * @return an array containing the allowable criteria
052:             */
053:            public abstract FormCriterion[] getAllowableCriteria();
054:
055:            /**
056:             * Property that keeps the concrete criteria instanciated
057:             * by an instance of this form.
058:             */
059:            private Collection concreteCriteria;
060:
061:            /**
062:             * Getter for the concrete criteria
063:             * @return the concrete criteria as a <code>List</code>
064:             *         object.
065:             */
066:            public List getConcreteCriteria() {
067:                if (concreteCriteria == null) {
068:                    concreteCriteria = new Vector();
069:                }
070:                return (List) concreteCriteria;
071:            }
072:
073:            /**
074:             * Set a list of criteria
075:             * @param collection the list of criteria
076:             */
077:            public void setConcreteCriteria(List collection) {
078:                concreteCriteria = collection;
079:            }
080:
081:            /**
082:             * Property that keeps the name of the selected criterion 
083:             * in the page
084:             */
085:            private String selectedCriterion;
086:
087:            /**
088:             * Getter for the selected criterion
089:             * @return a string with the name of the selected criterion
090:             */
091:            public String getSelectedCriterion() {
092:                return selectedCriterion;
093:            }
094:
095:            /**
096:             * Setter for the name of the selected criterion
097:             * @param criterion the name of the selected criterion
098:             */
099:            public void setSelectedCriterion(String criterion) {
100:                selectedCriterion = criterion;
101:            }
102:
103:            /**s
104:             * Methods that returns the <code>FormCriterion</code> associated
105:             * to the name passed as argument
106:             * @param name the name of the criterion to be retrieved
107:             * @return a <code>FormCriterion</code> object or <code>null</code>
108:             *         if the criterion doesn't exist.
109:             */
110:            public FormCriterion getAllowableCriterion(String name) {
111:                FormCriterion[] criteria = getAllowableCriteria();
112:                for (int i = 0; i < criteria.length; i++) {
113:                    if (criteria[i].getName().equals(name)) {
114:                        return criteria[i];
115:                    }
116:                }
117:                return null;
118:            }
119:
120:            /**
121:             * Method that adds a criterion from the the list of
122:             * allowable criteria to the list of concrete criteria.  It
123:             * dynamically instanciates a <code>FormCriterion</code> object
124:             * depending on the type of the allowable criterion.
125:             * @param mapName  the name that identifies the allowable criterion
126:             *                 in the map
127:             */
128:            public FormCriterion addCriterion(String key) {
129:                FormCriterion criterion = (FormCriterion) getAllowableCriterion(key);
130:                if (criterion == null) {
131:                    throw new CriterionException("The criterion doesn't exist");
132:                }
133:                Collection concreteCriteria = getConcreteCriteria();
134:                // Instancie un critère concret
135:
136:                Object object = null;
137:                try {
138:                    object = ClassUtils.getInstance(criterion.getClass(),
139:                            new Class[] { criterion.getClass() },
140:                            new Object[] { criterion });
141:                } catch (ClassUtilsException cue) {
142:                    throw new FormException(cue);
143:                }
144:                FormCriterion concCriterion = (FormCriterion) object;
145:                addCriterion(concCriterion);
146:                return concCriterion;
147:            }
148:
149:            /**
150:             * Method that adds a criterion from the the list of
151:             * allowable criteria to the list of concrete criteria.  It
152:             * dynamically instanciates a <code>FormCriterion</code> object
153:             * depending on the type of the allowable criterion.
154:             * @param mapName  the name that identifies the allowable criterion
155:             *                 in the map
156:             * @param criterion Instance de critere a ajouter
157:             */
158:            public FormCriterion addCriterion(FormCriterion criterion) {
159:                if (criterion == null) {
160:                    throw new CriterionException(
161:                            "The criterion to be added is null");
162:                }
163:                getConcreteCriteria().add(criterion);
164:                return (FormCriterion) criterion;
165:            }
166:
167:            /**
168:             * This method removes the concrete criterion identified by the
169:             * index passed as argument.
170:             * @param index the index of the criterion to be removed
171:             */
172:            public void removeCriterion(Integer index) {
173:                Collection concreteCriteria = getConcreteCriteria();
174:                ((List) concreteCriteria).remove(index.intValue());
175:            }
176:
177:            /**
178:             * Method that initialize the search list form.
179:             * @param request
180:             * @param response
181:             */
182:            public void initialize(HttpServletRequest request,
183:                    HttpServletResponse response) {
184:                setConcreteCriteria(new Vector());
185:            }
186:
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.