Source Code Cross Referenced for BaseDetailController.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:        //** Copyright Statement ***************************************************
002:        //The Salmon Open Framework for Internet Applications (SOFIA)
003:        // Copyright (C) 1999 - 2002, Salmon LLC
004:        //
005:        // This program is free software; you can redistribute it and/or
006:        // modify it under the terms of the GNU General Public License version 2
007:        // as published by the Free Software Foundation;
008:        //
009:        // This program is distributed in the hope that it will be useful,
010:        // but WITHOUT ANY WARRANTY; without even the implied warranty of
011:        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:        // GNU General Public License for more details.
013:        //
014:        // You should have received a copy of the GNU General Public License
015:        // along with this program; if not, write to the Free Software
016:        // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:        //
018:        // For more information please visit http://www.salmonllc.com
019:        //** End Copyright Statement ***************************************************
020:        package com.salmonllc.jsp.controller;
021:
022:        /////////////////////////
023:        //$Archive: /sofia/sourcecode/com/salmonllc/jsp/controller/BaseDetailController.java $
024:        //$Author: Deepak $
025:        //$Revision: 24 $
026:        //$Modtime: 6/16/03 10:37a $
027:        /////////////////////////
028:
029:        import com.salmonllc.forms.DetailForm;
030:        import com.salmonllc.forms.DetailFormListener;
031:        import com.salmonllc.html.HtmlComponent;
032:        import com.salmonllc.html.HtmlFormComponent;
033:        import com.salmonllc.html.HtmlText;
034:        import com.salmonllc.html.events.PageEvent;
035:        import com.salmonllc.html.events.PageListener;
036:        import com.salmonllc.html.events.SubmitListener;
037:        import com.salmonllc.html.events.SubmitEvent;
038:        import com.salmonllc.jsp.JspController;
039:        import com.salmonllc.sql.DataStore;
040:        import com.salmonllc.util.MessageLog;
041:        import com.salmonllc.util.Util;
042:
043:        /**
044:         * Licensed Material - Property of Salmon LLC
045:         * (C) Copyright Salmon LLC. 1999 - All Rights Reserved
046:         * For more information go to www.salmonllc.com
047:         *
048:         * *************************************************************************
049:         * DISCLAIMER:
050:         * The following code has been created by Salmon LLC. The code is provided
051:         * 'AS IS' , without warranty of any kind unless covered in another agreement
052:         * between your corporation and Salmon LLC.  Salmon LLC shall not be liable
053:         * for any damages arising out of your use of this, even if they have been
054:         * advised of the possibility of such damages.
055:         * *************************************************************************
056:         *
057:         *
058:         */
059:
060:        /**
061:         * Base class for all the standard Detail Controllers.
062:         */
063:        public class BaseDetailController extends JspController implements 
064:                DetailFormListener, PageListener, SubmitListener {
065:            public com.salmonllc.jsp.JspContainer _mainCont;
066:
067:            // heading
068:            public HtmlText _messageText;
069:
070:            protected DetailForm _detailForm;
071:            protected DataStore _ds;
072:
073:            private java.util.Hashtable _hashUserComponents = new java.util.Hashtable();
074:            public com.salmonllc.html.HtmlComponent fieldMessageComponent;
075:
076:            /**
077:             * This method is used if component in detail form is needed to be mapped to any other component
078:             * Creation date: (8/16/01 5:02:34 PM)
079:             * @return com.salmonllc.html.HtmlComponent
080:             * @param compName java.lang.String
081:             */
082:            public HtmlComponent assignComponentToUserComp(String compName) {
083:                if (getUserComponents() == null)
084:                    return null;
085:                else
086:                    return (HtmlComponent) getUserComponents().get(compName);
087:            }
088:
089:            /**
090:             *	This method checks the HTML form component passed into it to see the form field has been filled out and is valid.
091:             *	@param comp HtmlFormComponent
092:             *	@param itemName java.lang.String
093:             * @return boolean true
094:             */
095:
096:            public boolean checkComponent(HtmlFormComponent comp,
097:                    String itemName) {
098:                // call isValid for all components
099:                String preMess = "Please enter a valid value for ";
100:                if (Util.isFilled(comp.getValue())) {
101:                    if (!comp.isValid()) {
102:                        displayError(preMess + itemName, getMessageComponent());
103:                        return false;
104:                    }
105:                }
106:
107:                return true;
108:            }
109:
110:            /**
111:             *	This method calls the displayMessage method and passes the error message to it.
112:             *	@param message java.lang.String
113:             */
114:            public void displayError(String message) {
115:                displayMessage(message, true, null, -1);
116:            }
117:
118:            /**
119:             *	This method calls the displayMessage method and passes the error message to it.
120:             * 	@param message java.lang.String
121:             * 	@param focus com.salmonllc.html.HtmlComponent
122:             */
123:            public void displayError(String message, HtmlComponent focus) {
124:                displayMessage(message, true, focus, -1);
125:            }
126:
127:            /**
128:             *	This method calls the displayMessage method and passes the error message to it.
129:             * 	@param message java.lang.String
130:             * 	@param focus com.salmonllc.html.HtmlComponent
131:             *	@param row int
132:             */
133:            public void displayError(String message, HtmlComponent focus,
134:                    int row) {
135:                displayMessage(message, true, focus, row);
136:            }
137:
138:            /**
139:             *	This method calls an overloaded version of the displayMessage method and passes the message to it.
140:             *	@param message java.lang.String
141:             */
142:            public void displayMessage(String message) {
143:                displayMessage(message, false, null, -1);
144:            }
145:
146:            /**
147:             *	This method calls an overloaded version of the displayMessage method and passes the message to it.
148:             * 	@param focus com.salmonllc.html.HtmlComponent
149:             */
150:            public void displayMessage(String message, HtmlComponent focus) {
151:                displayMessage(message, false, focus, -1);
152:            }
153:
154:            /**
155:             *	This method is used to display a message in the descendant class/page.
156:             * 	@param message java.lang.String
157:             * 	@param focus com.salmonllc.html.HtmlComponent
158:             * 	@param row int
159:             */
160:            public void displayMessage(String message, boolean isError,
161:                    HtmlComponent focus, int row) {
162:
163:                HtmlComponent messageComp = getMessageComponent();
164:
165:                if (_detailForm.getErrorMessageComp() == null) {
166:                    _detailForm.setErrorMessageComp((HtmlText) messageComp);
167:                }
168:
169:                _detailForm.getErrorMessageComp().setVisible(true);
170:
171:                if (message == null) {
172:                    _detailForm.getErrorMessageComp().setText(" ");
173:                } else {
174:                    _detailForm.getErrorMessageComp().setText(message);
175:                    _detailForm.getErrorMessageComp().setFont(
176:                            isError ? HtmlText.FONT_ERROR
177:                                    : HtmlText.FONT_TEXT_EDIT);
178:                }
179:
180:                if (focus != null && (focus instanceof  HtmlFormComponent)) {
181:                    (focus).setVisible(true);
182:                    if (row > -1)
183:                        ((HtmlFormComponent) focus).setFocus(row);
184:                    else
185:                        ((HtmlFormComponent) focus).setFocus();
186:                }
187:            }
188:
189:            /**
190:             * Creation date: (10/26/01 5:17:41 AM)
191:             * @return com.salmonllc.html.HtmlComponent
192:             */
193:            protected com.salmonllc.html.HtmlComponent getMessageComponent() {
194:                return fieldMessageComponent;
195:            }
196:
197:            /**
198:             * Insert the method's description here.
199:             * Creation date: (8/2/01 10:16:09 AM)
200:             * @return java.lang.String
201:             */
202:            protected String getPrimaryKey(DataStore _ds)
203:                    throws com.salmonllc.sql.DataStoreException {
204:                int colCount = _ds.getColumnCount();
205:                String s = null;
206:                for (int i = 0; i < colCount; i++) {
207:                    if (!_ds.isPrimaryKey(i))
208:                        continue;
209:                    s = _ds.getColumnName(i);
210:                }
211:
212:                return s;
213:            }
214:
215:            /**
216:             * Insert the method's description here.
217:             * Creation date: (8/2/01 10:16:09 AM)
218:             * @return java.lang.String
219:             */
220:            protected String getPrimaryKeyName(DataStore _ds)
221:                    throws com.salmonllc.sql.DataStoreException {
222:                int colCount = _ds.getColumnCount();
223:                String s = null;
224:                for (int i = 0; i < colCount; i++) {
225:                    if (!_ds.isPrimaryKey(i))
226:                        continue;
227:                    s = _ds.getColumnName(i);
228:                }
229:
230:                if (s != null && s.indexOf(".") != -1)
231:                    s = s.substring(s.indexOf(".") + 1);
232:
233:                return s;
234:            }
235:
236:            /**
237:             * Gets all the User Components specified in Detail Form as a hastable
238:             * Creation date: (8/16/01 4:24:49 PM)
239:             * @return java.util.Hashtable
240:             */
241:            public java.util.Hashtable getUserComponents() {
242:                return _hashUserComponents;
243:            }
244:
245:            /**
246:             *	This method creates the list form for maintaining brokers
247:             *
248:             */
249:            public void initialize() throws Exception {
250:                super .initialize();
251:                try {
252:                    _messageText = new HtmlText("", this );
253:                    this .add(_messageText);
254:                    addPageListener(this );
255:                } catch (Exception e) {
256:                    writeMessage("Exception occured in initailize method of class "
257:                            + this .getClass().getName());
258:                }
259:            }
260:
261:            /**
262:             * Called when an error is encountered.
263:             * @return int	If true, continue processing the event.  Same convention as in
264:             *	ValueChangedEvent.valueChanged(), SubmitEvent.submitPerformed(), etc.
265:             */
266:            public boolean onDetailError(int code, java.lang.String message,
267:                    com.salmonllc.html.HtmlComponent component) {
268:                displayError(message, component);
269:                return false;
270:            }
271:
272:            /**
273:             *	This method verifies page access by returning TRUE.
274:             *	@return boolean
275:             */
276:
277:            public boolean pageAccess() {
278:                return (true);
279:            }
280:
281:            /**
282:             * Called before datastore retrieval.
283:             */
284:            public void pageRequested(PageEvent p) throws Exception {
285:                request(p);
286:            }
287:
288:            /**
289:             * 	This method/event will get fired each time a page is requested by the browser.
290:             *	@param p PageEvent
291:             *	@throws Exception
292:             */
293:            public void pageRequestEnd(PageEvent p) throws Exception {
294:                //writeMessage(getClassName() + ".pageRequestEnd()");
295:                //displayMessage(null);
296:            }
297:
298:            /**
299:             * 	This method occurs each time a page is sumbitted.
300:             *	@param p PageEvent
301:             */
302:            public void pageSubmitEnd(PageEvent p) {
303:                //writeMessage(getClassName() + ".pageSubmitEnd()");
304:            }
305:
306:            /**
307:             *	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.
308:             *	@param p PageEvent
309:             */
310:
311:            public void pageSubmitted(PageEvent p) {
312:
313:            }
314:
315:            /**
316:             * Called before Delete button is processed.
317:             * @return boolean	True if processing is to continue.
318:             */
319:            public boolean postDetailDelete() throws java.lang.Exception {
320:                return true;
321:            }
322:
323:            /**
324:             * Called after pageRequested is processed.
325:             * @return boolean	Currently undefined.
326:             */
327:            public boolean postDetailRequest() throws java.lang.Exception {
328:
329:                return false;
330:            }
331:
332:            /**
333:             * Called before Save button is processed on Detail page.
334:             * @return boolean	True if continue to save, else do not continue.
335:             */
336:            public boolean postDetailSave() throws java.lang.Exception {
337:
338:                return true;
339:            }
340:
341:            /**
342:             * Called before Delete button is processed.
343:             * @return boolean	True if processing is to continue.
344:             */
345:            public boolean preDetailDelete() throws java.lang.Exception {
346:                return true;
347:            }
348:
349:            /**
350:             * Called before pageRequested() is processed.
351:             * @return boolean	True if continue processing, else stop processing.
352:             */
353:            public boolean preDetailRequest() throws java.lang.Exception {
354:
355:                return true;
356:            }
357:
358:            /**
359:             * Called before Save button is processed on Detail page.
360:             * @return boolean	True if continue to save, else do not continue.
361:             */
362:            public boolean preDetailSave() throws java.lang.Exception
363:    {
364:        java.util.Hashtable hashComp = getUserComponents();
365:        java.util.Enumeration enum = hashComp.elements();
366:
367:        while(enum.hasMoreElements())
368:        {
369:            HtmlComponent comp = (HtmlComponent)enum.nextElement();
370:
371:            if(comp instanceof  HtmlFormComponent)
372:            {
373:                if(!checkComponent((HtmlFormComponent)comp, comp.getName()))
374:                {
375:                    break;
376:                }
377:            }
378:        }
379:        return true;
380:    }
381:
382:            /**
383:             *	This method is overridden in the descendant class/page.  It is used each time a user re-visits a page after the initial page generation by the initPage and createPage methods.
384:             *	@param p PageEvent
385:             *	@throws Exception
386:             */
387:
388:            public void request(PageEvent p) throws Exception {
389:            }
390:
391:            /**
392:             * Sets the message component
393:             * Creation date: (10/26/01 5:17:41 AM)
394:             * @param newMessageComponent com.salmonllc.html.HtmlComponent
395:             */
396:            public void setMessageComponent(
397:                    com.salmonllc.html.HtmlComponent newMessageComponent) {
398:                fieldMessageComponent = newMessageComponent;
399:            }
400:
401:            /**
402:             * Creation date: (8/16/01 4:24:49 PM)
403:             * @param newUserComponents java.util.Hashtable
404:             */
405:            public void setUserComponents(java.util.Hashtable newUserComponents) {
406:                _hashUserComponents = newUserComponents;
407:            }
408:
409:            /**
410:             *	This method is used to write a debug message to the Message Log in the descendant class/page.
411:             *	The message written to the log is the String value passed into this method.
412:             *	@param message java.lang.String
413:             */
414:
415:            public void writeMessage(String message) {
416:                MessageLog.writeDebugMessage("" + message, this );
417:            }
418:
419:            /**
420:             * Gets all the User Components specified in Detail Form as a hastable
421:             * Creation date: (8/16/01 4:24:49 PM)
422:             * @return java.util.Hashtable
423:             */
424:            public HtmlComponent getHtmlComponent(String name) {
425:                if (name != null)
426:                    return (HtmlComponent) getUserComponents().get(name);
427:                return null;
428:            }
429:
430:            public boolean submitPerformed(SubmitEvent e) throws Exception {
431:                return true;
432:            }
433:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.