Source Code Cross Referenced for DialogForm.java in  » Development » ivatamasks » com » ivata » mask » web » struts » 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 » Development » ivatamasks » com.ivata.mask.web.struts 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2001 - 2005 ivata limited.
003:         * All rights reserved.
004:         * -----------------------------------------------------------------------------
005:         * ivata masks may be redistributed under the GNU General Public
006:         * License as published by the Free Software Foundation;
007:         * version 2 of the License.
008:         *
009:         * These programs are free software; you can redistribute them and/or
010:         * modify them under the terms of the GNU General Public License
011:         * as published by the Free Software Foundation; version 2 of the License.
012:         *
013:         * These programs are distributed in the hope that they will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016:         *
017:         * See the GNU General Public License in the file LICENSE.txt for more
018:         * details.
019:         *
020:         * If you would like a copy of the GNU General Public License write to
021:         *
022:         * Free Software Foundation, Inc.
023:         * 59 Temple Place - Suite 330
024:         * Boston, MA 02111-1307, USA.
025:         *
026:         *
027:         * To arrange commercial support and licensing, contact ivata at
028:         *                  http://www.ivata.com/contact.jsp
029:         * -----------------------------------------------------------------------------
030:         * $Log: DialogForm.java,v $
031:         * Revision 1.11  2005/10/12 18:36:58  colinmacleod
032:         * Standardized format of Logger declaration - to make it easier to find instances
033:         * which are not both static and final.
034:         *
035:         * Revision 1.10  2005/10/11 18:54:06  colinmacleod
036:         * Fixed some checkstyle and javadoc issues.
037:         *
038:         * Revision 1.9  2005/10/03 10:17:25  colinmacleod
039:         * Fixed some style and javadoc issues.
040:         *
041:         * Revision 1.8  2005/10/02 14:06:34  colinmacleod
042:         * Added/improved log4j logging.
043:         *
044:         * Revision 1.7  2005/04/29 16:32:00  colinmacleod
045:         * Added clearReset as implementation for both
046:         * clear and reset methods.
047:         *
048:         * Revision 1.6  2005/04/09 18:04:18  colinmacleod
049:         * Changed copyright text to GPL v2 explicitly.
050:         *
051:         * Revision 1.5  2005/03/10 10:35:09  colinmacleod
052:         * Added default forwards.
053:         *
054:         * Revision 1.4  2005/01/19 12:56:36  colinmacleod
055:         * Added OperationNotSupportedException to clear.
056:         *
057:         * Revision 1.3  2005/01/07 08:08:24  colinmacleod
058:         * Moved up a version number.
059:         * Changed copyright notices to 2005.
060:         * Updated the documentation:
061:         *   - started working on multiproject:site docu.
062:         *   - changed the logo.
063:         * Added checkstyle and fixed LOADS of style issues.
064:         * Added separate thirdparty subproject.
065:         * Added struts (in web), util and webgui (in webtheme) from ivata op.
066:         *
067:         * Revision 1.2  2004/12/23 21:28:32  colinmacleod
068:         * Modifications to add ivata op compatibility.
069:         *
070:         * Revision 1.1.1.1  2004/05/16 20:40:32  colinmacleod
071:         * Ready for 0.1 release
072:         *
073:         * Revision 1.3  2004/03/21 21:16:08  colinmacleod
074:         * Shortened name to ivata op.
075:         *
076:         * Revision 1.2  2004/02/01 22:00:33  colinmacleod
077:         * Added full names to author tags
078:         *
079:         * Revision 1.1.1.1  2004/01/27 20:57:55  colinmacleod
080:         * Moved ivata op to SourceForge.
081:         *
082:         * Revision 1.1.1.1  2003/10/13 20:49:59  colin
083:         * Restructured portal into subprojects
084:         *
085:         * Revision 1.6  2003/04/14 07:12:33  peter
086:         * added helpKey field
087:         *
088:         * Revision 1.5  2003/02/24 19:08:17  colin
089:         * *** empty log message ***
090:         *
091:         * Revision 1.4  2003/02/04 17:37:37  colin
092:         * new interface
093:         * added onConfirm, onDelete and clear
094:         *
095:         * Revision 1.3  2003/01/31 16:16:39  colin
096:         * Fixed bugs on DeleteWarn & DeleteConfirm.
097:         *
098:         * Revision 1.1  2003/01/31 13:57:40  colin
099:         * first version
100:         * -----------------------------------------------------------------------------
101:         */
102:        package com.ivata.mask.web.struts;
103:
104:        import java.util.Locale;
105:
106:        import javax.naming.OperationNotSupportedException;
107:        import javax.servlet.http.HttpServletRequest;
108:        import javax.servlet.http.HttpSession;
109:
110:        import org.apache.log4j.Logger;
111:        import org.apache.struts.Globals;
112:        import org.apache.struts.action.ActionErrors;
113:        import org.apache.struts.action.ActionForm;
114:        import org.apache.struts.action.ActionMapping;
115:
116:        import com.ivata.mask.util.StringHandling;
117:        import com.ivata.mask.util.SystemException;
118:        import com.ivata.mask.validation.ValidationErrors;
119:
120:        /**
121:         * <p>
122:         * This form contains buttons and attributes commonly required in <i>ivata masks
123:         * </i> forms. You should override it and call <code>reset</code> on this form
124:         * from your form.
125:         * </p>
126:         *
127:         * <p>
128:         * This class originally appeared as part of <a
129:         * href="http://www.ivata.org">ivata op </a> and <a
130:         * href="http://www.ivata.com/portal">ivata team portal </a>.
131:         * </p>.
132:         *
133:         * @since ivata masks 0.4 (2003-01-31)
134:         * @author Colin MacLeod
135:         * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
136:         * @version $Revision: 1.11 $
137:         */
138:        public abstract class DialogForm extends ActionForm {
139:            /**
140:             * Logger for this class.
141:             */
142:            private static final Logger logger = Logger
143:                    .getLogger(DialogForm.class);
144:
145:            /**
146:             * <p>
147:             * If non- <code>null</code> or not empty, specifies that the form
148:             * contents should be amended/added and the window left open.
149:             * </p>
150:             */
151:            private String apply = null;
152:            /**
153:             * <p>
154:             * Localization messages resource bundle to use for <code>deleteKey</code>.
155:             * </p>
156:             */
157:            private String bundle = null;
158:            /**
159:             * <p>
160:             * Specifies whether or not we are adding a new element or clearing the form
161:             * fields.
162:             * </p>
163:             */
164:            private String clear = null;
165:            /**
166:             * <copyDoc>Refer to {@link #getDefaultForwardApply}.</copyDoc>
167:             */
168:            private String defaultForwardApply = "apply";
169:            /**
170:             * <copyDoc>Refer to {@link #getDefaultForwardOk}.</copyDoc>
171:             */
172:            private String defaultForwardDelete = "delete";
173:            /**
174:             * <copyDoc>Refer to {@link #getDefaultForwardOk}.</copyDoc>
175:             */
176:            private String defaultForwardOk = "ok";
177:            /**
178:             * <p>
179:             * If non- <code>null</code> or not empty, really delete the entry.
180:             * </p>
181:             */
182:            private String deleteConfirm = null;
183:            /**
184:             * <p>
185:             * If non- <code>null</code>, indicates a key to be displayed to warn
186:             * before deletion of the items in this form.
187:             * </p>
188:             *
189:             * <p>
190:             * The <code>FormTag</code> will check this value (or it's attribute
191:             * equivalent) and display JavaScript with the localized string this key
192:             * represents.
193:             * </p>
194:             */
195:            private String deleteKey = null;
196:            /**
197:             * <p>
198:             * If non- <code>null</code> or not empty, show a message before deleting.
199:             * </p>
200:             */
201:            private String deleteWarn = null;
202:            /**
203:             * <p>
204:             * Stores the correct help key.
205:             * </p>
206:             */
207:            private String helpKey = null;
208:            /**
209:             * <p>
210:             * If non- <code>null</code> or not empty, specifies that the form
211:             * contents should be amended/added.
212:             * </p>
213:             */
214:            private String ok = null;
215:
216:            /**
217:             * <p>
218:             * Clear all bean properties to their default state.The difference between
219:             * this and <code>reset</code> is that all properties are changed,
220:             * regardless of current request state.
221:             * </p>
222:             * @throws OperationNotSupportedException if this method must be overridden
223:             * to clear all form properties.
224:             */
225:            protected void clear() throws OperationNotSupportedException {
226:                if (logger.isDebugEnabled()) {
227:                    logger.debug("clear() - start");
228:                }
229:
230:                clearReset();
231:
232:                if (logger.isDebugEnabled()) {
233:                    logger.debug("clear() - end");
234:                }
235:            }
236:
237:            /**
238:             * Private implementation of <code>clear</code> and <code>reset</code> to
239:             * avoid repetition.
240:             */
241:            private void clearReset() {
242:                if (logger.isDebugEnabled()) {
243:                    logger.debug("clearReset() - start");
244:                }
245:
246:                setOk(null);
247:                setApply(null);
248:                setClear(null);
249:                setDeleteWarn(null);
250:                setDeleteConfirm(null);
251:
252:                if (logger.isDebugEnabled()) {
253:                    logger.debug("clearReset() - end");
254:                }
255:            }
256:
257:            /**
258:             * <p>
259:             * If non- <code>null</code> or not empty, specifies that the form
260:             * contents should be amended/added and the window left open.
261:             * </p>
262:             *
263:             * @return the current value of apply.
264:             */
265:            public final String getApply() {
266:                if (logger.isDebugEnabled()) {
267:                    logger.debug("getApply() - start");
268:                }
269:
270:                if (logger.isDebugEnabled()) {
271:                    logger.debug("getApply() - end - return value = " + apply);
272:                }
273:                return apply;
274:            }
275:
276:            /**
277:             * <p>
278:             * Localization messages resource bundle to use for <code>deleteKey</code>.
279:             * </p>
280:             *
281:             * @return the current value of bundle.
282:             */
283:            public final String getBundle() {
284:                if (logger.isDebugEnabled()) {
285:                    logger.debug("getBundle() - start");
286:                }
287:
288:                if (logger.isDebugEnabled()) {
289:                    logger
290:                            .debug("getBundle() - end - return value = "
291:                                    + bundle);
292:                }
293:                return bundle;
294:            }
295:
296:            /**
297:             * <p>
298:             * Get whether or not we are adding a new element or clearing the form
299:             * fields.
300:             * </p>
301:             *
302:             * @return a non- <code>null</code> and not empty value if the form is to
303:             *         be cleared.
304:             */
305:            public final String getClear() {
306:                if (logger.isDebugEnabled()) {
307:                    logger.debug("getClear() - start");
308:                }
309:
310:                if (logger.isDebugEnabled()) {
311:                    logger.debug("getClear() - end - return value = " + clear);
312:                }
313:                return clear;
314:            }
315:
316:            /**
317:             * Name of the <strong>Struts</strong> forward to go to, if the Apply button
318:             * is pressed.
319:             * @return Returns the name of the default <strong>Struts</strong> forward
320:             * for the Apply button.
321:             */
322:            public String getDefaultForwardApply() {
323:                if (logger.isDebugEnabled()) {
324:                    logger.debug("getDefaultForwardApply() - start");
325:                }
326:
327:                if (logger.isDebugEnabled()) {
328:                    logger
329:                            .debug("getDefaultForwardApply() - end - return value = "
330:                                    + defaultForwardApply);
331:                }
332:                return defaultForwardApply;
333:            }
334:
335:            /**
336:             * Name of the <strong>Struts</strong> forward to go to, if the Delete
337:             * button is pressed.
338:             * @return Returns the name of the default <strong>Struts</strong> forward
339:             * for the Delete button.
340:             */
341:            public String getDefaultForwardDelete() {
342:                if (logger.isDebugEnabled()) {
343:                    logger.debug("getDefaultForwardDelete() - start");
344:                }
345:
346:                if (logger.isDebugEnabled()) {
347:                    logger
348:                            .debug("getDefaultForwardDelete() - end - return value = "
349:                                    + defaultForwardDelete);
350:                }
351:                return defaultForwardDelete;
352:            }
353:
354:            /**
355:             * Name of the <strong>Struts</strong> forward to go to, if the Ok button
356:             * is pressed.
357:             * @return Returns the name of the default <strong>Struts</strong> forward
358:             * for the Ok button.
359:             */
360:            public String getDefaultForwardOk() {
361:                if (logger.isDebugEnabled()) {
362:                    logger.debug("getDefaultForwardOk() - start");
363:                }
364:
365:                if (logger.isDebugEnabled()) {
366:                    logger
367:                            .debug("getDefaultForwardOk() - end - return value = "
368:                                    + defaultForwardOk);
369:                }
370:                return defaultForwardOk;
371:            }
372:
373:            /**
374:             * <p>
375:             * If non- <code>null</code> or not empty, delete this element.
376:             * </p>
377:             *
378:             * @return the current value of delete confirm text.
379:             */
380:            public final String getDeleteConfirm() {
381:                if (logger.isDebugEnabled()) {
382:                    logger.debug("getDeleteConfirm() - start");
383:                }
384:
385:                if (logger.isDebugEnabled()) {
386:                    logger.debug("getDeleteConfirm() - end - return value = "
387:                            + deleteConfirm);
388:                }
389:                return deleteConfirm;
390:            }
391:
392:            /**
393:             * <p>
394:             * If non- <code>null</code>, indicates a key to be displayed to warn
395:             * before deletion of the items in this form.
396:             * </p>
397:             *
398:             * <p>
399:             * The <code>FormTag</code> will check this value (or it's attribute
400:             * equivalent) and display JavaScript with the localized string this key
401:             * represents.
402:             * </p>
403:             *
404:             * @return the current value of deleteKey.
405:             */
406:            public final String getDeleteKey() {
407:                if (logger.isDebugEnabled()) {
408:                    logger.debug("getDeleteKey() - start");
409:                }
410:
411:                if (logger.isDebugEnabled()) {
412:                    logger.debug("getDeleteKey() - end - return value = "
413:                            + deleteKey);
414:                }
415:                return deleteKey;
416:            }
417:
418:            /**
419:             * <p>
420:             * If non- <code>null</code> or not empty, display a message before
421:             * deleting this entry.
422:             * </p>
423:             *
424:             * @return the current value of delete.
425:             */
426:            public final String getDeleteWarn() {
427:                if (logger.isDebugEnabled()) {
428:                    logger.debug("getDeleteWarn() - start");
429:                }
430:
431:                if (logger.isDebugEnabled()) {
432:                    logger.debug("getDeleteWarn() - end - return value = "
433:                            + deleteWarn);
434:                }
435:                return deleteWarn;
436:            }
437:
438:            /**
439:             * <p>
440:             * Stores the correct help key..
441:             * </p>
442:             *
443:             * @return the current value of helpKey.
444:             */
445:            public final String getHelpKey() {
446:                if (logger.isDebugEnabled()) {
447:                    logger.debug("getHelpKey() - start");
448:                }
449:
450:                if (logger.isDebugEnabled()) {
451:                    logger.debug("getHelpKey() - end - return value = "
452:                            + helpKey);
453:                }
454:                return helpKey;
455:            }
456:
457:            /**
458:             * <p>
459:             * If non- <code>null</code> or not empty, specifies that the form
460:             * contents should be amended/added.
461:             * </p>
462:             *
463:             * @return the current value last returned by the OK button.
464:             */
465:            public final String getOk() {
466:                if (logger.isDebugEnabled()) {
467:                    logger.debug("getOk() - start");
468:                }
469:
470:                if (logger.isDebugEnabled()) {
471:                    logger.debug("getOk() - end - return value = " + ok);
472:                }
473:                return ok;
474:            }
475:
476:            /**
477:             * <p>
478:             * Reset all bean properties to their default state. This method is called
479:             * before the properties are re-populated by the controller servlet.
480:             * </p>
481:             *
482:             * @param mapping
483:             *            The mapping used to select this instance
484:             * @param request
485:             *            The servlet request we are processing
486:             */
487:            public void reset(final ActionMapping mapping,
488:                    final HttpServletRequest request) {
489:                if (logger.isDebugEnabled()) {
490:                    logger.debug("reset(ActionMapping mapping = " + mapping
491:                            + ", HttpServletRequest request = " + request
492:                            + ") - start");
493:                }
494:
495:                clearReset();
496:
497:                if (logger.isDebugEnabled()) {
498:                    logger
499:                            .debug("reset(ActionMapping, HttpServletRequest) - end");
500:                }
501:            }
502:
503:            /**
504:             * <p>
505:             * If non- <code>null</code> or not empty, specifies that the form
506:             * contents should be amended/added and the window left open.
507:             * </p>
508:             *
509:             * @param applyParam
510:             *            the new value of apply.
511:             */
512:            public final void setApply(final String applyParam) {
513:                if (logger.isDebugEnabled()) {
514:                    logger.debug("setApply(String applyParam = " + applyParam
515:                            + ") - start");
516:                }
517:
518:                this .apply = applyParam;
519:
520:                if (logger.isDebugEnabled()) {
521:                    logger.debug("setApply(String) - end");
522:                }
523:            }
524:
525:            /**
526:             * <p>
527:             * Localization messages resource bundle to use for <code>deleteKey</code>.
528:             * </p>
529:             *
530:             * @param bundleParam
531:             *            the new value of bundle.
532:             */
533:            public final void setBundle(final String bundleParam) {
534:                if (logger.isDebugEnabled()) {
535:                    logger.debug("setBundle(String bundleParam = "
536:                            + bundleParam + ") - start");
537:                }
538:
539:                this .bundle = bundleParam;
540:
541:                if (logger.isDebugEnabled()) {
542:                    logger.debug("setBundle(String) - end");
543:                }
544:            }
545:
546:            /**
547:             * <p>
548:             * Set whether or not we are adding a new element or clearing the form
549:             * fields.
550:             * </p>
551:             *
552:             * @param clearParam
553:             *            a non- <code>null</code> and not empty value if the form is
554:             *            to be cleared.
555:             */
556:            public final void setClear(final String clearParam) {
557:                if (logger.isDebugEnabled()) {
558:                    logger.debug("setClear(String clearParam = " + clearParam
559:                            + ") - start");
560:                }
561:
562:                this .clear = clearParam;
563:
564:                if (logger.isDebugEnabled()) {
565:                    logger.debug("setClear(String) - end");
566:                }
567:            }
568:
569:            /**
570:             * <copyDoc>Refer to {@link #getDefaultForwardApply}.</copyDoc>
571:             * @param defaultForwardApplyParam
572:             * <copyDoc>Refer to {@link #getDefaultForwardApply}.</copyDoc>
573:             */
574:            public final void setDefaultForwardApply(
575:                    final String defaultForwardApplyParam) {
576:                if (logger.isDebugEnabled()) {
577:                    logger.debug("setDefaultForwardApply before: '"
578:                            + defaultForwardApply + "', after: '"
579:                            + defaultForwardApplyParam + "'");
580:                }
581:
582:                defaultForwardApply = defaultForwardApplyParam;
583:
584:                if (logger.isDebugEnabled()) {
585:                    logger.debug("setDefaultForwardApply(String) - end");
586:                }
587:            }
588:
589:            /**
590:             * <copyDoc>Refer to {@link #getDefaultForwardDelete}.</copyDoc>
591:             * @param defaultForwardDeleteParam
592:             * <copyDoc>Refer to {@link #getDefaultForwardDelete}.</copyDoc>
593:             */
594:            public void setDefaultForwardDelete(
595:                    final String defaultForwardDeleteParam) {
596:                if (logger.isDebugEnabled()) {
597:                    logger.debug("setDefaultForwardDelete before: '"
598:                            + defaultForwardDelete + "', after: '"
599:                            + defaultForwardDeleteParam + "'");
600:                }
601:
602:                defaultForwardDelete = defaultForwardDeleteParam;
603:
604:                if (logger.isDebugEnabled()) {
605:                    logger.debug("setDefaultForwardDelete(String) - end");
606:                }
607:            }
608:
609:            /**
610:             * <copyDoc>Refer to {@link #getDefaultForwardOk}.</copyDoc>
611:             * @param defaultForwardOkParam
612:             * <copyDoc>Refer to {@link #getDefaultForwardOk}.</copyDoc>
613:             */
614:            public final void setDefaultForwardOk(
615:                    final String defaultForwardOkParam) {
616:                if (logger.isDebugEnabled()) {
617:                    logger.debug("setDefaultForwardOk before: '"
618:                            + defaultForwardOk + "', after: '"
619:                            + defaultForwardOkParam + "'");
620:                }
621:
622:                defaultForwardOk = defaultForwardOkParam;
623:
624:                if (logger.isDebugEnabled()) {
625:                    logger.debug("setDefaultForwardOk(String) - end");
626:                }
627:            }
628:
629:            /**
630:             * <p>
631:             * If non- <code>null</code> or not empty, delete this entry.
632:             * </p>
633:             *
634:             * @param deleteConfirmParam
635:             *            the new value of deleteConfirm.
636:             */
637:            public final void setDeleteConfirm(final String deleteConfirmParam) {
638:                if (logger.isDebugEnabled()) {
639:                    logger
640:                            .debug("setDeleteConfirm(String deleteConfirmParam = "
641:                                    + deleteConfirmParam + ") - start");
642:                }
643:
644:                this .deleteConfirm = deleteConfirmParam;
645:
646:                if (logger.isDebugEnabled()) {
647:                    logger.debug("setDeleteConfirm(String) - end");
648:                }
649:            }
650:
651:            /**
652:             * <p>
653:             * If non- <code>null</code>, indicates a key to be displayed to warn
654:             * before deletion of the items in this form.
655:             * </p>
656:             *
657:             * <p>
658:             * The <code>FormTag</code> will check this value (or it's attribute
659:             * equivalent) and display JavaScript with the localized string this key
660:             * represents.
661:             * </p>
662:             *
663:             * @param deleteKeyParam
664:             *            the new value of deleteKey.
665:             */
666:            public final void setDeleteKey(final String deleteKeyParam) {
667:                if (logger.isDebugEnabled()) {
668:                    logger.debug("setDeleteKey(String deleteKeyParam = "
669:                            + deleteKeyParam + ") - start");
670:                }
671:
672:                this .deleteKey = deleteKeyParam;
673:
674:                if (logger.isDebugEnabled()) {
675:                    logger.debug("setDeleteKey(String) - end");
676:                }
677:            }
678:
679:            /**
680:             * <p>
681:             * If non- <code>null</code> or not empty, display a message before
682:             * deleting this entry.
683:             * </p>
684:             *
685:             * @param deleteWarnParam
686:             *            the new value of deleteWarn.
687:             */
688:            public final void setDeleteWarn(final String deleteWarnParam) {
689:                if (logger.isDebugEnabled()) {
690:                    logger.debug("setDeleteWarn(String deleteWarnParam = "
691:                            + deleteWarnParam + ") - start");
692:                }
693:
694:                this .deleteWarn = deleteWarnParam;
695:
696:                if (logger.isDebugEnabled()) {
697:                    logger.debug("setDeleteWarn(String) - end");
698:                }
699:            }
700:
701:            /**
702:             * <p>
703:             * Stores the correct help key.
704:             * </p>
705:             *
706:             * @param helpKeyParam
707:             *            the new value of helpKey.
708:             */
709:            public final void setHelpKey(final String helpKeyParam) {
710:                if (logger.isDebugEnabled()) {
711:                    logger.debug("setHelpKey(String helpKeyParam = "
712:                            + helpKeyParam + ") - start");
713:                }
714:
715:                this .helpKey = helpKeyParam;
716:
717:                if (logger.isDebugEnabled()) {
718:                    logger.debug("setHelpKey(String) - end");
719:                }
720:            }
721:
722:            /**
723:             * <p>
724:             * If non- <code>null</code> or not empty, specifies that the form
725:             * contents should be amended/added.
726:             * </p>
727:             *
728:             * @param okParam
729:             *            the new value returned by the OK button.
730:             */
731:            public final void setOk(final String okParam) {
732:                if (logger.isDebugEnabled()) {
733:                    logger.debug("setOk(String okParam = " + okParam
734:                            + ") - start");
735:                }
736:
737:                this .ok = okParam;
738:
739:                if (logger.isDebugEnabled()) {
740:                    logger.debug("setOk(String) - end");
741:                }
742:            }
743:
744:            /**
745:             * <p>
746:             * Overridden to check if there were any errors from the mask request
747:             * processor.
748:             * </p>
749:             *
750:             * @param mapping
751:             *            <strong>Struts </strong> mapping we are currently processing.
752:             * @param request
753:             *            The non-HTTP request we are processing
754:             * @return any errors which occurred in validating the object, otherwise an
755:             *         empty <code>ActionErrors</code> instance.
756:             * @see org.apache.struts.action.ActionForm
757:             */
758:            public ActionErrors validate(final ActionMapping mapping,
759:                    final HttpServletRequest request) {
760:                if (logger.isDebugEnabled()) {
761:                    logger.debug("validate(ActionMapping mapping = " + mapping
762:                            + ", HttpServletRequest request = " + request
763:                            + ") - start");
764:                }
765:
766:                // only interested in errors when we confirm the dialog
767:                if (StringHandling.isNullOrEmpty(apply)
768:                        && StringHandling.isNullOrEmpty(ok)) {
769:                    if (logger.isDebugEnabled()) {
770:                        logger.debug("validate - end - return value = " + null);
771:                    }
772:                    return null;
773:                }
774:                ActionErrors actionErrors = super .validate(mapping, request);
775:                if (actionErrors == null) {
776:                    actionErrors = new ActionErrors();
777:                }
778:                // get the validation errors from the override
779:                ValidationErrors validationErrors = validate(request, request
780:                        .getSession());
781:
782:                // now convert them to Struts action errors
783:                Locale locale = (Locale) request.getSession().getAttribute(
784:                        Globals.LOCALE_KEY);
785:                try {
786:                    if (validationErrors != null) {
787:                        actionErrors.add(ValidationErrorsConvertor
788:                                .toActionErrors(validationErrors, locale));
789:                    }
790:                } catch (SystemException e) {
791:                    logger.error("validate(ActionMapping, HttpServletRequest)",
792:                            e);
793:
794:                    throw new RuntimeException(e);
795:                }
796:
797:                if (logger.isDebugEnabled()) {
798:                    logger.debug("validate - end - return value = "
799:                            + actionErrors);
800:                }
801:                return actionErrors;
802:            }
803:
804:            /**
805:             * <p>Validates the form contents.</p>
806:             *  @return this instance always returns an empty instance of
807:             * <code>ValidationErrors</code>.
808:             *
809:             * @param requestParam {@inheritDoc}
810:             * @param sessionParam {@inheritDoc}
811:             */
812:            public ValidationErrors validate(
813:                    final HttpServletRequest requestParam,
814:                    final HttpSession sessionParam) {
815:                if (logger.isDebugEnabled()) {
816:                    logger.debug("validate(HttpServletRequest request = "
817:                            + requestParam + ", HttpSession session = "
818:                            + sessionParam + ") - start");
819:                }
820:
821:                ValidationErrors returnValidationErrors = new ValidationErrors();
822:                if (logger.isDebugEnabled()) {
823:                    logger.debug("validate - end - return value = "
824:                            + returnValidationErrors);
825:                }
826:                return returnValidationErrors;
827:            }
828:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.