KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbforms > taglib > DbBaseHandlerTag


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbBaseHandlerTag.java,v 1.62 2005/02/22 14:15:03 hkollmann Exp $
3  * $Revision: 1.62 $
4  * $Date: 2005/02/22 14:15:03 $
5  *
6  * DbForms - a Rapid Application Development Framework
7  * Copyright (C) 2001 Joachim Peer <joepeer@excite.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */

23
24 package org.dbforms.taglib;
25
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28
29 import org.dbforms.config.Constants;
30 import org.dbforms.config.Field;
31 import org.dbforms.config.FieldTypes;
32 import org.dbforms.config.ResultSetVector;
33
34 import org.dbforms.event.WebEvent;
35 import org.dbforms.event.eventtype.EventType;
36
37 import org.dbforms.util.ICustomFormat;
38 import org.dbforms.util.IEscaper;
39 import org.dbforms.util.MessageResources;
40 import org.dbforms.util.MessageResourcesInternal;
41 import org.dbforms.util.ParseUtil;
42 import org.dbforms.util.ReflectionUtil;
43 import org.dbforms.util.Util;
44
45 import java.text.Format JavaDoc;
46
47 import java.util.HashMap JavaDoc;
48 import java.util.Locale JavaDoc;
49 import java.util.Vector JavaDoc;
50
51 import javax.servlet.http.HttpServletRequest JavaDoc;
52 import javax.servlet.http.HttpSession JavaDoc;
53 import javax.servlet.jsp.JspException JavaDoc;
54
55 /**
56  * <p>
57  * Base class for db-tags that render form data-elements capable of including
58  * JavaScript event handlers and/or CSS Style attributes.
59  * </p>
60  *
61  * <p>
62  * Furthermore, this base class provides base functionality for DataBase driven
63  * form widgets: it initializes the associated DbFormsConfig and provides
64  * various field-properties & methods (i.e getFormFieldName and
65  * getFormFieldValue)
66  * </p>
67  *
68  * <p>
69  * the html/css releated properties and methods where originally done by Don
70  * Clasen for Apache Groups's Jakarta-Struts project.
71  * </p>
72  *
73  * <p>
74  * Added support for Custom Formatter class, see SetCustomFormatter.java Author
75  * Neal Katz .
76  * </p>
77  *
78  * <p>
79  * Added support for overrideFormFieldName attribute. useful when working with
80  * customcontrollers. Author Neal Katz .
81  * </p>
82  * orginally done by Don Clasen
83  *
84  * @author Joe Peer (modified and extended this class for use in
85  * DbForms-Project)
86  */

