001: package com.salmonllc.jsp.controller;
002:
003: /////////////////////////
004: //$Archive: /sofia/sourcecode/com/salmonllc/jsp/controller/FormBinder.java $
005: //$Author: Deepak $
006: //$Revision: 49 $
007: //$Modtime: 10/28/03 10:16a $
008: /////////////////////////
009: import java.util.Hashtable;
010: import java.util.Vector;
011:
012: import com.salmonllc.forms.DetailForm;
013: import com.salmonllc.forms.ListForm;
014: import com.salmonllc.html.*;
015: import com.salmonllc.properties.Props;
016: import com.salmonllc.sql.DataStore;
017: import com.salmonllc.util.MessageLog;
018: import com.salmonllc.util.Util;
019: import com.salmonllc.xml.*;
020:
021: /**
022: * FormBinder is used to bind various components in List and DetailForm to their XML formats.
023: * Creation date: (7/20/01 4:30:05 PM)
024: * @author Deepak Agarwal
025: */
026: public class FormBinder extends DataBinder {
027: private String fieldXMLFileName = "";
028:
029: /**
030: * ListFormBinder constructor comment.
031: */
032: public FormBinder(String xmlFileName) {
033: super ();
034: fieldXMLFileName = xmlFileName;
035: }
036:
037: /**
038: * This method binds the detail form component to the data definitions specified by XML file
039: * Creation date: (7/20/01 4:33:39 PM)
040: * @return com.salmonllc.forms.ListForm
041: */
042: public com.salmonllc.forms.DetailForm bindDetailForm(com.salmonllc.forms.DetailForm detailForm, BaseDetailController page)
043: {
044:
045: try
046: {
047: XMLStoreParser parser = new XMLStoreParser(false);
048: XMLStoreParser.parseFile(getXMLFileName());
049:
050: ResultSetMetaData rsm = parser.getMetaData();
051: DataStore _ds = detailForm.getDataStore();
052:
053: HtmlComponent lastCompAdded = null;
054:
055: page.setUserComponents(new Hashtable());
056:
057: ColumnMetaData cmd = null;
058:
059: String componentType = null;
060:
061: String component = null;
062: String table = null;
063: String column = null;
064: String caption = null;
065: String maxlength = null;
066: String size = null;
067: int type = -1;
068: int flags = -1;
069: String href = null;
070:
071: Options values = null;
072: Options params = null;
073:
074: String jointo = null;
075:
076: HtmlLink lnk = null;
077:
078: String fullColName = null;
079:
080: Vector vct = rsm.getMetaData();
081: for (int i = 0; i < vct.size(); i++)
082: {
083: lastCompAdded = null;
084: cmd = (ColumnMetaData) vct.elementAt(i);
085:
086: component = cmd.getComponent();
087: componentType = cmd.getComponentType();
088:
089: table = cmd.getTable();
090: column = cmd.getColumnName();
091: caption = cmd.getCaption();
092:
093: /** assigning max length */
094: maxlength = cmd.getMaxLength();
095: int maxLengthValue = 0;
096: if(maxlength != null)
097: maxLengthValue = (new Integer(maxlength)).intValue();
098:
099: /** ASsigning size */
100: size = cmd.getSize();
101: int sizeValue = 0;
102: if(size != null)
103: sizeValue = (new Integer(size)).intValue();
104:
105: type = mapDataType(cmd.getColumnType());
106: jointo = cmd.getJoinTo();
107:
108: /** Create the Flags for the detail form */
109: flags = createDetailMode(cmd);
110:
111: href = cmd.getHref();
112: if (Util.isFilled(href))
113: href = "'" + href + "&id='+" + page.getPrimaryKey(detailForm.getDataStore());
114:
115: // create a full column name
116: fullColName = createFulColumnName(table, column);
117:
118: if (!cmd.isBucket() && !cmd.isNotBound())
119: {
120: if (detailForm.getDataStore().getColumnIndex(fullColName) < 0)
121: {
122: // add the column to datastore
123: detailForm.getDataStore().addColumn(fullColName, type, cmd.isPrimaryKey(), true);
124: if( cmd.isPrimaryKey() )
125: detailForm.getDataStore().setAutoIncrement(fullColName, cmd.isAutoIncrement());
126:
127: if (Util.isFilled(jointo))
128: {
129: detailForm.getDataStore().addJoin(fullColName, jointo, false);
130: }
131: }
132: }
133:
134: if (cmd.isDetailDisplay())
135: {
136: values = cmd.getValues();
137: if (values != null)
138: {
139: String comp = values.getComponent();
140: String valuesType = values.getType();
141: boolean isEmptyRequried = values.isMandatory(); // check for flags
142: if (values.isMandatory())
143: flags |= DetailForm.IS_REQUIRED;
144: if (comp != null && comp.equalsIgnoreCase("IntegerDropDown"))
145: {
146: if (valuesType != null && valuesType.equalsIgnoreCase("Static"))
147: {
148: lastCompAdded = detailForm.addIntegerDropDown(table, column, caption, flags, values.getIntKeys(), values.getStringObjects(), isEmptyRequried);
149: ((HtmlDropDownList)lastCompAdded).sort();
150: }
151: else
152: {
153: lastCompAdded = detailForm.addPreInitDropDown(table, column, caption, flags, values.getTable(), values.getInitColumn(), values.getDescColumn(), null, null);
154: ((HtmlDropDownList)lastCompAdded).sort();
155: }
156: }
157: else if (comp != null && comp.equalsIgnoreCase("IntegerRadioButtonGroup"))
158: {
159: if (valuesType != null && valuesType.equalsIgnoreCase("Static"))
160: lastCompAdded = detailForm.addIntegerRadioButtonGroup(table, column, caption, flags, values.getIntKeys(), values.getStringObjects());
161: else
162: lastCompAdded = detailForm.addPreInitRadioButtonGroup(table, column, caption, flags, values.getTable(), values.getInitColumn(), values.getDescColumn(), null, null);
163: }
164: else if (comp != null && comp.equalsIgnoreCase("StringRadioButtonGroup"))
165: {
166: if (valuesType != null && valuesType.equalsIgnoreCase("Static"))
167: lastCompAdded = detailForm.addStringRadioButtonGroup(table, column, caption, flags, values.getStringKeys(), values.getStringObjects());
168: else
169: lastCompAdded = detailForm.addPreInitStringRadioButtonGroup(table, column, caption, flags, values.getTable(), values.getInitColumn(), values.getDescColumn());
170: }
171: else if (comp != null && comp.equalsIgnoreCase("StringDropDown"))
172: {
173: if (valuesType != null && valuesType.equalsIgnoreCase("Static"))
174: {
175: lastCompAdded = detailForm.addStringDropDown(table, column, caption, flags, values.getStringKeys(), values.getStringObjects(), isEmptyRequried);
176: ((HtmlDropDownList)lastCompAdded).sort();
177: }
178: else
179: {
180: lastCompAdded = detailForm.addPreInitStringDropDown(table, column, caption, flags, values.getTable(), values.getInitColumn(), values.getDescColumn());
181: ((HtmlDropDownList)lastCompAdded).sort();
182: }
183:
184: }
185: }
186: else
187: {
188: if (componentType != null && componentType.equalsIgnoreCase("HtmlLink"))
189: {
190: lnk = new HtmlLink(column, "", page);
191: if (Util.isFilled(href))
192: {
193: lnk.setHrefExpression(_ds, href);
194: }
195: if (cmd.getImageFile() != null && !cmd.getImageFile().equalsIgnoreCase(""))
196: {
197: lnk.add(new HtmlImage(cmd.getImageFile(), page));
198: }
199:
200: detailForm.addComponent(caption, lnk, flags);
201: lastCompAdded = lnk;
202: }
203: else if (componentType != null && componentType.equalsIgnoreCase("HtmlTextEdit"))
204: { // create active only checkbox
205: HtmlTextEdit hte = new HtmlTextEdit(fullColName, page);
206: hte.setColumn(_ds, fullColName);
207:
208: if(maxLengthValue != 0)
209: {
210: hte.setMaxLength(maxLengthValue);
211: if(sizeValue != 0)
212: {
213: hte.setSize(sizeValue);
214: }
215: }
216:
217: params = cmd.getParms();
218: if (params != null)
219: {
220:
221: java.util.Enumeration enum = params.keys();
222: while (enum.hasMoreElements())
223: {
224: String propertyName = enum.nextElement().toString();
225: Object keyval = params.get(propertyName);
226: Util.executeMethod(hte, propertyName, keyval);
227: }
228: }
229:
230: detailForm.addComponent(caption, hte, flags);
231: lastCompAdded = hte;
232: }
233: else if (componentType != null && componentType.equalsIgnoreCase("HtmlCheckBox"))
234: { // create active only checkbox
235: HtmlCheckBox _chkBox = new HtmlCheckBox(column, page, "1", "0"); // _chkBox.setValue("1");
236: detailForm.addComponent(caption, _chkBox, flags);
237: lastCompAdded = _chkBox;
238: }
239: else if (componentType != null && componentType.equalsIgnoreCase("HtmlSSNComponent"))
240: { // create active only checkbox
241: HtmlSSNComponent _ssnComp = new HtmlSSNComponent(column, page, "-", true);
242: _ssnComp.setColumn(_ds, column);
243: detailForm.addComponent(caption, _ssnComp, flags);
244: lastCompAdded = _ssnComp;
245: }
246: else if (componentType != null && componentType.equalsIgnoreCase("HtmlMultiLineEdit"))
247: {
248: HtmlMultiLineTextEdit _textEdit = new HtmlMultiLineTextEdit(column, page);
249: _textEdit.setColumn(_ds, fullColName);
250:
251: if(maxLengthValue != 0)
252: _textEdit.setColumns(maxLengthValue);
253: else
254: _textEdit.setColumns(75);
255:
256: if(sizeValue != 0)
257: _textEdit.setRows(sizeValue);
258:
259: detailForm.addComponent(caption, _textEdit, flags);
260: lastCompAdded = _textEdit;
261: }
262: else if (componentType != null && componentType.equalsIgnoreCase("HtmlDateComponent"))
263: {
264: HtmlDateComponent dc = new HtmlDateComponent(column, page, -1);
265: dc.setColumn(_ds, fullColName);
266: detailForm.addComponent(caption, dc, flags);
267: lastCompAdded = dc;
268: }
269: else if (componentType != null && componentType.equalsIgnoreCase("HtmlStateComponent"))
270: {
271: HtmlStateComponent sc = new HtmlStateComponent(column, page, true);
272: sc.setColumn(_ds, fullColName);
273: detailForm.addComponent(caption, sc, flags);
274: lastCompAdded = sc;
275: }
276: else if (componentType != null && componentType.equalsIgnoreCase("HtmlEMailComponent"))
277: {
278: HtmlEMailComponent em = new HtmlEMailComponent(column, page);
279: em.setColumn(_ds, fullColName);
280: detailForm.addComponent(caption, em, flags);
281: lastCompAdded = em;
282: }
283: else if (componentType != null && componentType.equalsIgnoreCase("HtmlZipCodeComponent"))
284: {
285: HtmlZipCodeComponent zc = new HtmlZipCodeComponent(column, page);
286: zc.setColumn(_ds, fullColName);
287: detailForm.addComponent(caption, zc, flags);
288: lastCompAdded = zc;
289: }
290: else if (componentType != null && componentType.equalsIgnoreCase("HtmlTelephoneComponent"))
291: {
292: HtmlTelephoneComponent tc = new HtmlTelephoneComponent(column, page);
293: tc.setColumn(_ds, fullColName);
294: detailForm.addComponent(caption, tc, flags);
295: lastCompAdded = tc;
296: }
297: else if (componentType != null && componentType.equalsIgnoreCase("HtmlFileUpload"))
298: {
299: HtmlFileUpload fu = new HtmlFileUpload(column, page);
300: fu.setColumns(_ds, null, fullColName, null, null);
301: detailForm.addComponent(caption, fu, flags);
302: fu.addFileUploadListener(detailForm);
303: detailForm.setFileUploadDirectory(page.getPageProperties().getProperty("FILE_UPLOAD_DIRECTORY", "/"));
304: page.setFormType(HtmlPage.FORMTYPE_MULTIPART);
305: lastCompAdded = fu;
306: }
307: else if (componentType != null && componentType.equalsIgnoreCase("HtmlSubmitButton"))
308: {
309: HtmlSubmitButton button = new HtmlSubmitButton(column, cmd.getColumnName(), page);
310: button.setOnClick(cmd.getOnClick());
311: detailForm.addComponent(null, button, flags);
312: button.addSubmitListener(page);
313: lastCompAdded = button;
314: }
315: else
316: {
317: lastCompAdded = detailForm.addColumn(table, column, caption, cmd.getDefaultValue(), type, flags);
318: }
319:
320: } // ENd of If else of Values or no Values
321: // assign the userComponents
322: if (component != null && lastCompAdded != null)
323: {
324: if (page.getUserComponents() == null)
325: page.setUserComponents(new Hashtable());
326: page.getUserComponents().put(component, lastCompAdded);
327: }
328:
329: } // if isDetail Display
330: } // For loop
331: }
332: catch (java.io.UnsupportedEncodingException e)
333: {
334: MessageLog.writeErrorMessage("bindDetailForm", e, this );
335: }
336: catch (java.lang.Exception e)
337: {
338: MessageLog.writeErrorMessage("bindDetailForm", e, this );
339: }
340:
341: return detailForm;
342: }
343:
344: /**
345: * This method binds the list form component to the data definitions specified by XML file
346: * Creation date: (7/20/01 4:33:39 PM)
347: * @return com.salmonllc.forms.ListForm
348: */
349: public com.salmonllc.forms.ListForm bindListForm(com.salmonllc.forms.ListForm ls, BaseListController page, String querystring)
350: {
351:
352: try
353: {
354: XMLStoreParser parser = new XMLStoreParser(false);
355: XMLStoreParser.parseFile(getXMLFileName());
356:
357: DataStore _ds = ls.getDataStore();
358: ResultSetMetaData rsm = parser.getMetaData();
359: Vector vct = rsm.getMetaData();
360: HtmlComponent lastCompAdded = null;
361:
362: page.setUserComponents(new Hashtable());
363:
364: ColumnMetaData cmd = null;
365:
366: String componentType = null;
367: String component = null;
368: String size= null;
369: String maxlength = null;
370: String table = null;
371: String column = null;
372: String caption = null;
373: int type = -1;
374: int flags = -1;
375: String href = null;
376:
377: String fullColName = null;
378: String format = null;
379: String jointo = null;
380:
381: Options values = null;
382: Options params = null;
383: HtmlLink lnk = null;
384: boolean bIsOrderBy=false;
385: StringBuffer sbOrderBy = new StringBuffer();
386:
387: for (int i = 0; i < vct.size(); i++)
388: {
389: lastCompAdded = null;
390: cmd = (ColumnMetaData) vct.elementAt(i);
391:
392: componentType = cmd.getComponentType();
393: component = cmd.getComponent();
394: table = cmd.getTable();
395: column = cmd.getColumnName();
396: maxlength = cmd.getMaxLength();
397: size = cmd.getSize();
398: caption = cmd.getCaption();
399: type = mapDataType(cmd.getColumnType());
400: flags = createListMode(cmd);
401: href = cmd.getHref();
402: jointo = cmd.getJoinTo();
403: bIsOrderBy=cmd.isOrderBy();
404:
405: if (Util.isFilled(href))
406: href += "&" + querystring;
407:
408: format = cmd.getFormat();
409:
410: // create a full column name
411: fullColName = createFulColumnName(table, column);
412:
413: if(bIsOrderBy){
414: sbOrderBy.append(fullColName);
415: sbOrderBy.append(",");
416: }
417:
418: if (!cmd.isBucket() && !cmd.isNotBound())
419: {
420: if (_ds.getColumnIndex(fullColName) < 0)
421: {
422: _ds.addColumn(fullColName, type, cmd.isPrimaryKey(), cmd.isUpdateable());
423: if (Util.isFilled(jointo))
424: {
425: _ds.addJoin(fullColName, jointo, false);
426: }
427: }
428: }
429: if(cmd.isListDisplay() || cmd.isSearchDisplay())
430: {
431: values = cmd.getValues();
432:
433: if (values == null)
434: {
435: /*if(bIsOrderBy){
436: sbOrderBy.append(fullColName);
437: sbOrderBy.append(",");
438: }*/
439: if (componentType != null && componentType.equalsIgnoreCase("HtmlLink"))
440: {
441: lnk = new HtmlLink(fullColName, "", page);
442: if (Util.isFilled(href))
443: {
444: lnk.setHrefExpression(_ds, href);
445: }
446: if (cmd.getImageFile() != null && !cmd.getImageFile().equalsIgnoreCase(""))
447: {
448: lnk.add(new HtmlImage(cmd.getImageFile(), page));
449: }
450:
451: if ((flags & ListForm.LIST_ONLY) == 0)
452: {
453: ls.addSearchDisplay(fullColName, caption, lnk, flags);
454: }
455: else if ((flags & ListForm.SEARCH_ONLY) == 0)
456: {
457: ls.addListDisplay(fullColName, caption, lnk);
458: }
459:
460: lastCompAdded = lnk;
461: }
462: else if (componentType != null && componentType.equalsIgnoreCase("HtmlCheckBox"))
463: {
464: // create active only checkbox
465: HtmlCheckBox _chkBox = new HtmlCheckBox(fullColName, page, "1", "0");
466: _chkBox.setValue("1");
467:
468: if ((flags & ListForm.LIST_ONLY) == 0)
469: {
470: ls.addSearchDisplay(fullColName, caption, _chkBox, flags);
471: }
472: else if ((flags & ListForm.SEARCH_ONLY) == 0)
473: {
474: ls.addListDisplay(fullColName, caption, _chkBox);
475: }
476: lastCompAdded = _chkBox;
477: }
478: else if (componentType != null && componentType.equalsIgnoreCase("HtmlTelephoneComponent"))
479: {
480: // create active only checkbox
481: HtmlTelephoneComponent tc = new HtmlTelephoneComponent(fullColName, page);
482:
483: if ((flags & ListForm.LIST_ONLY) == 0)
484: {
485: ls.addSearchDisplay(fullColName, caption, tc, flags);
486: }
487: else if ((flags & ListForm.SEARCH_ONLY) == 0)
488: {
489: tc.setColumn(_ds, fullColName);
490: tc.setEnabled(false);
491: ls.addListDisplay(fullColName, caption, tc);
492: }
493: lastCompAdded = tc;
494: }
495: else if (componentType != null && componentType.equalsIgnoreCase("HtmlSSNComponent"))
496: {
497: // create active only checkbox
498: HtmlSSNComponent _ssnComp = new HtmlSSNComponent(fullColName, page, "-", true);
499: _ssnComp.setColumn(_ds, column);
500:
501: if ((flags & ListForm.LIST_ONLY) == 0)
502: {
503: ls.addSearchDisplay(fullColName, caption, _ssnComp, flags);
504: }
505: else if ((flags & ListForm.SEARCH_ONLY) == 0)
506: {
507: ls.addListDisplay(fullColName, caption, _ssnComp);
508: }
509: lastCompAdded = _ssnComp;
510: }
511: else if (componentType != null && componentType.equalsIgnoreCase("HtmlTextEdit"))
512: {
513: // create text edit
514: HtmlTextEdit hte = new HtmlTextEdit(fullColName, page);
515: if(maxlength != null)
516: {
517: try{
518: int maxLengthValue = (new Integer(maxlength)).intValue();
519: hte.setMaxLength(maxLengthValue);
520:
521: if(size != null)
522: {
523: int sizeValue = (new Integer(size)).intValue();
524: hte.setSize(sizeValue);
525: }
526: }
527: catch(NumberFormatException e)
528: {
529: // Let it set to default
530: }
531: }
532: params = cmd.getParms();
533: if (params != null)
534: {
535:
536: java.util.Enumeration enum = params.keys();
537: while (enum.hasMoreElements())
538: {
539: String propertyName = enum.nextElement().toString();
540: Object keyval = params.get(propertyName);
541: Util.executeMethod(hte, propertyName, keyval);
542: }
543: }
544:
545: if ((flags & ListForm.LIST_ONLY) == 0)
546: {
547: ls.addSearchDisplay(fullColName, caption, hte, flags);
548: }
549:
550: if (cmd.isDetailDisplay())
551: {
552: if ((flags & ListForm.SEARCH_ONLY) == 0)
553: {
554: HtmlLink hl;
555:
556: HtmlText ht = new HtmlText(table + "_" + column, page);
557: if (format == null)
558: {
559: // For certain data types, set format according to page properties.
560: Props props = page.getPageProperties();
561: switch (type)
562: {
563: case DataStore.DATATYPE_DATETIME :
564: format = props.getProperty(Props.DATETIME_FORMAT);
565: break;
566: case DataStore.DATATYPE_DATE :
567: format = props.getProperty(Props.DATE_FORMAT);
568: break;
569: case DataStore.DATATYPE_TIME :
570: format = props.getProperty(Props.TIME_FORMAT);
571: break;
572: }
573: }
574: if (format != null)
575: {
576: ht.setExpression(_ds, fullColName, format);
577: }
578: else
579: {
580: ht.setExpression(_ds, fullColName);
581: }
582: if (Util.isFilled(href))
583: {
584: hl = new HtmlLink("lnk" + column, "", page);
585: hl.setHrefExpression(_ds, href);
586: hl.add(ht);
587: ht.setFont(HtmlText.FONT_LINK);
588: ls.addListDisplay(fullColName, caption, hl, null);
589: }
590: else
591: {
592: ls.addListDisplay(fullColName, caption, ht, null);
593: }
594: }
595:
596: }
597: else
598: {
599: if ((flags & ListForm.SEARCH_ONLY) == 0)
600: {
601: ls.addListDisplay(fullColName, caption, hte);
602: }
603:
604: }
605: lastCompAdded = hte;
606: }
607: else
608: {
609: if (Util.isFilled(href))
610: {
611: if (cmd.isPrimaryKey())
612: href = "'" + href + "&" + cmd.getColumnName() + "='+" + fullColName;
613: else
614: href = "'" + href + "&" + page.getPrimaryKeyName(_ds) + "='+" + page.getPrimaryKey(_ds);
615: }
616:
617: // add the columns to ListForm
618: ls.addColumn(table, column, caption, type, flags, href, format, null, null, null);
619: }
620: }
621: else
622: {
623: String comp = values.getComponent();
624: String valuesType = values.getType();
625: if (values.getTable() == null)
626: {
627: values.setTable(table);
628: }
629: if (values.getInitColumn() == null)
630: {
631: values.setInitColumn(column);
632: }
633: if (values.getDescColumn() == null)
634: {
635: values.setDescColumn(column);
636: }
637:
638: if (comp != null && comp.equalsIgnoreCase("IntegerDropDown"))
639: {
640: if (valuesType != null && valuesType.equalsIgnoreCase("Static"))
641: lastCompAdded = ls.addIntegerDropDown(table, column, caption, flags, values.getIntKeys(), values.getStringObjects(), values.isMandatory());
642: else
643: {
644: lastCompAdded = ls.addPreInitDropDown(table, column, caption, flags, values.getTable(), values.getInitColumn(), values.getDescColumn());
645: }
646:
647: }
648: else if (comp != null && comp.equalsIgnoreCase("IntegerRadioButtonGroup"))
649: {
650: if (valuesType != null && valuesType.equalsIgnoreCase("Static"))
651: lastCompAdded = ls.addIntegerRadioButtonGroup(table, column, caption, flags, values.getIntKeys(), values.getStringObjects());
652: else
653: lastCompAdded = ls.addPreInitRadioButtonGroup(table, column, caption, flags, values.getTable(), values.getInitColumn(), values.getDescColumn());
654: }
655: else if (comp != null && comp.equalsIgnoreCase("StringRadioButtonGroup"))
656: {
657: if (valuesType != null && valuesType.equalsIgnoreCase("Static"))
658: lastCompAdded = ls.addStringRadioButtonGroup(table, column, caption, flags, values.getStringKeys(), values.getStringObjects());
659: else
660: lastCompAdded = ls.addPreInitStringRadioButtonGroup(table, column, caption, flags, values.getTable(), values.getInitColumn(), values.getDescColumn());
661: }
662: else if (comp != null && comp.equalsIgnoreCase("StringDropDown"))
663: {
664: if (valuesType != null && valuesType.equalsIgnoreCase("Static"))
665: {
666: lastCompAdded = ls.addStringDropDown(table, column, caption, flags, values.getStringKeys(), values.getStringObjects(), values.isMandatory());
667: }
668: else
669: {
670: lastCompAdded = ls.addPreInitStringDropDown(table, column, caption, flags, values.getTable(), values.getInitColumn(), values.getDescColumn());
671: }
672:
673: }
674: }
675: // assign the userComponents
676: if (component != null && lastCompAdded != null)
677: {
678: if (page.getUserComponents() == null)
679: page.setUserComponents(new Hashtable());
680:
681: page.getUserComponents().put(component, lastCompAdded);
682: }
683:
684: } // Not a Bucket
685: else
686: {
687: // Bucket
688: ls.addBucket(column, caption, type, flags, href, format, null, null, null);
689: if(bIsOrderBy){
690: sbOrderBy.append(column);
691: sbOrderBy.append(",");
692: }
693: }
694: } // if check for if the display for search and list is set to true
695:
696: if(sbOrderBy!=null && sbOrderBy.length()>0){
697: // srufle 03-19-2003 int idx = sbOrderBy.lastIndexOf(","); // this is jdk1.4 specific
698: int idx = 0;
699: if(idx>0){
700: _ds.setOrderBy(sbOrderBy.substring(0, idx));
701: }
702: }
703:
704: }
705: catch (java.io.UnsupportedEncodingException e)
706: {
707: MessageLog.writeErrorMessage("bindListForm", e, this );
708: }
709: catch (java.lang.Exception e)
710: {
711: MessageLog.writeErrorMessage("bindListForm", e, this );
712: }
713:
714: return ls;
715: }
716:
717: /**
718: * Creation date: (7/25/01 10:57:57 AM)
719: * @return int
720: * @param cmd com.salmonllc.xml.ColumnMetaData
721: */
722: private int createDetailMode(ColumnMetaData cmd) {
723:
724: int mode = 0;
725:
726: if (cmd.isPrimaryKey())
727: mode |= DetailForm.PRIMARY_KEY;
728:
729: if (cmd.isMandatory())
730: mode |= DetailForm.IS_REQUIRED;
731:
732: if (cmd.isSameRow())
733: mode |= DetailForm.SAME_ROW;
734:
735: if (cmd.isBucket())
736: mode |= DetailForm.BUCKET;
737:
738: if (cmd.isReadOnly())
739: mode |= DetailForm.READ_ONLY;
740:
741: if (cmd.isNotBound())
742: mode |= DetailForm.NO_DATASTORE;
743:
744: return mode;
745: }
746:
747: /**
748: * Creation date: (7/20/01 4:32:35 PM)
749: * @return java.lang.String
750: */
751: private java.lang.String createFulColumnName(String table,
752: String column) {
753: boolean tablefilled = false;
754:
755: String ret = "";
756: if (Util.isFilled(table)) {
757: tablefilled = true;
758: ret += table;
759: }
760: if (Util.isFilled(column) && tablefilled) {
761: ret += "." + column;
762: } else {
763: ret = column;
764: }
765: return ret;
766: }
767:
768: /**
769: * Creation date: (7/25/01 10:57:57 AM)
770: * @return int
771: * @param cmd com.salmonllc.xml.ColumnMetaData
772: */
773: private int createListMode(ColumnMetaData cmd) {
774:
775: int mode = 0;
776:
777: if (cmd.isSearchDisplay() && !cmd.isListDisplay())
778: mode = ListForm.SEARCH_ONLY;
779:
780: if (cmd.isListDisplay() && !cmd.isSearchDisplay())
781: mode = ListForm.LIST_ONLY;
782:
783: if (!cmd.isSearchDisplay() && !cmd.isListDisplay()) {
784: mode |= ListForm.SEARCH_ONLY;
785: mode |= ListForm.LIST_ONLY;
786: }
787:
788: if (cmd.isPrimaryKey())
789: mode |= ListForm.PRIMARY_KEY;
790:
791: if (cmd.isPrecedence())
792: mode |= ListForm.PRECEDENCE;
793:
794: if (cmd.isExactMatch())
795: mode |= ListForm.EXACT_MATCH;
796:
797: if (!cmd.isCaseSensitive())
798: mode |= ListForm.IGNORE_CASE;
799:
800: if (cmd.isAdvanceSearch())
801: mode |= ListForm.ADVANCED_SEARCH;
802:
803: if (cmd.isExactMatch())
804: mode |= ListForm.EXACT_MATCH;
805:
806: if (cmd.isLeadingWildCard())
807: mode |= ListForm.LEADING_WILDCARD;
808:
809: if (cmd.isSameRow())
810: mode |= ListForm.SAME_ROW;
811:
812: return mode;
813: }
814:
815: /**
816: * Creation date: (7/20/01 4:32:35 PM)
817: * @return java.lang.String
818: */
819: private java.lang.String getXMLFileName() {
820: return fieldXMLFileName;
821: }
822:
823: }
|