Source Code Cross Referenced for BaseListController.java in  » J2EE » Sofia » com » salmonllc » jsp » controller » 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 » Sofia » com.salmonllc.jsp.controller 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.salmonllc.jsp.controller;
002:
003:        /////////////////////////
004:        //$Archive: /sofia/sourcecode/com/salmonllc/jsp/controller/BaseListController.java $
005:        //$Author: Deepak $
006:        //$Revision: 25 $
007:        //$Modtime: 9/29/03 12:14p $
008:        /////////////////////////
009:        import java.text.SimpleDateFormat;
010:        import java.util.Vector;
011:
012:        import com.salmonllc.forms.ListFormListener;
013:        import com.salmonllc.html.HtmlComponent;
014:        import com.salmonllc.html.HtmlLink;
015:        import com.salmonllc.html.events.PageEvent;
016:        import com.salmonllc.html.events.PageListener;
017:        import com.salmonllc.jsp.JspController;
018:        import com.salmonllc.properties.Props;
019:        import com.salmonllc.sql.DataStore;
020:        import com.salmonllc.util.MessageLog;
021:
022:        /**
023:         * Base class for all the standard List Controllers.
024:         */
025:        public class BaseListController extends JspController implements 
026:                ListFormListener, PageListener {
027:
028:            public com.salmonllc.forms.ListForm _listForm;
029:
030:            protected DataStore _ds;
031:
032:            protected SimpleDateFormat _dateFormat[];
033:
034:            public com.salmonllc.jsp.JspListForm _mainCont;
035:            protected Vector _linkComponents;
036:
037:            private java.util.Hashtable _hashUserComponents = new java.util.Hashtable();
038:
039:            public String querystring = "";
040:
041:            /**
042:             * This method is used if component in List form is needed to be mapped to any other component
043:             * Creation date: (8/16/01 5:02:34 PM)
044:             * @return com.salmonllc.html.HtmlComponent
045:             * @param compName java.lang.String
046:             */
047:            public HtmlComponent assignComponentToUserComp(String compName) {
048:                if (getUserComponents() == null)
049:                    return null;
050:                else
051:                    return (HtmlComponent) getUserComponents().get(compName);
052:            }
053:
054:            /**
055:             * Insert the method's description here.
056:             * Creation date: (8/2/01 10:16:09 AM)
057:             * @return java.lang.String
058:             * @param ds com.salmonllc.sql.DataStore
059:             */
060:            protected Vector getPrimaryKey(DataStore _ds)
061:                    throws com.salmonllc.sql.DataStoreException {
062:                int colCount = _ds.getColumnCount();
063:                Vector s = new Vector();
064:                for (int i = 0; i < colCount; i++) {
065:                    if (!_ds.isPrimaryKey(i))
066:                        continue;
067:                    s.add(_ds.getColumnName(i));
068:                }
069:
070:                return s;
071:            }
072:
073:            /**
074:             * Insert the method's description here.
075:             * Creation date: (8/2/01 10:16:09 AM)
076:             * @return java.lang.String
077:             * @param ds com.salmonllc.sql.DataStore
078:             */
079:            protected String getPrimaryKeyName(DataStore _ds)
080:                    throws com.salmonllc.sql.DataStoreException {
081:                int colCount = _ds.getColumnCount();
082:                String s = null;
083:                for (int i = 0; i < colCount; i++) {
084:                    if (!_ds.isPrimaryKey(i))
085:                        continue;
086:                    s = _ds.getColumnName(i);
087:                }
088:
089:                if (s != null && s.indexOf(".") != -1)
090:                    s = s.substring(s.indexOf(".") + 1);
091:
092:                return s;
093:            }
094:
095:            /**
096:             * Gets all the User Components specified in List Form as a hastable
097:             * Creation date: (8/17/01 10:55:39 AM)
098:             * @return java.util.Hashtable
099:             */
100:            public java.util.Hashtable getUserComponents() {
101:                return _hashUserComponents;
102:            }
103:
104:            //
105:
106:            public void initialize() throws Exception {
107:                super .initialize();
108:                try {
109:
110:                    addPageListener(this );
111:
112:                    // Stupid date format parsing
113:                    Props p = getPageProperties();
114:                    String s;
115:                    Vector v = new Vector();
116:                    if ((s = p.getProperty(Props.DATE_FORMAT)) != null)
117:                        v.addElement(new SimpleDateFormat(s));
118:                    if ((s = p.getProperty(Props.DATETIME_FORMAT)) != null)
119:                        v.addElement(new SimpleDateFormat(s));
120:                    v.addElement(new SimpleDateFormat());
121:                    v.addElement(new SimpleDateFormat("MMM dd, yyyy"));
122:                    v.addElement(new SimpleDateFormat("MMM dd yyyy"));
123:                    v
124:                            .addElement(new SimpleDateFormat(
125:                                    "MMM dd, yyyy hh:mm aaa"));
126:                    _dateFormat = new SimpleDateFormat[v.size()];
127:                    for (int i = 0; i < v.size(); i++)
128:
129:                        _dateFormat[i] = (SimpleDateFormat) v.elementAt(i);
130:
131:                } catch (Exception e) {
132:                    MessageLog.writeErrorMessage("initialize", e, this );
133:                }
134:            }
135:
136:            /**
137:             * Called before datastore retrieval.
138:             * @return boolean	If true, continue with retrieval.
139:             */
140:            public void pageRequested(PageEvent p) throws Exception {
141:                request(p);
142:            }
143:
144:            /**
145:             * 	This method/event will get fired each time a page is requested by the browser.
146:             *	@param p PageEvent
147:             *	@throws Exception
148:             */
149:            public void pageRequestEnd(PageEvent p) throws Exception {
150:                //writeMessage(getClassName() + ".pageRequestEnd()");
151:                //displayMessage(null);
152:            }
153:
154:            /**
155:             * 	This method occurs each time a page is sumbitted.
156:             *	@param p PageEvent
157:             */
158:            public void pageSubmitEnd(PageEvent p) {
159:                //writeMessage(getClassName() + ".pageSubmitEnd()");
160:            }
161:
162:            /**
163:             *	This method is called after a page has been submitted.  It sets a URL for the user to be re-directed to after the page has been submitted.
164:             *	@param p PageEvent
165:             */
166:
167:            public void pageSubmitted(PageEvent p) {
168:
169:            }
170:
171:            /**
172:             * Called after the Add button in the List display box has been processed.
173:             * @return boolean	Undefined at this time.
174:             */
175:            public boolean postListAdd() {
176:                return false;
177:            }
178:
179:            /**
180:             * Called after datastore retrieval.
181:             *
182:             * @return boolean	If false, stop further processing of listeners.
183:             */
184:            public boolean postListRetrieve() throws java.lang.Exception {
185:                return true;
186:            }
187:
188:            /**
189:             * Called before processing the Add submit button on the List display box.
190:             * @return boolean	If true, continue processing.
191:             */
192:            public boolean preListAdd() {
193:                return true;
194:            }
195:
196:            /**
197:             * Called before datastore retrieval.
198:             * @return boolean	If true, continue with retrieval.
199:             */
200:            public boolean preListRetrieve() throws Exception {
201:                return true;
202:            }
203:
204:            /**
205:             * Called before datastore retrieval.
206:             * @return boolean	If true, continue with retrieval.
207:             */
208:            public void request(PageEvent p) throws Exception {
209:                if (_linkComponents != null) {
210:                    for (int i = 0; i < _linkComponents.size(); i++) {
211:                        if (_linkComponents.elementAt(i) != null) {
212:                            // get link params
213:                            String mode = getParameter("mode");
214:                            String returnVal = getParameter("returnTo");
215:
216:                            Vector vctPrimaryKeys = getPrimaryKey(_ds);
217:                            String URL;
218:
219:                            if (mode != null && mode.equals("view")) {
220:                                URL = "'" + returnVal + "?'";
221:                            } else {
222:                                URL = "'" + _mainCont.getDetailPageName()
223:                                        + "?mode=update'";
224:                            }
225:
226:                            String connector = "+'";
227:                            for (int j = 0; j < vctPrimaryKeys.size(); j++) {
228:                                String keyValue = (String) vctPrimaryKeys
229:                                        .elementAt(j);
230:                                String keyValueName = "";
231:                                { // Get the Key Valye
232:                                    int dot = keyValue.indexOf(".");
233:                                    if (dot != -1)
234:                                        keyValueName = keyValue
235:                                                .substring(dot + 1);
236:                                }
237:
238:                                if (mode != null && mode.equals("view")) {
239:                                    // return value to lookup comp
240:                                    URL += connector + getParameter("comp")
241:                                            + "='+" + keyValue;
242:                                    connector = "+'&";
243:                                } else {
244:                                    // maintain values
245:                                    URL += "+'&" + keyValueName + "='+";
246:                                    URL += keyValue;
247:                                    if (querystring != null
248:                                            && !querystring.equals("")) {
249:                                        URL += "+'&" + querystring + "'";
250:                                    }
251:                                }
252:
253:                                // get row no if any from parametr list
254:                                String rowNo = getParameter("rowNo");
255:                                if (rowNo != null)
256:                                    URL += "+'&rowNo=" + rowNo + "'";
257:
258:                            } // For loop for primary Keys
259:                            ((HtmlLink) _linkComponents.get(i))
260:                                    .setHrefExpression(_ds, URL);
261:                        }
262:                    }
263:                }
264:            }
265:
266:            /**
267:             * Creation date: (8/17/01 10:55:39 AM)
268:             * @param newUserComponents java.util.Hashtable
269:             */
270:            public void setUserComponents(java.util.Hashtable newUserComponents) {
271:                _hashUserComponents = newUserComponents;
272:            }
273:
274:            /**
275:             *	This method is used to write a debug message to the Message Log in the descendant class/page.
276:             *	The message written to the log is the String value passed into this method.
277:             *	@param message java.lang.String
278:             */
279:
280:            public void writeMessage(String message) {
281:                MessageLog.writeDebugMessage("" + message, this );
282:            }
283:
284:            /**
285:             * Gets all the User Components specified in Detail Form as a hastable
286:             * Creation date: (8/16/01 4:24:49 PM)
287:             * @return java.util.Hashtable
288:             */
289:            public HtmlComponent getHtmlComponent(String name) {
290:                if (name != null)
291:                    return (HtmlComponent) getUserComponents().get(name);
292:                return null;
293:            }
294:
295:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.