87 public abstract class DbBaseHandlerTag extends TagSupportWithScriptHandler {
88     private static Log logCat = LogFactory.getLog(DbBaseHandlerTag.class
89             .getName());
90
91     private DbFormTag parentForm;
92
93     private IEscaper escaper = null;
94
95     private Field field;
96
97     private Format formatter;
98
99     // n.k. Support for CustomFormatter attribute - neal katz
100
private String JavaDoc customFormatter = null;
101
102     private String JavaDoc defaultValue;
103
104     private String JavaDoc escaperClass = null;
105
106     private String JavaDoc fieldName;
107
108     private String JavaDoc maxlength = null;
109
110     private String JavaDoc nullFieldValue;
111
112     // n.k. allow the FormFieldName to be overridden
113
private String JavaDoc overrideFormFieldName;
114
115     private String JavaDoc pattern;
116
117     private String JavaDoc readOnly = "false";
118
119     /** Named Style class associated with component for read-only mode. */
120     private String JavaDoc readOnlyStyleClass = null;
121
122     /**
123      * DOCUMENT ME!
124      *
125      * @param string
126      */

127     public void setCustomFormatter(String JavaDoc string) {
128         customFormatter = string;
129     }
130
131     /**
132      * DOCUMENT ME!
133      *
134      * @param value
135      * DOCUMENT ME!
136      */

137     public void setDefaultValue(String JavaDoc value) {
138         this.defaultValue = value;
139     }
140
141     /**
142      * "value" is only used if parent tag is in "insert-mode" (footer, etc.)
143      * otherwise this tag takes the current value from the database result!
144      *
145      * @return DOCUMENT ME!
146      */

147     public String JavaDoc getDefaultValue() {
148         return defaultValue;
149     }
150
151     /**
152      * DOCUMENT ME!
153      *
154      * @return DOCUMENT ME!
155      */

156     public IEscaper getEscaper() {
157         if (escaper == null) {
158             String JavaDoc s = getEscaperClass();
159
160             if (!Util.isNull(s)) {
161                 try {
162                     escaper = (IEscaper) ReflectionUtil.newInstance(s);
163                 } catch (Exception JavaDoc e) {
164                     logCat
165                             .error("cannot create the new escaper [" + s + "]",
166                                     e);
167                 }
168             }
169
170             if ((escaper == null) && (getField() != null)) {
171                 escaper = getField().getEscaper();
172             }
173
174             if ((escaper == null)) {
175                 escaper = getConfig().getEscaper();
176             }
177         }
178
179         return escaper;
180     }
181
182     /**
183      * DOCUMENT ME!
184      *
185      * @param string
186      */

187     public void setEscaperClass(String JavaDoc string) {
188         escaperClass = string;
189     }
190
191     /**
192      * DOCUMENT ME!
193      *
194      * @return
195      */

196     public String JavaDoc getEscaperClass() {
197         return escaperClass;
198     }
199
200     /**
201      * DOCUMENT ME!
202      *
203      * @return
204      */

205     public Field getField() {
206         return field;
207     }
208
209     /**
210      * DOCUMENT ME!
211      *
212      * @param fieldName
213      * DOCUMENT ME!
214      */

215     public void setFieldName(String JavaDoc fieldName) {
216         this.fieldName = fieldName;
217
218         if (getParentForm().getTable() != null) {
219             setField(getParentForm().getTable().getFieldByName(fieldName));
220         } else {
221             setField(null);
222         }
223
224         if (getParentForm().isSubForm() && (this.field != null)) {
225             // tell parent that _this_ class will generate the html tag, not
226
// DbBodyTag!
227
getParentForm().strikeOut(this.field);
228         }
229     }
230
231     /**
232      * formatting a value
233      *
234      * @param formatter
235      * DOCUMENT ME!
236      */

237     public void setFormatter(Format formatter) {
238         this.formatter = formatter;
239     }
240
241     /**
242      * formatting a value
243      *
244      * @return DOCUMENT ME!
245      */

246     public Format getFormatter() {
247         Format res = formatter;
248
249         if ((res == null) && (getField() != null)) {
250             res = getField().getFormat(pattern, getLocale());
251         }
252
253         return res;
254     }
255
256     /**
257      * Sets the maxlength
258      *
259      * @param maxlength
260      * The maxlength to set
261      */

262     public void setMaxlength(String JavaDoc maxlength) {
263         this.maxlength = maxlength;
264     }
265
266     /**
267      * Gets the maxlength
268      *
269      * @return Returns a String
270      */

271     public String JavaDoc getMaxlength() {
272         return maxlength;
273     }
274
275     /**
276      * DOCUMENT ME!
277      *
278      * @return
279      */

280     public String JavaDoc getName() {
281         return (getField() != null) ? getField().getName() : fieldName;
282     }
283
284     /**
285      * Sets the nullFieldValue attribute of the DbLabelTag object
286      *
287      * @param nullFieldValue
288      * The new nullFieldValue value
289      */

290     public void setNullFieldValue(String JavaDoc nullFieldValue) {
291         this.nullFieldValue = nullFieldValue;
292     }
293
294     /**
295      * DOCUMENT ME!
296      *
297      * @param string
298      */

299     public void setOverrideFormFieldName(String JavaDoc string) {
300         overrideFormFieldName = string;
301     }
302
303     /**
304      * DOCUMENT ME!
305      *
306      * @param parent
307      * DOCUMENT ME!
308      */

309     public void setParent(final javax.servlet.jsp.tagext.Tag JavaDoc parent) {
310         super.setParent(parent);
311
312         // between this form and its parent lies a DbHeader/Body/Footer-Tag and
313
// maybe other tags (styling, logic, etc.)
314
parentForm = (DbFormTag) findAncestorWithClass(this, DbFormTag.class);
315     }
316
317     /**
318      * DOCUMENT ME!
319      *
320      * @param string
321      */

322     public void setPattern(String JavaDoc string) {
323         pattern = string;
324     }
325
326     /**
327      * DOCUMENT ME!
328      *
329      * @return
330      */

331     public String JavaDoc getPattern() {
332         Format f = getFormatter();
333
334         if (f == null) {
335             return null;
336         }
337
338         return Util.getPattern(f);
339     }
340
341     /**
342      * Sets the read-only attribute.
343      *
344      * @param readOnly
345      * DOCUMENT ME!
346      */

347     public void setReadOnly(String JavaDoc readOnly) {
348         this.readOnly = readOnly;
349     }
350
351     /**
352      * Sets the style class attribute for read-only mode.
353      *
354      * @param readOnlyStyleClass
355      * DOCUMENT ME!
356      */

357     public void setReadOnlyStyleClass(String JavaDoc readOnlyStyleClass) {
358         this.readOnlyStyleClass = readOnlyStyleClass;
359     }
360
361     /**
362      * Returns the style class attribute for read-only mode.
363      *
364      * @return DOCUMENT ME!
365      */

366     public String JavaDoc getReadOnlyStyleClass() {
367         return readOnlyStyleClass;
368     }
369
370     /**
371      * DOCUMENT ME!
372      *
373      * @return DOCUMENT ME!
374      */

375     public String JavaDoc getStyleClass() {
376         boolean readonly = hasReadOnlySet() || getParentForm().hasReadOnlySet();
377
378         if (readonly && !Util.isNull(getReadOnlyStyleClass())) {
379             return getReadOnlyStyleClass();
380         } else {
381             return super.getStyleClass();
382         }
383     }
384
385     /**
386      * DOCUMENT ME!
387      *
388      * @param s
389      *
390      * @return
391      */

392     protected String JavaDoc customFormat(String JavaDoc s) {
393         if (!Util.isNull(customFormatter)) {
394             HttpSession JavaDoc session = pageContext.getSession();
395             HashMap JavaDoc hm = (HashMap JavaDoc) session
396                     .getAttribute(SetCustomFormatterTag.sessionKey);
397             if (hm != null) {
398                 Object JavaDoc obj = hm.get(customFormatter);
399                 if (obj instanceof ICustomFormat) {
400                     ICustomFormat cf = (ICustomFormat) obj;
401                     Locale JavaDoc locale = MessageResources
402                             .getLocale((HttpServletRequest JavaDoc) pageContext
403                                     .getRequest());
404                     cf.setLocale(locale);
405                     s = cf.sprintf(s);
406                 }
407             }
408         }
409         return s;
410     }
411
412     /**
413      * DOCUMENT ME!
414      */

415     public void doFinally() {
416         formatter = null;
417         field = null;
418         defaultValue = null;
419         pattern = null;
420         nullFieldValue = null;
421         maxlength = null;
422         readOnlyStyleClass = null;
423         readOnly = "false";
424         escaperClass = null;
425         escaper = null;
426         customFormatter = null;
427         overrideFormFieldName = null;
428         super.doFinally();
429     }
430
431     /**
432      * Returns the read-only attribute.
433      *
434      * @return DOCUMENT ME!
435      */

436     public boolean hasReadOnlySet() {
437         return Util.getTrue(readOnly);
438     }
439
440     /**
441      * DOCUMENT ME!
442      *
443      * @return
444      */

445     protected String JavaDoc getCustomFormatter() {
446         return customFormatter;
447     }
448
449     /**
450      * DOCUMENT ME!
451      *
452      * @param field
453      * DOCUMENT ME!
454      */

455     protected void setField(Field field) {
456         this.field = field;
457     }
458
459     /**
460      * return the object value from the database
461      *
462      * @return the object
463      */

464     protected Object JavaDoc getFieldObject() {
465         Object JavaDoc fieldValueObj = null;
466         ResultSetVector res = getParentForm().getResultSetVector();
467
468         if ((res != null) && (getField() != null)) {
469             fieldValueObj = res.getFieldAsObject(getField().getName());
470         } else {
471             // try to get old value if we have an unbounded field!
472
fieldValueObj = ParseUtil.getParameter(
473                     (HttpServletRequest JavaDoc) pageContext.getRequest(),
474                     getFormFieldName());
475
476             if (fieldValueObj == null) {
477                 // if we have an unbounded field and no old value then use
478
// default!
479
fieldValueObj = getDefaultValue();
480             } else {
481                 fieldValueObj = (getEscaper() == null) ? fieldValueObj
482                         : getEscaper().unescapeHTML((String JavaDoc) fieldValueObj);
483             }
484         }
485
486         return fieldValueObj;
487     }
488
489     /**
490      * fetches the value from the database. if no value is given, contents of
491      * attribute nullFieldValue is returned.
492      *
493      * @return the field value
494      */

495     protected String JavaDoc getFieldValue() {
496         ResultSetVector rsv = getParentForm().getResultSetVector();
497         String JavaDoc res = null;
498
499         if ((getField() != null) && (rsv != null)) {
500             String JavaDoc[] s = rsv.getCurrentRow();
501
502             if (s != null) {
503                 res = rsv.getCurrentRow()[getField().getId()];
504             }
505         }
506
507         return res;
508     }
509
510     /**
511      * DOCUMENT ME!
512      *
513      * @return DOCUMENT ME!
514      */

515     protected String JavaDoc getFormFieldDefaultValue() {
516         if (defaultValue != null) {
517             // default value defined by jsp-developer (provided via the "value"
518
// attribute of the tag)
519
return defaultValue;
520         }
521
522         // fill out empty fields so that there are no plain field-syntax errors
523
// on database operations...
524
return typicalDefaultValue();
525     }
526
527     /**
528      * generates the decoded name for the html-widget.
529      *
530      * @return DOCUMENT ME!
531      */

532     protected String JavaDoc getFormFieldName() {
533         if (hasOverrideFormFieldNameSet()) {
534             return getOverrideFormFieldName();
535         }
536
537         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
538
539         if ((getParentForm().getTable() != null) && (getField() != null)) {
540             String JavaDoc keyIndex = (getParentForm().isFooterReached()) ? (Constants.FIELDNAME_INSERTPREFIX + getParentForm()
541                     .getPositionPathCore())
542                     : getParentForm().getPositionPath();
543             buf.append(Constants.FIELDNAME_PREFIX);
544             buf.append(getParentForm().getTable().getId());
545             buf.append("_");
546             buf.append(keyIndex);
547             buf.append("_");
548             buf.append(getField().getId());
549         } else {
550             buf.append(fieldName);
551         }
552
553         return buf.toString();
554     }
555
556     /**
557      * Philip Grunikiewicz 2001-05-31 determinates value of the html-widget. In
558      * a jsp which contains many input fields, it may be desirable, in the event
559      * of an error, to redisplay input data. (instead of refreshing the fields
560      * from the DB) Currently dbforms implements this functionality with INSERT
561      * fields only. The following describes the changes I've implemented: - I've
562      * added a new attribute in the Form tag which sets the functionality
563      * (redisplayFieldsOnError=true/false) - I've modified the code below to
564      * handle the redisplay of previously posted information
565      *
566      * @return DOCUMENT ME!
567      */

568     protected String JavaDoc getFormFieldValue() {
569         HttpServletRequest JavaDoc request = (HttpServletRequest JavaDoc) this.pageContext
570                 .getRequest();
571         Vector errors = (Vector) request.getAttribute("errors");
572         WebEvent we = getParentForm().getWebEvent();
573
574         // Are we in Update mode
575
if (!getParentForm().isFooterReached()) {
576             // Check if attribute 'redisplayFieldsOnError' has been set to true
577
// and is this jsp displaying an error?
578
if ((getParentForm().hasRedisplayFieldsOnErrorSet()
579                     && (errors != null) && (errors.size() > 0))
580                     || ((we != null) && EventType.EVENT_NAVIGATION_RELOAD
581                             .equals(we.getType()))) {
582                 // Yes - redisplay posted data
583
String JavaDoc oldValue = ParseUtil.getParameter(request,
584                         getFormFieldName());
585
586                 if (oldValue != null) {
587                     return oldValue;
588                 }
589             }
590
591             return getFormattedFieldValue();
592         } else {
593             // the form field is in 'insert-mode'
594
if (((we != null) && (EventType.EVENT_NAVIGATION_COPY.equals(we
595                     .getType())))) {
596                 String JavaDoc copyValue = ParseUtil.getParameter(request,
597                         getFormFieldNameForCopyEvent());
598
599                 if (copyValue != null) {
600                     return copyValue;
601                 }
602             }
603
604             if (((we != null) && EventType.EVENT_NAVIGATION_RELOAD.equals(we
605                     .getType()))
606                     || ((errors != null) && (errors.size() > 0))) {
607                 String JavaDoc oldValue = ParseUtil.getParameter(request,
608                         getFormFieldName());
609
610                 if (oldValue != null) {
611                     return oldValue;
612                 }
613
614                 // Patch to reload checkbox, because when unchecked checkbox is
615
// null
616
// If unchecked, return anything different of
617
// typicalDefaultValue() ...
618
if (this instanceof DbCheckboxTag) {
619                     return typicalDefaultValue() + "_";
620                 }
621             }
622
623             return getFormFieldDefaultValue();
624         }
625     }
626
627     /**
628      * fetches the value from the database. if no value is given, contents of
629      * attribute nullFieldValue is returned.
630      *
631      * @return the field value
632      */

633     protected String JavaDoc getFormattedFieldValue() {
634         Object JavaDoc fieldValueObj = getFieldObject();
635         String JavaDoc res;
636
637         if (fieldValueObj == null) {
638             res = getNullFieldValue();
639         } else {
640             // if column object returned by database is of type
641
// 'array of byte: byte[]' (which can happen in case
642
// of eg. LONGVARCHAR columns), method toString would
643
// just return a sort of String representation
644
// of the array's address. So in this case it is
645
// better to create a String using a corresponding
646
// String constructor:
647
if (fieldValueObj.getClass().isArray()
648                     && "byte".equals(fieldValueObj.getClass()
649                             .getComponentType().toString())) {
650                 res = new String JavaDoc((byte[]) fieldValueObj);
651             } else if (getField() != null) {
652                 switch (getField().getType()) {
653                 case FieldTypes.INTEGER:
654                 case FieldTypes.DOUBLE:
655                 case FieldTypes.FLOAT:
656                 case FieldTypes.NUMERIC:
657                 case FieldTypes.DATE:
658                 case FieldTypes.TIME:
659                 case FieldTypes.TIMESTAMP:
660
661                     try {
662                         res = getFormatter().format(fieldValueObj);
663                     } catch (Exception JavaDoc e) {
664                         logCat.error("field type: " + getField().getType()
665                                 + "\n" + "object type: "
666                                 + fieldValueObj.getClass().getName() + "\n"
667                                 + "pattern: " + getPattern() + "\n"
668                                 + e.getMessage());
669                         res = fieldValueObj.toString();
670                     }
671
672                     break;
673
674                 case FieldTypes.BLOB:
675                 case FieldTypes.DISKBLOB:
676                 case FieldTypes.CHAR:
677                 default:
678                     res = fieldValueObj.toString();
679
680                     break;
681                 }
682             } else {
683                 res = fieldValueObj.toString();
684             }
685         }
686         // add support for custom formatting - neal katz
687
res = customFormat(res);
688         return res;
689     }
690
691     /**
692      * DOCUMENT ME!
693      *
694      * @return DOCUMENT ME!
695      */

696     protected Locale JavaDoc getLocale() {
697         return getParentForm().getLocale();
698     }
699
700     /**
701      * DOCUMENT ME!
702      *
703      * @return
704      */

705     protected String JavaDoc getOverrideFormFieldName() {
706         return overrideFormFieldName;
707     }
708
709     /**
710      * DOCUMENT ME!
711      *
712      * @return DOCUMENT ME!
713      */

714     protected DbFormTag getParentForm() {
715         return parentForm;
716     }
717
718     /**
719      * Just a shortcut for calling the escaper
720      *
721      * @param html
722      * string to escape
723      *
724      * @return escaped string
725      */

726     protected String JavaDoc escapeHTML(String JavaDoc html) {
727         return (getEscaper() == null) ? html : getEscaper().escapeHTML(html);
728     }
729
730     /**
731      * DOCUMENT ME!
732      *
733      * @return
734      */

735     protected boolean hasOverrideFormFieldNameSet() {
736         return overrideFormFieldName != null;
737     }
738
739     /**
740      * writes out the field value in hidden field _old
741      *
742      * @return DOCUMENT ME!
743      */

744     protected String JavaDoc renderOldValueHtmlInputField() {
745         StringBuffer JavaDoc tagBuf = new StringBuffer JavaDoc();
746         tagBuf.append("<input type=\"hidden\" name=\"");
747         tagBuf.append(Constants.FIELDNAME_OLDVALUETAG + getFormFieldName());
748         tagBuf.append("\" value=\"");
749
750         if (!getParentForm().isFooterReached()) {
751             tagBuf.append(escapeHTML(getFormattedFieldValue()));
752         } else {
753             tagBuf.append(escapeHTML(getFormFieldDefaultValue()));
754         }
755
756         tagBuf.append("\" />");
757
758         return tagBuf.toString();
759     }
760
761     /**
762      * writes out the current used format to the page
763      *
764      * @return DOCUMENT ME!
765      *
766      * @throws JspException
767      */

768     protected String JavaDoc renderPatternHtmlInputField() {
769         StringBuffer JavaDoc tagBuf = new StringBuffer JavaDoc();
770         String JavaDoc ppattern = getPattern();
771
772         if (!Util.isNull(ppattern)) {
773             tagBuf.append("<input type=\"hidden\" name=\"");
774             tagBuf.append(Constants.FIELDNAME_PATTERNTAG + getFormFieldName());
775             tagBuf.append("\" value=\"");
776             tagBuf.append(ppattern);
777             tagBuf.append("\" />");
778         }
779
780         return tagBuf.toString();
781     }
782
783     /**
784      * DOCUMENT ME!
785      *
786      * @return DOCUMENT ME!
787      */

788     protected String JavaDoc typicalDefaultValue() {
789         // 20030113-HKK: Change to use format too
790
String JavaDoc res = "";
791
792         if (getField() != null) {
793             switch (field.getType()) {
794             case org.dbforms.config.FieldTypes.INTEGER:
795             case org.dbforms.config.FieldTypes.NUMERIC:
796             case org.dbforms.config.FieldTypes.DOUBLE:
797             case org.dbforms.config.FieldTypes.FLOAT:
798
799                 try {
800                     res = getFormatter().format(new Double JavaDoc(0));
801                 } catch (Exception JavaDoc e) {
802                     res = "0";
803                 }
804
805             // in all other cases we just leave the formfield empty
806
}
807         }
808
809         return res;
810     }
811
812     /**
813      * writes out all hidden fields for the input fields
814      */

815     protected void writeOutSpecialValues() throws JspException JavaDoc {
816         try {
817             pageContext.getOut().write(renderOldValueHtmlInputField());
818         } catch (java.io.IOException JavaDoc ioe) {
819             throw new JspException JavaDoc("IO Error: " + ioe.getMessage());
820         }
821     }
822
823     /**
824      * generates the decoded name for the html-widget in the case of copy
825      * events.
826      *
827      * @return DOCUMENT ME!
828      */

829     private String JavaDoc getFormFieldNameForCopyEvent() {
830         boolean footerReached = getParentForm().isFooterReached();
831         getParentForm().setFooterReached(false);
832
833         String JavaDoc name = getFormFieldName();
834         getParentForm().setFooterReached(footerReached);
835
836         return name;
837     }
838
839     /**
840      * Gets the nullFieldValue attribute of the DbLabelTag object
841      *
842      * @return The nullFieldValue value
843      */

844     private String JavaDoc getNullFieldValue() {
845         String JavaDoc res = nullFieldValue;
846
847         if (res == null) {
848             res = MessageResourcesInternal.getMessage("dbforms.nodata",
849                     getLocale());
850         }
851
852         // Resolve message if captionResource=true in the Form Tag
853
if ((getParentForm() != null)
854                 && getParentForm().hasCaptionResourceSet()) {
855             res = MessageResources.getMessage(res, getLocale(), res);
856         }
857
858         /**
859          * Philip Grunikiewicz 2003-12-04 The data being return has a value of
860          * null. The developer has not specified a substitute. So instead of
861          * crashing, lets display an empty string!
862          */

863         if (res == null) {
864             res = "";
865         }
866
867         return res;
868     }
869 }
870
Popular Tags