0001: //** Copyright Statement ***************************************************
0002: //The Salmon Open Framework for Internet Applications (SOFIA)
0003: // Copyright (C) 1999 - 2002, Salmon LLC
0004: //
0005: // This program is free software; you can redistribute it and/or
0006: // modify it under the terms of the GNU General Public License version 2
0007: // as published by the Free Software Foundation;
0008: //
0009: // This program is distributed in the hope that it will be useful,
0010: // but WITHOUT ANY WARRANTY; without even the implied warranty of
0011: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0012: // GNU General Public License for more details.
0013: //
0014: // You should have received a copy of the GNU General Public License
0015: // along with this program; if not, write to the Free Software
0016: // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
0017: //
0018: // For more information please visit http://www.salmonllc.com
0019: //** End Copyright Statement ***************************************************
0020: package com.salmonllc.html;
0021:
0022: /////////////////////////
0023: //$Archive: /SOFIA/SourceCode/com/salmonllc/html/HtmlDataTable.java $
0024: //$Author: Dan $
0025: //$Revision: 88 $
0026: //$Modtime: 11/05/04 9:05a $
0027: /////////////////////////
0028:
0029: import java.awt.*;
0030: import java.io.*;
0031: import java.lang.reflect.Method;
0032: import java.util.*;
0033:
0034: import com.salmonllc.forms.BaseListForm;
0035: import com.salmonllc.jsp.JspDataTable;
0036: import com.salmonllc.jsp.JspForm;
0037: import com.salmonllc.properties.Props;
0038: import com.salmonllc.sql.*;
0039: import com.salmonllc.util.*;
0040:
0041: /**
0042: * This component will generate an HTML table. It serves as a container and
0043: * layout manager for other components. There are several bands of components in
0044: * the page. Heading Components are displayed at the top of the table and occur
0045: * only once. Row Components are displayed below the heading components and are
0046: * repeated for each row in the DataStoreBuffer. Footer Components are displayed
0047: * at the end of the table. Control Break Header and Footer components are
0048: * displayed before and after a set of control break columns change.
0049: */
0050:
0051: public class HtmlDataTable extends HtmlContainer implements
0052: ImageGenerator {
0053: public static final int PAGE_BUTTON_TYPE_SUBMIT = 0;
0054: public static final int PAGE_BUTTON_TYPE_IMAGE = 1;
0055: public static final int PAGE_BUTTON_TYPE_TEXT = 2;
0056: public static final int PAGE_BUTTON_TYPE_SCROLLBAR = 3;
0057:
0058: public static final int SIZE_PERCENT = 0;
0059: public static final int SIZE_PIXELS = 1;
0060: public static final String ALIGN_LEFT = "LEFT";
0061: public static final String ALIGN_CENTER = "CENTER";
0062: public static final String ALIGN_RIGHT = "RIGHT";
0063: public static final String ALIGN_NONE = "";
0064: public static final String VALIGN_BASELINE = "BASELINE";
0065: public static final String VALIGN_BOTTOM = "BOTTOM";
0066: public static final String VALIGN_MIDDLE = "MIDDLE";
0067: public static final String VALIGN_TOP = "TOP";
0068: public static final String VALIGN_NONE = "";
0069: public static final int MAX_ROW_LIMIT = 999999;
0070: //
0071:
0072: private int _tableHeight = -1;
0073: private Vector _headingComponents = new Vector();
0074: private Vector _rowComponents = new Vector();
0075: private Vector _footerComponents = new Vector();
0076: private Vector _controlBreakFooterComponents = new Vector();
0077: private Vector _controlBreakHeadingComponents = new Vector();
0078:
0079: protected int _sizeOption = SIZE_PERCENT;
0080: protected int _containerWidth = 100;
0081: protected Vector _columnWidth = new Vector();
0082:
0083: protected String _align;
0084: protected int _border = -1;
0085: protected String _bgColor = "";
0086: protected int _cellPadding = -1;
0087: protected int _cellSpacing = -1;
0088: protected DataStoreBuffer _ds;
0089: protected String _defaultHeadingBackground;
0090: protected String _defaultRowBackground1;
0091: protected String _defaultRowBackground2;
0092: protected int _rowsPerPage = 10;
0093: protected int _firstRowOnPage = 0;
0094: protected int _maxPageButtons = 10;
0095: protected int _firstSubmitButton = 0;
0096: protected int _newStartRow = -1;
0097: protected int _newFirstButton = -1;
0098: protected boolean _scroll = false;
0099: protected boolean _clickSort = true;
0100: protected int _clickSortColumn = -1;
0101: protected int _sortColumn = -1;
0102: protected int _sortDir = DataStore.SORT_DES;
0103: protected int _breakColumns[];
0104: protected HtmlComponent _contMessage;
0105: protected Vector _propertyExpressions;
0106: protected String _theme = null;
0107: protected boolean _rowPerPageSel = true;
0108: protected int _newRowsPerPage = -1;
0109: protected int _baseSortColumn = -1;
0110: protected int _baseSortDir;
0111: protected boolean _didSubmit = false;
0112: protected boolean _scrollOnSort = true;
0113:
0114: public static final String PAGE_BUTTON_STYLE_RECTANGLE = "RECTANGLE";
0115: public static final String PAGE_BUTTON_STYLE_OVAL = "OVAL";
0116:
0117: protected boolean _useCache = true;
0118: protected long _cacheKey = 0;
0119: protected Font _buttonFont;
0120: private String _fontString;
0121: private int _fontSize;
0122: protected Color _textColor = Color.black;
0123: protected Color _backgroundColor = Color.lightGray;
0124: protected Color _topLeftBorder = Color.white;
0125: protected Color _bottomRightBorder = Color.gray;
0126: protected Color _transparentColor = Color.magenta;
0127: protected int _height;
0128: protected String _style = PAGE_BUTTON_STYLE_RECTANGLE;
0129: protected int _pageButtonType = PAGE_BUTTON_TYPE_SUBMIT;
0130: // protected boolean _genImagesForPageButtons = false;
0131: // protected boolean _linkForPageButtons = false;
0132: protected String _imageURL;
0133:
0134: protected String _summaryRowText = null;
0135: protected boolean _displayRowComponents = true;
0136: protected String _scrollAnchor;
0137: // used in addDisplay
0138: private int _colListVal = 0;
0139: // Used in addColumn
0140: private String _linkFont = HtmlText.FONT_LINK;
0141: private Hashtable _compLookUpHash = new Hashtable();
0142: private final static String HEADING_COMP_HASH_KEY = "Heading_comp_";
0143: private final static String ROW_COMP_HASH_KEY = "Row_comp_";
0144:
0145: private boolean _bAddPageBreak = false;
0146: private HtmlStyle _pageBreak;
0147: private int _iPageBreakIndex = 4;
0148:
0149: private boolean _repeatHeadingsAfterBreak = false;
0150: protected DataTablePageSelectRenderer _pageSelectRenderer;
0151: protected DataTableRowsPerPageRenderer _rowsPerPageRenderer;
0152:
0153: private String _defaultRowStyleClassName1;
0154: private String _defaultRowStyleClassName2;
0155: private String _defaultHeadingStyleClassName;
0156: private boolean _genTHeadAndBody = true;
0157: private HtmlRowHighlighter _rowHighlighter;
0158:
0159: /**
0160: * Constructs a new HTMLDataTable.
0161: *
0162: * @param name
0163: * Each component on a page must have a unique name.
0164: * @param d
0165: * The DataStoreBuffer to get the data from.
0166: * @param p
0167: * The page that the table will be added to.
0168: */
0169: public HtmlDataTable(String name, DataStoreBuffer d, HtmlPage p) {
0170: this (name, d, null, p);
0171: }
0172:
0173: /**
0174: * Constructs a new HTMLDataTable.
0175: *
0176: * @param name
0177: * Each component on a page must have a unique name.
0178: * @param d
0179: * The DataStoreBuffer to get the data from.
0180: * @param theme
0181: * The theme to use for loading properties.
0182: * @param p
0183: * The page that the table will be added to.
0184: */
0185: public HtmlDataTable(String name, DataStoreBuffer d, String theme,
0186: HtmlPage p) {
0187: super (name, p);
0188:
0189: setTheme(theme);
0190:
0191: _ds = d;
0192: _imageURL = generateImageURL();
0193: }
0194:
0195: /**
0196: * This method should not be used in this type of container. Instead use
0197: * setComponentAt().
0198: */
0199: public void add(HtmlComponent comp) {
0200: return;
0201: }
0202:
0203: /**
0204: * Creates a datastore bucket and corresponding display components for the
0205: * search and list boxes.
0206: *
0207: * @param name
0208: * Name of bucket
0209: * @param heading
0210: * heading for search box and/or list box, or null
0211: * @param type
0212: * Type of datastore column, using DataStore.DATATYPE_* values
0213: */
0214: public void addBucket(String name, String heading, int type)
0215: throws Exception {
0216: addBucket(name, heading, type, null, null);
0217: }
0218:
0219: /**
0220: * Creates a datastore bucket and corresponding display components for the
0221: * search and list boxes.
0222: *
0223: * @param name
0224: * Name of bucket
0225: * @param heading
0226: * heading for search box and/or list box, or null
0227: * @param type
0228: * Type of datastore column, using DataStore.DATATYPE_* values
0229: * @param href
0230: * HREF to use in hotlink from this column in list box, else
0231: * null.
0232: * @param format
0233: * Format used to display column in listbox (as in DataStore),
0234: * else null.
0235: */
0236: public void addBucket(String name, String heading, int type,
0237: String href, String format) throws Exception {
0238: addBucket(name, heading, type, href, format, null);
0239: }
0240:
0241: /**
0242: * Creates a datastore bucket and corresponding display components for the
0243: * search and list boxes.
0244: *
0245: * @param name
0246: * Name of bucket
0247: * @param heading
0248: * heading for search box and/or list box, or null
0249: * @param type
0250: * Type of datastore column, using DataStore.DATATYPE_* values
0251: * @param href
0252: * HREF to use in hotlink from this column in list box, else
0253: * null.
0254: * @param format
0255: * Format used to display column in listbox (as in DataStore),
0256: * else null.
0257: * @param propList
0258: * HtmlTableCellProperties
0259: */
0260: public void addBucket(String name, String heading, int type,
0261: String href, String format, HtmlTableCellProperties propList)
0262: throws Exception {
0263:
0264: DataStore dsTemp = null;
0265: if (_ds instanceof DataStore) {
0266: dsTemp = (DataStore) _ds;
0267: } else {
0268: throw new Exception(
0269: "Can not use this method.Not using a DataStore. ");
0270: }
0271:
0272: // Don't add the same column twice to the data store.
0273: if (dsTemp.getColumnIndex(name) == -1) {
0274: dsTemp.addBucket(name, type);
0275: }
0276:
0277: HtmlLink hl;
0278: HtmlPage page = getPage();
0279: HtmlText ht = new HtmlText("", page);
0280: if (format == null) {
0281: // For certain data types, set format according to page properties.
0282: Props props = getPage().getPageProperties();
0283: switch (type) {
0284: case DataStore.DATATYPE_DATETIME:
0285: format = props.getProperty(Props.DATETIME_FORMAT);
0286: break;
0287: case DataStore.DATATYPE_DATE:
0288: format = props.getProperty(Props.DATE_FORMAT);
0289: break;
0290: case DataStore.DATATYPE_TIME:
0291: format = props.getProperty(Props.TIME_FORMAT);
0292: break;
0293: }
0294: }
0295:
0296: if (format != null) {
0297: ht.setExpression(_ds, name, format);
0298: } else {
0299: ht.setExpression(_ds, name);
0300: }
0301:
0302: if (Util.isFilled(href)) {
0303: hl = new HtmlLink("lnk" + name, "", page);
0304: hl.setHrefExpression(_ds, href);
0305: hl.add(ht);
0306: ht.setFont(_linkFont);
0307: addDisplay(name, heading, hl, propList);
0308: } else {
0309: addDisplay(name, heading, ht, propList);
0310: }
0311:
0312: }
0313:
0314: /**
0315: * Creates a datastore column and corresponding display components for the
0316: * search and list boxes.
0317: *
0318: * @param table
0319: * Name of table for datastore
0320: * @param column
0321: * Name of column for datastore
0322: * @param heading
0323: * heading for search box and/or list box, or null
0324: * @param type
0325: * Type of datastore column, using DataStore.DATATYPE_* values
0326: */
0327: public void addColumn(String table, String column, String heading,
0328: int type) throws Exception {
0329: addColumn(table, column, heading, type, null);
0330: }
0331:
0332: /**
0333: * Creates a datastore column and corresponding display components for the
0334: * search and list boxes.
0335: *
0336: * @param table
0337: * Name of table for datastore
0338: * @param column
0339: * Name of column for datastore
0340: * @param heading
0341: * heading for search box and/or list box, or null
0342: * @param type
0343: * Type of datastore column, using DataStore.DATATYPE_* values
0344: * @param href
0345: * HREF to use in hotlink from this column in list box, else
0346: * null.
0347: */
0348: public void addColumn(String table, String column, String heading,
0349: int type, String href) throws Exception {
0350: addColumn(table, column, heading, type, href, null);
0351: }
0352:
0353: /**
0354: * Creates a datastore column and corresponding display components for the
0355: * search and list boxes.
0356: *
0357: * @param table
0358: * Name of table for datastore
0359: * @param column
0360: * Name of column for datastore
0361: * @param heading
0362: * heading for search box and/or list box, or null
0363: * @param type
0364: * Type of datastore column, using DataStore.DATATYPE_* values
0365: * @param href
0366: * HREF to use in hotlink from this column in list box, else
0367: * null.
0368: * @param format
0369: * Format used to display column in listbox (as in DataStore),
0370: * else null.
0371: */
0372: public void addColumn(String table, String column, String heading,
0373: int type, String href, String format) throws Exception {
0374: addColumn(table, column, heading, type, href, format, null);
0375: }
0376:
0377: /**
0378: * Creates a datastore column and corresponding display components for the
0379: * search and list boxes.
0380: *
0381: * @param table
0382: * Name of table for datastore. If table == null then table will
0383: * be forced to "NULL_TABLE"
0384: * @param column
0385: * Name of column for datastore
0386: * @param heading
0387: * heading for search box and/or list box, or null
0388: * @param type
0389: * Type of datastore column, using DataStore.DATATYPE_* values
0390: * @param href
0391: * HREF to use in hotlink from this column in list box, else
0392: * null.
0393: * @param format
0394: * Format used to display column in listbox (as in DataStore),
0395: * else null.
0396: * @param propList
0397: * HtmlTableCellProperties
0398: */
0399: public void addColumn(String table, String column, String heading,
0400: int type, String href, String format,
0401: HtmlTableCellProperties propList) throws Exception {
0402: addColumn(table, column, heading, type, href, format, propList,
0403: propList);
0404: }
0405:
0406: /**
0407: * Creates a datastore column and corresponding display components for the
0408: * search and list boxes.
0409: *
0410: * @param table
0411: * Name of table for datastore. If table == null then table will
0412: * be forced to "NULL_TABLE"
0413: * @param column
0414: * Name of column for datastore
0415: * @param heading
0416: * heading for search box and/or list box, or null
0417: * @param type
0418: * Type of datastore column, using DataStore.DATATYPE_* values
0419: * @param href
0420: * HREF to use in hotlink from this column in list box, else
0421: * null.
0422: * @param format
0423: * Format used to display column in listbox (as in DataStore),
0424: * else null.
0425: * @param propHeading
0426: * HtmlTableCellProperties
0427: * @param propList
0428: * HtmlTableCellProperties
0429: */
0430: public void addColumn(String table, String column, String heading,
0431: int type, String href, String format,
0432: HtmlTableCellProperties propHeading,
0433: HtmlTableCellProperties propList) throws Exception {
0434:
0435: // If table == null then table will be forced to "NULL_TABLE"
0436: if (table == null) {
0437: table = BaseListForm.NULL_TABLE;
0438: }
0439: String fullColName = table + "." + column;
0440:
0441: DataStore dsTemp = null;
0442: if (_ds instanceof DataStore) {
0443: dsTemp = (DataStore) _ds;
0444: } else {
0445: throw new Exception(
0446: "Can not use this method.Not using a DataStore. ");
0447: }
0448:
0449: // Don't add the same column twice to the data store.
0450: if (dsTemp.getColumnIndex(table + "." + column) == -1) {
0451: dsTemp.addColumn(table, column, type, false, false);
0452: }
0453:
0454: HtmlLink hl;
0455: HtmlPage page = getPage();
0456: HtmlText ht = new HtmlText(table + "_" + column, page);
0457: if (format == null) {
0458: // For certain data types, set format according to page properties.
0459: Props props = getPage().getPageProperties();
0460: switch (type) {
0461: case DataStore.DATATYPE_DATETIME:
0462: format = props.getProperty(Props.DATETIME_FORMAT);
0463: break;
0464: case DataStore.DATATYPE_DATE:
0465: format = props.getProperty(Props.DATE_FORMAT);
0466: break;
0467: case DataStore.DATATYPE_TIME:
0468: format = props.getProperty(Props.TIME_FORMAT);
0469: break;
0470: }
0471: }
0472: if (format != null) {
0473: ht.setExpression(dsTemp, fullColName, format);
0474: } else {
0475: ht.setExpression(dsTemp, fullColName);
0476: }
0477:
0478: // if an href is given make the component a link
0479: if (Util.isFilled(href)) {
0480: hl = new HtmlLink("lnk" + column, "", page);
0481: hl.setHrefExpression(dsTemp, href);
0482: hl.add(ht);
0483: ht.setFont(_linkFont);
0484: addDisplay(fullColName, heading, hl, propHeading, propList);
0485: } else {
0486: addDisplay(fullColName, heading, ht, propHeading, propList);
0487: }
0488:
0489: }
0490:
0491: /**
0492: * Adds a component to the List display.
0493: *
0494: * @param fullColName
0495: * Datastore column name in form table.column
0496: * @param heading
0497: * DataTable Heading, or null
0498: * @param component
0499: * HtmlComponent The component to add
0500: * @param prop
0501: * HtmlTableCellProperties Table cell properties
0502: */
0503: public void addDisplay(String fullColName, String heading,
0504: HtmlComponent component, HtmlTableCellProperties prop)
0505: throws Exception {
0506: addDisplay(fullColName, heading, component, prop, prop);
0507: }
0508:
0509: /**
0510: * Adds a component to the List display.
0511: *
0512: * @param fullColName
0513: * Datastore column name in form table.column
0514: * @param heading
0515: * DataTable Heading, or null
0516: * @param component
0517: * HtmlComponent The component to add
0518: * @param propHeading
0519: * HtmlTableCellProperties the table-cell properties for the
0520: * column heading
0521: * @param propComponent
0522: * HtmlTableCellProperties the table-cell properties for the list
0523: * data
0524: */
0525: public void addDisplay(String fullColName, String heading,
0526: HtmlComponent component,
0527: HtmlTableCellProperties propHeading,
0528: HtmlTableCellProperties propComponent) throws Exception {
0529:
0530: // Add heading comp to HashTable with key Heading_comp+fullColName
0531: HtmlText headComp = null;
0532: if (heading != null) {
0533: headComp = new HtmlText(heading,
0534: HtmlText.FONT_TABLE_HEADING, getPage());
0535: setHeadingComponentAt(_colListVal, headComp, propHeading);
0536: _compLookUpHash.put(HEADING_COMP_HASH_KEY + fullColName,
0537: headComp);
0538: }
0539:
0540: if (propComponent != null) {
0541: setRowComponentAt(_colListVal++, component, propComponent);
0542:
0543: } else {
0544: setRowComponentAt(_colListVal++, component);
0545: }
0546: // Add row comp to HashTable with key Row_comp+fullColName
0547: // then later the get by name routine can just use the name value pair
0548: _compLookUpHash.put(ROW_COMP_HASH_KEY + fullColName, component);
0549:
0550: }
0551:
0552: /**
0553: * This method will add a property expression to the HtmlDataTable. The
0554: * property expression will automatically set a property value on the
0555: * specified component with the results of the passed expression as each row
0556: * in the table is processed. This can be used for example to make a
0557: * component invisible or visible depending on the value in the datastore
0558: * for a particular row: ex:
0559: * addPropertyExpression(comp,"visible","bucket==1") will call the
0560: * setVisible method on the component comp passing the results of the
0561: * expression.
0562: *
0563: * @param comp
0564: * The component to set the property for
0565: * @param propertyName
0566: * The name of the property to set. The component must have a
0567: * corresponding setProperty method or this method will throw a
0568: * NoSuchMethodException
0569: * @param expEval
0570: * DataStoreEvaluator The datastore evaluator that evaluates the
0571: * expression
0572: * @exception java.lang.NoSuchMethodException
0573: * The exception description.
0574: * @exception com.salmonllc.sql.DataStoreException
0575: * The exception description.
0576: */
0577: public void addPropertyExpression(Object comp, String propertyName,
0578: DataStoreEvaluator expEval) throws NoSuchMethodException,
0579: DataStoreException {
0580: Class c = comp.getClass();
0581: Method m[] = c.getMethods();
0582: Method exe = null;
0583: String name = "set" + propertyName;
0584: Class parms[] = null;
0585: for (int i = 0; i < m.length; i++) {
0586: if (name.equalsIgnoreCase(m[i].getName())) {
0587: parms = m[i].getParameterTypes();
0588: if (parms.length == 1) {
0589: exe = m[i];
0590: break;
0591: }
0592: }
0593: }
0594: if (exe == null)
0595: throw new NoSuchMethodException(
0596: "Couldn't find a set method for property:"
0597: + propertyName);
0598: ThreeObjectContainer t = new ThreeObjectContainer(comp, exe,
0599: expEval);
0600: if (_propertyExpressions == null)
0601: _propertyExpressions = new Vector();
0602: _propertyExpressions.addElement(t);
0603: }
0604:
0605: /**
0606: * This method will add a property expression to the HtmlDataTable. The
0607: * property expression will automatically set a property value on the
0608: * specified component with the results of the passed expression as each row
0609: * in the table is processed. This can be used for example to make a
0610: * component invisible or visible depending on the value in the datastore
0611: * for a particular row: ex:
0612: * addPropertyExpression(comp,"visible","bucket==1") will call the
0613: * setVisible method on the component comp passing the results of the
0614: * expression.
0615: *
0616: * @param comp
0617: * The component to set the property for
0618: * @param propertyName
0619: * The name of the property to set. The component must have a
0620: * corresponding setProperty method or this method will throw a
0621: * NoSuchMethodException
0622: * @param propExpression
0623: * com.salmonllc.html.PropertyExpression The instance of
0624: * PropertyExpression that should do the evaluating.
0625: * @exception java.lang.NoSuchMethodException
0626: * The exception description.
0627: * @exception com.salmonllc.sql.DataStoreException
0628: * The exception description.
0629: */
0630: public void addPropertyExpression(Object comp, String propertyName,
0631: DataStoreExpression propExpression)
0632: throws NoSuchMethodException, DataStoreException {
0633: DataStoreEvaluator dse = new DataStoreEvaluator(_ds,
0634: propExpression);
0635: addPropertyExpression(comp, propertyName, dse);
0636: }
0637:
0638: /**
0639: * This method will add a property expression to the HtmlDataTable. The
0640: * property expression will automatically set a property value on the
0641: * specified component with the results of the passed expression as each row
0642: * in the table is processed. This can be used for example to make a
0643: * component invisible or visible depending on the value in the datastore
0644: * for a particular row: ex:
0645: * addPropertyExpression(comp,"visible","bucket==1") will call the
0646: * setVisible method on the component comp passing the results of the
0647: * expression.
0648: *
0649: * @param comp
0650: * The component to set the property for
0651: * @param propertyName
0652: * The name of the property to set. The component must have a
0653: * corresponding setProperty method or this method will throw a
0654: * NoSuchMethodException
0655: * @param expression
0656: * java.lang.String The datastore expression to evaluate
0657: * @exception java.lang.NoSuchMethodException
0658: * The exception description.
0659: * @exception com.salmonllc.sql.DataStoreException
0660: * The exception description.
0661: */
0662: public void addPropertyExpression(Object comp, String propertyName,
0663: String expression) throws NoSuchMethodException,
0664: DataStoreException {
0665: DataStoreEvaluator dse = new DataStoreEvaluator(_ds, expression);
0666: addPropertyExpression(comp, propertyName, dse);
0667: }
0668:
0669: /**
0670: * This method will remove all property expressions from the table.
0671: */
0672: public void clearPropertyExpressions() {
0673: if (_propertyExpressions != null)
0674: _propertyExpressions.setSize(0);
0675: }
0676:
0677: public boolean executeEvent(int eventType) throws Exception {
0678: TwoObjectContainer t = null;
0679: //
0680: if (eventType == HtmlComponent.EVENT_OTHER) {
0681: HtmlComponent h = null;
0682: int headingComponentsSize = _headingComponents.size();
0683: for (int i = 0; i < headingComponentsSize; i++) {
0684: t = (TwoObjectContainer) _headingComponents
0685: .elementAt(i);
0686: if (t != null) {
0687: h = (HtmlComponent) t.getObject1();
0688: if (h != null)
0689: if (!h.executeEvent(eventType))
0690: return false;
0691: }
0692: }
0693: int rowComponentsSize = _rowComponents.size();
0694: for (int i = 0; i < rowComponentsSize; i++) {
0695: t = (TwoObjectContainer) _rowComponents.elementAt(i);
0696: if (t != null) {
0697: h = (HtmlComponent) t.getObject1();
0698: if (h != null)
0699: if (!h.executeEvent(eventType))
0700: return false;
0701: }
0702: }
0703: int footerComponentsSize = _footerComponents.size();
0704: for (int i = 0; i < footerComponentsSize; i++) {
0705: t = (TwoObjectContainer) _footerComponents.elementAt(i);
0706: if (t != null) {
0707: h = (HtmlComponent) t.getObject1();
0708: if (h != null)
0709: if (!h.executeEvent(eventType))
0710: return false;
0711: }
0712: }
0713: } else if (_submit != null
0714: && eventType == HtmlComponent.EVENT_SUBMIT) {
0715: boolean retVal = true;
0716: if (_submit == this ) {
0717: if (_newRowsPerPage > -1) {
0718: _rowsPerPage = _newRowsPerPage;
0719: _firstSubmitButton = 0;
0720: setFirstRowOnPage(0);
0721: _newRowsPerPage = -1;
0722: }
0723: if (_newStartRow > -1)
0724: setFirstRowOnPage(_newStartRow);
0725: if (_newFirstButton > -1)
0726: _firstSubmitButton = _newFirstButton;
0727: if (_clickSortColumn > -1) {
0728: t = (TwoObjectContainer) _rowComponents
0729: .elementAt(_clickSortColumn);
0730: HtmlComponent sortComp = findSortComponent((HtmlComponent) t
0731: .getObject1());
0732: if (sortComp != null)
0733: sortOnComponent(sortComp, _clickSortColumn);
0734: }
0735: if (_scroll) {
0736: if (_scrollAnchor != null)
0737: getPage().scrollToItem(_scrollAnchor);
0738: else {
0739: boolean didScroll = false;
0740: JspForm form = JspForm.findParentForm(this );
0741: if (form != null) {
0742: if (form.isScrollPositionSet()) {
0743: form.scrollToLastPosition();
0744: didScroll = true;
0745: }
0746: }
0747: if (!didScroll)
0748: getPage().scrollToItem(
0749: getFullName() + "TableStart");
0750: }
0751: _scroll = false;
0752: }
0753: } else
0754: retVal = _submit.executeEvent(eventType);
0755: _submit = null;
0756: return retVal;
0757: }
0758: return true;
0759: }
0760:
0761: protected HtmlComponent findSortComponent(HtmlComponent sortComp) {
0762: if (sortComp instanceof HtmlFormComponent) {
0763: if (((HtmlFormComponent) sortComp).getColumnNumber() != -1)
0764: return sortComp;
0765: } else if (sortComp instanceof HtmlText) {
0766: if (((HtmlText) sortComp).getExpressionEvaluator() != null)
0767: return sortComp;
0768: } else if (sortComp instanceof HtmlContainer) {
0769: Enumeration e = ((HtmlContainer) sortComp).getComponents();
0770: while (e.hasMoreElements()) {
0771: sortComp = (HtmlComponent) e.nextElement();
0772: return findSortComponent(sortComp);
0773: }
0774: }
0775: return null;
0776: }
0777:
0778: public void generateHTML(java.io.PrintWriter p, int rowNo)
0779: throws Exception {
0780:
0781: if (_pageBreak != null)
0782: _pageBreak.generateHTML(p, rowNo);
0783:
0784: if (!getVisible()) {
0785: _didSubmit = false;
0786: return;
0787: }
0788:
0789: if (_rowHighlighter != null) {
0790: HtmlScriptGenerator gen = new HtmlScriptGenerator(getPage());
0791: gen.generateSelectRowScript();
0792: _rowHighlighter.resetForGenerate();
0793: }
0794:
0795: int rowsPerPage = _rowsPerPage;
0796: boolean rowPerPageSel = _rowPerPageSel;
0797: if (getParent() instanceof HtmlInlineFrame
0798: && getPage().getUseIFrames()
0799: || (_pageButtonType == PAGE_BUTTON_TYPE_SCROLLBAR)) {
0800: rowsPerPage = 100000;
0801: rowPerPageSel = false;
0802: }
0803: _newStartRow = -1;
0804:
0805: // Start Table
0806: generateHtmlTableStart(p);
0807: // SR 10-15-2000
0808: int headingComponentsSize = _headingComponents.size();
0809: int rowComponentsSize = _rowComponents.size();
0810: int footerComponentsSize = _footerComponents.size();
0811: // LT/FC 11/22/00: maxComponentsSize represents true number of columns;
0812: // needed for COLSPAN at end of table
0813: int maxComponentsSize = Math.max(Math.max(
0814: headingComponentsSize, rowComponentsSize),
0815: footerComponentsSize);
0816:
0817: //
0818: int maxSize = headingComponentsSize;
0819: //
0820: if (rowComponentsSize > maxSize)
0821: maxSize = rowComponentsSize;
0822: if (footerComponentsSize > maxSize)
0823: maxSize = footerComponentsSize;
0824:
0825: if (headingComponentsSize > 0) {
0826: if (_genTHeadAndBody)
0827: p.println("<THEAD id=\"" + getFullName() + "-thead\">");
0828: generateHtmlForBand(_headingComponents, p,
0829: _defaultHeadingBackground,
0830: _defaultHeadingStyleClassName, maxSize, _clickSort,
0831: "TD");
0832: if (_genTHeadAndBody)
0833: p.println("</THEAD>");
0834: }
0835:
0836: //get the data
0837: _ds.waitForRetrieve();
0838: int rowCount = _ds.getRowCount();
0839: if (_firstRowOnPage >= rowCount) {
0840: _firstRowOnPage = 0;
0841: _firstSubmitButton = 0;
0842: }
0843:
0844: //find the first row for control breaks (if used)
0845: int lastBreak = -1;
0846: if (_breakColumns != null) {
0847: lastBreak = 0;
0848: if (_firstRowOnPage != 0) {
0849: lastBreak = 0;
0850: for (int i = _firstRowOnPage; i >= 0; i--) {
0851: if (_ds.compareRows(_firstRowOnPage, i,
0852: _breakColumns) != 0) {
0853: lastBreak = i + 1;
0854: break;
0855: }
0856: }
0857: }
0858: }
0859:
0860: //do the row components
0861: String backgroundColor = _defaultRowBackground2;
0862: String rowStyle = _defaultRowStyleClassName2;
0863:
0864: if (_genTHeadAndBody) {
0865: if ((getPageButtonType() == JspDataTable.PAGE_BUTTON_TYPE_SCROLLBAR)
0866: && !(getPage().getBrowserType() == HtmlPage.BROWSER_MICROSOFT))
0867: p.println("<TBODY id=\"" + getFullName()
0868: + "-tbody\" style=\"max-height:"
0869: + getTableHeight() + "px;overflow: scroll\">");
0870: else
0871: p.println("<TBODY>");
0872: }
0873: for (int rowIndex = _firstRowOnPage; (rowIndex < rowCount)
0874: && (rowIndex < (_firstRowOnPage + rowsPerPage)); rowIndex++) {
0875: if (_displayRowComponents) {
0876: backgroundColor = getBackgroundColor(backgroundColor);
0877: rowStyle = getStyle(rowStyle);
0878: }
0879: //check for control breaks
0880: if (_breakColumns != null) {
0881: if (_contMessage != null) {
0882: _contMessage.setVisible(false);
0883: }
0884:
0885: if (rowIndex == _firstRowOnPage) {
0886: if (_controlBreakHeadingComponents.size() > 0) {
0887: if (_contMessage != null
0888: && lastBreak != _firstRowOnPage) {
0889: _contMessage.setVisible(true);
0890: }
0891:
0892: generateHtmlForBand(
0893: _controlBreakHeadingComponents, p,
0894: backgroundColor, rowStyle, maxSize,
0895: false, lastBreak, lastBreak, "TD");
0896: backgroundColor = getBackgroundColor(backgroundColor);
0897: rowStyle = getStyle(rowStyle);
0898: }
0899: } else {
0900: if (_ds.compareRows(lastBreak, rowIndex,
0901: _breakColumns) != 0) {
0902: if (_controlBreakFooterComponents.size() > 0) {
0903: generateHtmlForBand(
0904: _controlBreakFooterComponents, p,
0905: backgroundColor, rowStyle, maxSize,
0906: false, lastBreak, rowIndex - 1,
0907: "TD");
0908: backgroundColor = getBackgroundColor(backgroundColor);
0909: rowStyle = getStyle(rowStyle);
0910: }
0911: if (_controlBreakHeadingComponents.size() > 0) {
0912: generateHtmlForBand(
0913: _controlBreakHeadingComponents, p,
0914: backgroundColor, rowStyle, maxSize,
0915: false, rowIndex, rowIndex, "TD");
0916: backgroundColor = getBackgroundColor(backgroundColor);
0917: rowStyle = getStyle(rowStyle);
0918: }
0919: lastBreak = rowIndex;
0920: }
0921: } // end first row on page check
0922: } //end check for control breaks
0923: processPropertyExpressions(rowIndex);
0924:
0925: //do the columns
0926: if (_displayRowComponents) {
0927: //Begening of new row
0928: //Add the pagebreak if reuested... TT2001_11_15
0929: generateHtmlForBand(_rowComponents, p, backgroundColor,
0930: rowStyle, maxSize, false, rowIndex, rowIndex,
0931: "TD", _bAddPageBreak);
0932: }
0933:
0934: Thread.yield();
0935: }
0936: int nextRow = _firstRowOnPage + rowsPerPage;
0937: if (_breakColumns != null) {
0938: if (nextRow >= rowCount) {
0939: if (_controlBreakFooterComponents.size() > 0) {
0940: backgroundColor = getBackgroundColor(backgroundColor);
0941: rowStyle = getStyle(rowStyle);
0942: generateHtmlForBand(_controlBreakFooterComponents,
0943: p, backgroundColor, rowStyle, maxSize,
0944: false, lastBreak, rowCount - 1, "TD");
0945: }
0946: } else if (_ds.compareRows(lastBreak, nextRow,
0947: _breakColumns) != 0) {
0948: if (_controlBreakFooterComponents.size() > 0) {
0949: backgroundColor = getBackgroundColor(backgroundColor);
0950: rowStyle = getStyle(rowStyle);
0951: generateHtmlForBand(_controlBreakFooterComponents,
0952: p, backgroundColor, rowStyle, maxSize,
0953: false, lastBreak, nextRow - 1, "TD");
0954: }
0955: }
0956: }
0957: if (_genTHeadAndBody)
0958: p.println("</TBODY><TFOOT>");
0959: if (footerComponentsSize > 0 && nextRow >= rowCount) {
0960: backgroundColor = getBackgroundColor(backgroundColor);
0961: rowStyle = getStyle(rowStyle);
0962: generateHtmlForBand(_footerComponents, p, backgroundColor,
0963: rowStyle, maxSize, false, "TD");
0964: }
0965:
0966: if (rowCount > rowsPerPage) {
0967: if (_pageSelectRenderer == null) {
0968: if (_pageButtonType == PAGE_BUTTON_TYPE_SUBMIT)
0969: _pageSelectRenderer = DataTablePageSelectRenderer
0970: .getSubmitButtonRenderer();
0971: else if (_pageButtonType == PAGE_BUTTON_TYPE_IMAGE)
0972: _pageSelectRenderer = DataTablePageSelectRenderer
0973: .getImageButtonRenderer();
0974: else if (_pageButtonType != PAGE_BUTTON_TYPE_SCROLLBAR)
0975: _pageSelectRenderer = DataTablePageSelectRenderer
0976: .getLinkRenderer();
0977: }
0978: backgroundColor = getBackgroundColor(backgroundColor);
0979: rowStyle = getStyle(rowStyle);
0980: String styleString = "";
0981: if (backgroundColor != null)
0982: styleString += " BGCOLOR=\"" + backgroundColor + "\"";
0983: if (rowStyle != null)
0984: styleString += " CLASS=\"" + rowStyle + "\"";
0985:
0986: p.println("<TR><TD VALIGN=\"MIDDLE\" COLSPAN=\""
0987: + maxComponentsSize + "\"" + styleString + ">");
0988: int noButtons = (rowCount / rowsPerPage);
0989: if (rowCount % rowsPerPage > 0)
0990: noButtons++;
0991: int page = (_firstRowOnPage / rowsPerPage) + 1;
0992: p.println(_pageSelectRenderer.generateRowSelector(this ,
0993: _theme, "Page", "of", page, _firstSubmitButton,
0994: noButtons, _maxPageButtons, _imageURL));
0995: p.println("</TD></TR>");
0996: }
0997:
0998: if (rowPerPageSel && rowCount > 10) {
0999: if (_rowsPerPageRenderer == null)
1000: _rowsPerPageRenderer = DataTableRowsPerPageRenderer
1001: .getDefaultRenderer();
1002: backgroundColor = getBackgroundColor(backgroundColor);
1003: rowStyle = getStyle(rowStyle);
1004: String styleString = "";
1005: if (backgroundColor != null)
1006: styleString += " BGCOLOR=\"" + backgroundColor + "\"";
1007: if (rowStyle != null)
1008: styleString += " CLASS=\"" + rowStyle + "\"";
1009: p.println("<TR><TD VALIGN=\"MIDDLE\" COLSPAN=\""
1010: + maxComponentsSize + "\"" + styleString + ">");
1011: p.println(_rowsPerPageRenderer.generateRowSelector(this ,
1012: _theme, "Total Rows", "Rows displayed per page",
1013: _summaryRowText, rowsPerPage, rowCount));
1014: p.println("</TD></TR>");
1015: }
1016: if (_genTHeadAndBody)
1017: p.println("</TFOOT>");
1018: p.println("</TABLE>");
1019: boolean writeScrollDiv = _pageButtonType == PAGE_BUTTON_TYPE_SCROLLBAR
1020: && getPage().getBrowserType() == HtmlPage.BROWSER_MICROSOFT
1021: && getPage().getBrowserVersion() > 4;
1022: if (writeScrollDiv)
1023: p.println("</DIV>");
1024: if (_center)
1025: p.print("</CENTER>");
1026: if (_scroll) {
1027: _scroll = false;
1028: }
1029: _didSubmit = false;
1030: }
1031:
1032: /**
1033: * Author: Bruno Y. Decaudin Last Modifed: 12/06/00 - 4:30pm
1034: */
1035: private void generateHtmlForBand(Vector components, PrintWriter p,
1036: String rowBgColor, String rowStyle, int maxSize,
1037: boolean clickSort, int startRow, int endRow, String cellType)
1038: throws Exception {
1039: generateHtmlForBand(components, p, rowBgColor, rowStyle,
1040: maxSize, clickSort, startRow, endRow, cellType, false);
1041: }
1042:
1043: /**
1044: * Author: Bruno Y. Decaudin Last Modifed: 12/06/00 - 4:30pm
1045: */
1046: private void generateHtmlForBand(Vector components, PrintWriter p,
1047: String rowBgColor, String rowStyle, int maxSize,
1048: boolean clickSort, int startRow, int endRow,
1049: String cellType, boolean bAddPageBreak) throws Exception {
1050:
1051: processPropertyExpressions(endRow);
1052: StringBuffer td = new StringBuffer();
1053:
1054: if (bAddPageBreak && _iPageBreakIndex > 0) {
1055: if ((endRow % _iPageBreakIndex) == 0 && endRow > 0) {
1056: p
1057: .print("<TR><TD colspan=\""
1058: + maxSize
1059: + "\"><DIV class=pagebreak> </DIV></TR></TD>");
1060: if (components != _headingComponents
1061: && _repeatHeadingsAfterBreak)
1062: generateHtmlForBand(_headingComponents, p,
1063: _defaultHeadingBackground,
1064: _defaultHeadingStyleClassName, maxSize,
1065: _clickSort, "TD");
1066: }
1067: }
1068:
1069: boolean rowComponents = (components == _rowComponents);
1070: String javascriptRow = "";
1071: String rowHighlightColor = rowBgColor;
1072: if (rowComponents && _rowHighlighter != null) {
1073: String script = _rowHighlighter
1074: .generateJavaScriptForTrOnMouseDown(startRow, null);
1075: if (script.length() > 0)
1076: javascriptRow += " onmousedown=\"" + script + "\"";
1077: script = _rowHighlighter.generateJavaScriptForTrOnClick();
1078: if (script.length() > 0)
1079: javascriptRow += " onclick=\"" + script + "\"";
1080: rowHighlightColor = _rowHighlighter.getBgColorForRow(
1081: startRow, rowBgColor, null);
1082: }
1083:
1084: String styleString = "";
1085: if (rowHighlightColor != null)
1086: styleString += " BGCOLOR=\"" + rowHighlightColor + "\"";
1087: if (rowStyle != null)
1088: styleString += " CLASS=\"" + rowStyle + "\"";
1089:
1090: p.println("<TR" + styleString + javascriptRow + ">");
1091:
1092: //
1093: int addTo = 0;
1094: // sr 10-15-2000
1095: int width = -1;
1096: TwoObjectContainer cont = null;
1097: HtmlComponent comp = null;
1098: HtmlTableCellProperties props = null;
1099: int componentsSize = components.size();
1100: int rowComponentsSize = _rowComponents.size();
1101: //
1102: for (int i = 0; i < maxSize; i++) {
1103: td.setLength(0);
1104: td.append("<");
1105: td.append(cellType);
1106: width = getColumnWidth(i);
1107:
1108: // WIDTH
1109: if (width > 0) {
1110: td.append(" WIDTH=\"" + width);
1111: if (_sizeOption == SIZE_PERCENT)
1112: td.append("%");
1113: td.append("\"");
1114: }
1115:
1116: //
1117: cont = null;
1118: if (i < componentsSize) {
1119: cont = (TwoObjectContainer) components.elementAt(i);
1120: }
1121:
1122: // clear previous values
1123: comp = null;
1124: props = null;
1125: //
1126: if (cont != null) {
1127: comp = (HtmlComponent) cont.getObject1();
1128: props = (HtmlTableCellProperties) cont.getObject2();
1129: }
1130:
1131: //
1132: String cellBgColor = null;
1133: if (props != null) {
1134: // ALIGN -- ALIGN_NONE = ""
1135: if (!Util.isNull(props.getAlign())
1136: && !Util.isEmpty(props.getAlign())) {
1137: td.append(" ALIGN=\"" + props.getAlign() + "\"");
1138: }
1139:
1140: // VALIGN -- VALIGN_NONE = ""
1141: if (!Util.isNull(props.getVertAlign())
1142: && !Util.isEmpty(props.getVertAlign())) {
1143: td.append(" VALIGN=\"" + props.getVertAlign()
1144: + "\"");
1145: }
1146:
1147: // WIDTH
1148: if (width == -1 && props.getCellWidth() != -1) {
1149: td.append(" WIDTH=\"" + props.getCellWidth());
1150: // get column size option
1151: if (props.getCellWidthSizeOption() == SIZE_PERCENT)
1152: td.append("%");
1153: td.append("\"");
1154: }
1155:
1156: // HEIGHT
1157: if (props.getCellHeight() != -1) {
1158: td.append(" HEIGHT=\"" + props.getCellHeight());
1159: // get column size option
1160: if (props.getCellHeightSizeOption() == SIZE_PERCENT)
1161: td.append("%");
1162: td.append("\"");
1163: }
1164:
1165: // BGCOLOR
1166: if (!Util.isNull(props.getBackgroundColor())
1167: && !Util.isEmpty(props.getBackgroundColor())) {
1168: cellBgColor = props.getBackgroundColor();
1169: td.append(" BGCOLOR=\"" + cellBgColor + "\"");
1170: }
1171:
1172: // NOWRAP
1173: if (!props.getWrap()) {
1174: td.append(" NOWRAP");
1175: }
1176:
1177: // COLSPAN
1178: if (props.getColumnSpan() > 1) {
1179: td.append(" COLSPAN=\"" + props.getColumnSpan()
1180: + "\"");
1181: addTo = props.getColumnSpan() - 1;
1182: }
1183:
1184: }
1185: td.append('>');
1186:
1187: if (_rowHighlighter != null && rowComponents) {
1188: String html = _rowHighlighter.generateHtmlForTd(
1189: startRow, 0, rowBgColor);
1190: if (html.length() > 0) {
1191: td.append(" ");
1192: td.append(html);
1193: }
1194: }
1195:
1196: //
1197: p.println(td.toString());
1198: if (comp != null) {
1199: boolean underLine = false;
1200: if (i < rowComponentsSize) {
1201: if (clickSort
1202: && _rowComponents.elementAt(i) != null) {
1203: //-----------------------------------------------------------------------------------------------
1204: // Author: Bruno Y. Decaudin
1205: // Date: 12/06/00 - 4:30pm
1206: // Feedback Item#890: table cell background incorrectly
1207: // displayed in Netscape (non-issue in IE)
1208: // This is the second part of the fix. Part one of the
1209: // fix takes place in the HtmlText component
1210: // in both 'generateHTML' methods.
1211: // I added the following three lines to provide a way of
1212: // preventing an empty label from being
1213: // replaced by a ' ' and hence from being
1214: // associated with a JavaScript clicksort.
1215: // If the component is an HtmlText and its content is an
1216: // empty string then 'underline' will be set
1217: // to false and the JAvaScript code will not be
1218: // generated
1219: if (i < _headingComponents.size()) {
1220: TwoObjectContainer tocHeading = (TwoObjectContainer) _headingComponents
1221: .elementAt(i);
1222: if ((tocHeading.getObject1() instanceof HtmlText)
1223: && (((HtmlText) tocHeading
1224: .getObject1()).getText()
1225: .trim().equals("")))
1226: underLine = false;
1227: else
1228: underLine = true;
1229: }
1230: //-----------------------------------------------------------------------------------------------
1231: }
1232: }
1233:
1234: //
1235: if (underLine) {
1236: p.print("<A HREF=\"javascript:" + getFullName()
1237: + "_clickSort(" + i + ");\">");
1238: }
1239:
1240: //
1241: if (comp == null)
1242: p.println(" ");
1243: else {
1244: if (startRow > -1) {
1245: //sr 11-15-2000 originally the only thing in here :
1246: // comp.generateHTML(p, startRow, endRow);
1247: if (startRow != endRow) {
1248: comp.generateHTML(p, startRow, endRow);
1249: } else {
1250: comp.generateHTML(p, startRow);
1251: }
1252: } else {
1253: comp.generateHTML(p, -1);
1254: }
1255: }
1256:
1257: //
1258: if (underLine) {
1259: p.print("</A>");
1260: }
1261: } else {
1262: p.println(" ");
1263: }
1264:
1265: // Close the cell
1266: p.print("\n</");
1267: p.print(cellType);
1268: p.println(">");
1269: i += addTo;
1270: addTo = 0;
1271: }
1272:
1273: // close the row
1274: p.println("</TR>");
1275: }
1276:
1277: /**
1278: * This method was created in VisualAge.
1279: *
1280: * @param components
1281: * java.util.Vector
1282: */
1283: private void generateHtmlForBand(Vector components, PrintWriter p,
1284: String bgColor, String style, int maxSize,
1285: boolean clickSort, String cellType) throws Exception {
1286: generateHtmlForBand(components, p, bgColor, style, maxSize,
1287: clickSort, -1, -1, cellType);
1288: }
1289:
1290: private void generateHtmlTableStart(PrintWriter p) throws Exception {
1291: // SR 11-14-2000 p.println(Util.addHtmlComment("Start Data Table"));
1292:
1293: // CENTER
1294: if (_center) {
1295: p.print("<CENTER>");
1296: }
1297:
1298: // Create Table start
1299: p.println("<A NAME=\"" + getFullName() + "TableStart\"></A>");
1300: String tableHeading = "";
1301: boolean writeScrollDiv = _pageButtonType == PAGE_BUTTON_TYPE_SCROLLBAR
1302: && getPage().getBrowserType() == HtmlPage.BROWSER_MICROSOFT
1303: && getPage().getBrowserVersion() > 4;
1304: if (writeScrollDiv) {
1305: tableHeading += "<style>thead#"
1306: + getFullName()
1307: + "-thead td {position:relative;top: expression(document.getElementById(\""
1308: + getFullName() + "-div\").scrollTop-2);}</style>";
1309: tableHeading += "<div id=\"" + getFullName()
1310: + "-div\" style=\"height:" + _tableHeight
1311: + "px;overflow: auto\">";
1312: }
1313: tableHeading += "<TABLE";
1314: if (_containerWidth > -1) {
1315: tableHeading += " WIDTH=\"" + _containerWidth;
1316: if (_sizeOption == SIZE_PERCENT) {
1317: tableHeading += "%";
1318: }
1319: tableHeading += "\"";
1320: }
1321:
1322: // BORDER
1323: if (_border > -1) {
1324: tableHeading += " BORDER=\"" + _border + "\"";
1325: }
1326:
1327: // BGCOLOR
1328: if (!Util.isNull(_bgColor) && !Util.isEmpty(_bgColor)) {
1329: tableHeading += " BGCOLOR=\"" + _bgColor + "\"";
1330: }
1331:
1332: // CELLPADDING
1333: if (_cellPadding > -1) {
1334: tableHeading += " CELLPADDING=\"" + _cellPadding + "\"";
1335: }
1336:
1337: // CELLSPACING
1338: if (_cellPadding > -1) {
1339: tableHeading += " CELLSPACING=\"" + _cellSpacing + "\"";
1340: }
1341:
1342: // ALIGN
1343: if (_align != null) {
1344: if (_align.equals(ALIGN_LEFT) || _align.equals(ALIGN_RIGHT)
1345: || _align.equals(ALIGN_CENTER)) {
1346: tableHeading += " ALIGN=\"" + _align + "\"";
1347: }
1348: }
1349:
1350: //
1351: tableHeading += ">";
1352: p.println(tableHeading);
1353: if (_clickSort) {
1354: p.println("<INPUT TYPE=\"HIDDEN\" NAME=\"" + getFullName()
1355: + "_SORTITEM\" VALUE=\"-1\">");
1356: p.print("<SCRIPT>");
1357: p.print("function " + getFullName() + "_clickSort(i) {");
1358: p.print(getFormString() + getFullName()
1359: + "_SORTITEM.value = i;");
1360: JspForm form = JspForm.findParentForm(this );
1361: if (form != null)
1362: p.print(form.getSubmitScript());
1363: else
1364: p.print(getFormString() + "submit();");
1365: p.print("}");
1366: p.print("</SCRIPT>");
1367: }
1368: }
1369:
1370: public void generateImage(String img, OutputStream out)
1371: throws IOException {
1372: //create an image to draw
1373: ImageFactory fact = new ImageFactory();
1374: Image i = null;
1375:
1376: String source = img;
1377: if (img.equals("first"))
1378: source = "<<";
1379: else if (img.equals("last"))
1380: source = ">>";
1381: else if (img.equals("next"))
1382: source = ">";
1383: else if (img.equals("prior"))
1384: source = "<";
1385: else
1386: source = new Integer((Integer.parseInt(img) + 1))
1387: .toString();
1388:
1389: if (_style.equals(PAGE_BUTTON_STYLE_OVAL))
1390: i = fact.createOvalButton(_height, getPagingButtonFont(),
1391: source, _textColor, _backgroundColor,
1392: _topLeftBorder, _bottomRightBorder,
1393: _transparentColor, false, _enabled);
1394: else
1395: i = fact.createRectangleButton(_height,
1396: getPagingButtonFont(), source, _textColor,
1397: _backgroundColor, _topLeftBorder,
1398: _bottomRightBorder, false, _enabled);
1399:
1400: GifEncoder g = new GifEncoder(i, out, true, _transparentColor);
1401: g.encode();
1402:
1403: }
1404:
1405: public void generateInitialHTML(PrintWriter p) throws Exception {
1406: if (!_visible)
1407: return;
1408:
1409: generateInitialHtmlForBand(_headingComponents, p);
1410: generateInitialHtmlForBand(_rowComponents, p);
1411: generateInitialHtmlForBand(_footerComponents, p);
1412: generateInitialHtmlForBand(_controlBreakFooterComponents, p);
1413: generateInitialHtmlForBand(_controlBreakHeadingComponents, p);
1414:
1415: }
1416:
1417: private void generateInitialHtmlForBand(Vector components,
1418: PrintWriter p) throws Exception {
1419: // sr 10-15-2000
1420: int componentsSize = components.size();
1421: TwoObjectContainer cont = null;
1422: //
1423: for (int i = 0; i < componentsSize; i++) {
1424: cont = (TwoObjectContainer) components.elementAt(i);
1425: if (cont != null && cont.getObject1() != null)
1426: ((HtmlComponent) cont.getObject1())
1427: .generateInitialHTML(p);
1428: }
1429: }
1430:
1431: /**
1432: * Returns the alignment property for the table.
1433: *
1434: * @return align Valid values are ALIGN_LEFT,ALIGN_CENTER,ALIGN_RIGHT and
1435: * ALIGN_NONE.
1436: */
1437: public String getAlign() {
1438: return _align;
1439: }
1440:
1441: /**
1442: * Gets the background color for the table.
1443: */
1444: public String getBackgroundColor() {
1445: return _bgColor;
1446: }
1447:
1448: protected String getBackgroundColor(String currentColor) {
1449: if (currentColor == null)
1450: return _defaultRowBackground1;
1451: else if (currentColor.equals(_defaultRowBackground1))
1452: return _defaultRowBackground2;
1453: else
1454: return _defaultRowBackground1;
1455:
1456: }
1457:
1458: protected String getStyle(String currentStyle) {
1459: if (currentStyle == null)
1460: return _defaultRowStyleClassName1;
1461: else if (currentStyle.equals(_defaultRowStyleClassName1))
1462: return _defaultRowStyleClassName2;
1463: else
1464: return _defaultRowStyleClassName1;
1465:
1466: }
1467:
1468: /**
1469: * Gets the border thickness for the table.
1470: */
1471: public int getBorder() {
1472: return _border;
1473: }
1474:
1475: public long getCacheKey() {
1476: return _cacheKey;
1477: }
1478:
1479: /**
1480: * Gets the cell padding for the table.
1481: */
1482: public int getCellPadding() {
1483: return _cellPadding;
1484: }
1485:
1486: /**
1487: * Gets the cell spacing for the table.
1488: */
1489: public int getCellSpacing() {
1490: return _cellSpacing;
1491: }
1492:
1493: /**
1494: * Returns true if heading components should be underline links that sort
1495: * the list.
1496: */
1497: public boolean getClickSort() {
1498: return _clickSort;
1499: }
1500:
1501: /**
1502: * This method gets the minimum width for a particular column in the table
1503: * or -1 if the column width has not been set
1504: */
1505: public int getColumnWidth(int column) {
1506: if (column < 0)
1507: return -1;
1508:
1509: if (column >= _columnWidth.size())
1510: return -1;
1511:
1512: Object o = _columnWidth.elementAt(column);
1513:
1514: if (o == null)
1515: return -1;
1516:
1517: return ((Integer) o).intValue();
1518: }
1519:
1520: /**
1521: * This method returns all the elements in the container.
1522: */
1523: public Enumeration getComponents() {
1524: Vector comp = new Vector();
1525: //
1526: int headingComponentsSize = _headingComponents.size();
1527: int rowComponentsSize = _rowComponents.size();
1528: int footerComponentsSize = _footerComponents.size();
1529: int controlBreakHeadingComponentsSize = _controlBreakHeadingComponents
1530: .size();
1531: int controlBreakFooterComponentsSize = _controlBreakFooterComponents
1532: .size();
1533: //
1534: TwoObjectContainer t = null;
1535: HtmlComponent h = null;
1536: //
1537:
1538: for (int i = 0; i < headingComponentsSize; i++) {
1539: t = (TwoObjectContainer) _headingComponents.elementAt(i);
1540: if (t != null) {
1541: h = (HtmlComponent) t.getObject1();
1542: if (h != null)
1543: comp.addElement(h);
1544: }
1545: }
1546: for (int i = 0; i < rowComponentsSize; i++) {
1547: t = (TwoObjectContainer) _rowComponents.elementAt(i);
1548: if (t != null) {
1549: h = (HtmlComponent) t.getObject1();
1550: if (h != null)
1551: comp.addElement(h);
1552: }
1553: }
1554: for (int i = 0; i < footerComponentsSize; i++) {
1555: t = (TwoObjectContainer) _footerComponents.elementAt(i);
1556: if (t != null) {
1557: h = (HtmlComponent) t.getObject1();
1558: if (h != null)
1559: comp.addElement(h);
1560: }
1561: }
1562: for (int i = 0; i < controlBreakHeadingComponentsSize; i++) {
1563: t = (TwoObjectContainer) _controlBreakHeadingComponents
1564: .elementAt(i);
1565: if (t != null) {
1566: h = (HtmlComponent) t.getObject1();
1567: if (h != null)
1568: comp.addElement(h);
1569: }
1570: }
1571: for (int i = 0; i < controlBreakFooterComponentsSize; i++) {
1572: t = (TwoObjectContainer) _controlBreakFooterComponents
1573: .elementAt(i);
1574: if (t != null) {
1575: h = (HtmlComponent) t.getObject1();
1576: if (h != null)
1577: comp.addElement(h);
1578: }
1579: }
1580: return comp.elements();
1581: }
1582:
1583: /**
1584: * Returns the internal data store buffer used by the component.
1585: */
1586: public DataStoreBuffer getDataStoreBuffer() {
1587: return _ds;
1588: }
1589:
1590: /**
1591: * This method returns true if the datatable did the last submit of the page
1592: * through a sort or clicking on a paging button.
1593: */
1594: public boolean getDidSubmit() {
1595: return _didSubmit;
1596: }
1597:
1598: /**
1599: * This method gets the first row displayed on the current page.
1600: */
1601: public int getFirstRowOnPage() {
1602: return _firstRowOnPage;
1603: }
1604:
1605: /**
1606: * This method returns all the elements in the container.
1607: */
1608: public int getFooterComponentsSize() {
1609: return _footerComponents.size();
1610: }
1611:
1612: /**
1613: * Gets whether the or not paging buttons will be generated images or
1614: * regular submit buttons.
1615: *
1616: * @deprecated Use getPageButtonType()
1617: */
1618: public boolean getGenImagesForPagingButtons() {
1619: return _pageButtonType == PAGE_BUTTON_TYPE_IMAGE;
1620: }
1621:
1622: /**
1623: * This method returns the heading component at the specified position or
1624: * null if non is found.
1625: */
1626: public HtmlComponent getHeadingComponentAt(int pos) {
1627: if (pos < 0 || pos >= _headingComponents.size())
1628: return null;
1629:
1630: TwoObjectContainer t = (TwoObjectContainer) _headingComponents
1631: .elementAt(pos);
1632: if (t == null)
1633: return null;
1634:
1635: return (HtmlComponent) t.getObject1();
1636:
1637: }
1638:
1639: /**
1640: * This method returns the heading component at that is the same as the name
1641: * specified or null if none is found.
1642: */
1643: public HtmlComponent getHeadingComponentAt(String name) {
1644: return (HtmlComponent) _compLookUpHash
1645: .get(HEADING_COMP_HASH_KEY + name);
1646: }
1647:
1648: /**
1649: * This method returns all the elements in the container.
1650: */
1651: public int getHeadingComponentsSize() {
1652: return _headingComponents.size();
1653: }
1654:
1655: /**
1656: * This method returns the font that is being used for links created with
1657: * addColumn.
1658: */
1659: public String getLinkFont() {
1660: return _linkFont;
1661: }
1662:
1663: /**
1664: * This method gets the maximum number of paging buttons to display.
1665: */
1666: public int getMaxPageButtons() {
1667: return _maxPageButtons;
1668: }
1669:
1670: /**
1671: * This method returns the page the row is on.
1672: */
1673: public int getPage(int row) {
1674: return row / _rowsPerPage;
1675: }
1676:
1677: /**
1678: * This method returns the background color of paging button images
1679: */
1680: public Color getPagingButtonBackgroundColor() {
1681: return _backgroundColor;
1682: }
1683:
1684: /**
1685: * This method returns the bottom right border color of paging button images
1686: */
1687: public Color getPagingButtonBottomRightColor() {
1688: return _bottomRightBorder;
1689: }
1690:
1691: /**
1692: * This method gets the Display Style for a generated page button image.
1693: * Valid Values are PAGE_BUTTON_STYLE_RECTANGLE and PAGE_BUTTON_STYLE_OVAL
1694: */
1695: public String getPagingButtonDisplayStyle() {
1696: return _style;
1697: }
1698:
1699: /**
1700: * This method returns the font used for page button images
1701: */
1702: public Font getPagingButtonFont() {
1703: if (_buttonFont == null)
1704: _buttonFont = new Font(_fontString, 0, _fontSize);
1705: return _buttonFont;
1706: }
1707:
1708: /**
1709: * This method returns the height used for page button images
1710: */
1711: public int getPagingButtonHeight() {
1712: return _height;
1713: }
1714:
1715: /**
1716: * This method returns the text color of page button images
1717: */
1718: public Color getPagingButtonTextColor() {
1719: return _textColor;
1720: }
1721:
1722: /**
1723: * This method returns the row component at the specified position or null
1724: * if non is found.
1725: */
1726: public HtmlComponent getRowComponentAt(int pos) {
1727: if (pos < 0 || pos >= _rowComponents.size())
1728: return null;
1729:
1730: TwoObjectContainer t = (TwoObjectContainer) _rowComponents
1731: .elementAt(pos);
1732: if (t == null)
1733: return null;
1734:
1735: return (HtmlComponent) t.getObject1();
1736:
1737: }
1738:
1739: /**
1740: * This method returns the row component at that is the same as the name
1741: * specified or null if none is found.
1742: */
1743: public HtmlComponent getRowComponentAt(String name) {
1744: return (HtmlComponent) _compLookUpHash.get(ROW_COMP_HASH_KEY
1745: + name);
1746:
1747: }
1748:
1749: /**
1750: * This method returns all the elements in the container.
1751: */
1752: public int getRowComponentsSize() {
1753: return _rowComponents.size();
1754: }
1755:
1756: /**
1757: * This method gets the number of rows to display on one page of output. A
1758: * value <= 0 will indicate no limit to the number of rows displayed.
1759: */
1760: public int getRowsPerPage() {
1761: if (_rowsPerPage == MAX_ROW_LIMIT)
1762: return 0;
1763: else
1764: return _rowsPerPage;
1765: }
1766:
1767: /**
1768: * This method gets the anchor to scroll to when a paging button on the
1769: * table is clicked. Set it to null for the top of the table.
1770: */
1771: public String getScrollAnchor() {
1772: return _scrollAnchor;
1773: }
1774:
1775: /**
1776: * Gets whether the datastore will build scrolling javascript when the user
1777: * clicks on a column heading to sort or a paging button.
1778: */
1779: public boolean getScrollOnClickSort() {
1780: return _scrollOnSort;
1781: }
1782:
1783: /**
1784: * Returns true if rows per page selector is visible.
1785: */
1786: public boolean getSelRowsPerPage() {
1787: return _rowPerPageSel;
1788: }
1789:
1790: /**
1791: * This method returns the size option for the table and each cell in it.
1792: * Valid return values are SIZE_PIXELS or SIZE_PERCENT.
1793: */
1794: public int getSizeOption() {
1795: return _sizeOption;
1796: }
1797:
1798: /**
1799: * This method returns the number of the last column that the user clicked
1800: * on to sort the list.
1801: */
1802: public int getSortColumn() {
1803: return _sortColumn;
1804: }
1805:
1806: /**
1807: * This method returns the direction of the sort set when the user last
1808: * clicked a column heading to sort the list. Valid values are
1809: * DataStoreBuffer.SORT_ASC or DataStoreBuffer.SORT_DES.
1810: */
1811: public int getSortDirection() {
1812: return _sortDir;
1813: }
1814:
1815: /**
1816: * This method returns the property theme for the component.
1817: */
1818: public String getTheme() {
1819: return _theme;
1820: }
1821:
1822: /**
1823: * If the image is dynamically generated, this method will indicate whether
1824: * or not the Objectstore should cache it.
1825: */
1826: public boolean getUseCache() {
1827: return _useCache;
1828: }
1829:
1830: /**
1831: * Gets whether the or not paging buttons will be links or submit.
1832: *
1833: * @deprecated use getPageButtonType
1834: */
1835: public boolean getUseLinksForPagingButtons() {
1836: return _pageButtonType == PAGE_BUTTON_TYPE_TEXT;
1837: }
1838:
1839: /**
1840: * This method returns the width of the table.
1841: */
1842: public int getWidth() {
1843: return _containerWidth;
1844: }
1845:
1846: /**
1847: * This method returns true if the specified row is on the current page.
1848: */
1849: public boolean isRowOnPage(int row) {
1850: int pageNo = row / _rowsPerPage;
1851: int currentPage = _firstRowOnPage / _rowsPerPage;
1852:
1853: return pageNo == currentPage;
1854: }
1855:
1856: public boolean processParms(Hashtable parms, int rowNo)
1857: throws Exception {
1858: if (!getVisible())
1859: return false;
1860: //
1861: int headingComponentsSize = _headingComponents.size();
1862: int rowComponentsSize = _rowComponents.size();
1863: int footerComponentsSize = _footerComponents.size();
1864: int controlBreakHeadingComponentsSize = _controlBreakHeadingComponents
1865: .size();
1866: //
1867: TwoObjectContainer t = null;
1868: HtmlComponent h = null;
1869: int rowCount = _ds.getRowCount();
1870: //
1871: for (int i = 0; i < headingComponentsSize; i++) {
1872: t = (TwoObjectContainer) _headingComponents.elementAt(i);
1873: if (t != null) {
1874: h = (HtmlComponent) t.getObject1();
1875: if (h != null)
1876: if (h.processParms(parms, -1))
1877: _submit = h;
1878: }
1879: }
1880: //
1881: for (int j = _firstRowOnPage; (j < rowCount)
1882: && (j < (_firstRowOnPage + _rowsPerPage)); j++) {
1883: processPropertyExpressions(j);
1884: for (int i = 0; i < rowComponentsSize; i++) {
1885: t = (TwoObjectContainer) _rowComponents.elementAt(i);
1886: if (t != null) {
1887: h = (HtmlComponent) t.getObject1();
1888: if (h != null)
1889: if (h.processParms(parms, j))
1890: _submit = h;
1891: }
1892: }
1893: }
1894: //
1895: for (int i = 0; i < footerComponentsSize; i++) {
1896: t = (TwoObjectContainer) _footerComponents.elementAt(i);
1897: if (t != null) {
1898: h = (HtmlComponent) t.getObject1();
1899: if (h != null)
1900: if (h.processParms(parms, -1))
1901: _submit = h;
1902: }
1903: }
1904: //
1905: for (int j = _firstRowOnPage; (j < rowCount)
1906: && (j < (_firstRowOnPage + _rowsPerPage)); j++) {
1907: for (int i = 0; i < controlBreakHeadingComponentsSize; i++) {
1908: t = (TwoObjectContainer) _controlBreakHeadingComponents
1909: .elementAt(i);
1910: if (t != null) {
1911: h = (HtmlComponent) t.getObject1();
1912: if (h != null)
1913: if (h.processParms(parms, j))
1914: _submit = h;
1915: }
1916: }
1917: }
1918: //
1919: int noButtons = rowCount / _rowsPerPage;
1920: if (rowCount % _rowsPerPage > 0)
1921: noButtons++;
1922:
1923: Object rpp = parms.get(getFullName() + "_rows_per_page_hidden");
1924: if (rpp != null) {
1925: String val = ((String[]) rpp)[0];
1926: if (val.equals("1")) {
1927: rpp = parms.get(getFullName() + "row_per_page_dd");
1928: _newRowsPerPage = new Integer(((String[]) rpp)[0])
1929: .intValue();
1930: _submit = this ;
1931: } else if (!val.equals("-1")) {
1932: _newRowsPerPage = new Integer(val.trim()).intValue();
1933: _submit = this ;
1934: }
1935: }
1936:
1937: //
1938: _newStartRow = -1;
1939: _newFirstButton = -1;
1940: _clickSortColumn = -1;
1941: Object s1 = parms.get(getFullName() + "_SORTITEM");
1942: String sort = "-1";
1943: if (s1 != null)
1944: sort = ((String[]) s1)[0];
1945: //
1946: if (!sort.equals("-1")) {
1947: if (_breakColumns == null) {
1948: _newFirstButton = 0;
1949: _newStartRow = 0;
1950: }
1951: _clickSortColumn = Integer.parseInt(sort);
1952: _submit = this ;
1953: }
1954:
1955: String[] pageSubmitA = (String[]) parms.get(getFullName()
1956: + "_page_selector");
1957: String pageSubmit = "";
1958: if (pageSubmitA != null)
1959: pageSubmit = pageSubmitA[0];
1960:
1961: if (parms.get(getFullName() + "_page_first") != null
1962: || parms.get(getFullName() + "_page_first.x") != null
1963: || pageSubmit.equals("first")) {
1964: _newFirstButton = 0;
1965: _newStartRow = 0;
1966: _submit = this ;
1967: } else if (parms.get(getFullName() + "_page_prior") != null
1968: || parms.get(getFullName() + "_page_prior.x") != null
1969: || pageSubmit.equals("prior")) {
1970: _newFirstButton = _firstSubmitButton
1971: - (_maxPageButtons == 0 ? 1 : _maxPageButtons);
1972: _submit = this ;
1973: if (_newFirstButton < 0)
1974: _newFirstButton = 0;
1975: _newStartRow = _rowsPerPage
1976: * (_newFirstButton
1977: + (_maxPageButtons == 0 ? 1
1978: : _maxPageButtons) - 1);
1979: } else if (parms.get(getFullName() + "_page_next") != null
1980: || parms.get(getFullName() + "_page_next.x") != null
1981: || pageSubmit.equals("next")) {
1982: _newFirstButton = _firstSubmitButton
1983: + (_maxPageButtons == 0 ? 1 : _maxPageButtons);
1984: _submit = this ;
1985: if ((_newFirstButton + _maxPageButtons) >= noButtons)
1986: _newFirstButton = (noButtons - (_maxPageButtons == 0 ? 1
1987: : _maxPageButtons));
1988: _newStartRow = _rowsPerPage * _newFirstButton;
1989: } else if (parms.get(getFullName() + "_page_last") != null
1990: || parms.get(getFullName() + "_page_last.x") != null
1991: || pageSubmit.equals("last")) {
1992: _submit = this ;
1993: _newFirstButton = (noButtons - (_maxPageButtons == 0 ? 1
1994: : _maxPageButtons));
1995: _newStartRow = _rowsPerPage * _newFirstButton;
1996: if (_newStartRow < 0)
1997: _newStartRow = 0;
1998: } else if (!pageSubmit.equals("")) {
1999: _newStartRow = _rowsPerPage * Integer.parseInt(pageSubmit);
2000: _submit = this ;
2001: } else {
2002: for (int i = _firstSubmitButton; (i < noButtons)
2003: && ((i - _firstSubmitButton) < _maxPageButtons); i++) {
2004: if (parms.get(getFullName() + "_page_" + i) != null
2005: || parms.get(getFullName() + "_page_" + i
2006: + ".x") != null) {
2007: _newStartRow = _rowsPerPage * i;
2008: _submit = this ;
2009: break;
2010: }
2011: }
2012: }
2013: //
2014: if (_submit == null) {
2015: _scroll = false;
2016: return false;
2017: } else {
2018: _scroll = _scrollOnSort;
2019: _didSubmit = true;
2020: return true;
2021: }
2022: }
2023:
2024: protected void processPropertyExpressions(int row) {
2025: if (_propertyExpressions == null)
2026: return;
2027:
2028: ThreeObjectContainer c = null;
2029: Object comp = null;
2030: Method meth = null;
2031: DataStoreEvaluator eval = null;
2032:
2033: int propertyExpressionsSize = _propertyExpressions.size();
2034: for (int i = 0; i < propertyExpressionsSize; i++) {
2035: c = (ThreeObjectContainer) _propertyExpressions
2036: .elementAt(i);
2037: comp = c.getObject1();
2038: meth = (Method) c.getObject2();
2039: eval = (DataStoreEvaluator) c.getObject3();
2040: HtmlPage.executePropertyMethod(comp, meth, eval, row);
2041: }
2042: }
2043:
2044: /**
2045: * Removes all the components from the DataTable
2046: */
2047: public void removeAll() {
2048: _headingComponents.removeAllElements();
2049: _rowComponents.removeAllElements();
2050: _footerComponents.removeAllElements();
2051: _controlBreakFooterComponents.removeAllElements();
2052: _controlBreakHeadingComponents.removeAllElements();
2053: }
2054:
2055: /**
2056: * Removes an html component from the row container.
2057: *
2058: * @param comp
2059: * The component to remove
2060: */
2061: public void removeRowComponent(HtmlComponent comp) {
2062: int rowComponentsSize = _rowComponents.size();
2063: //
2064: TwoObjectContainer t = null;
2065: HtmlComponent h = null;
2066: //
2067: for (int i = 0; i < rowComponentsSize; i++) {
2068: t = (TwoObjectContainer) _rowComponents.elementAt(i);
2069: h = (HtmlComponent) t.getObject1();
2070: if (h == comp) {
2071: _rowComponents.setElementAt(null, i);
2072: return;
2073: }
2074: }
2075: }
2076:
2077: public void reset() {
2078: super .reset();
2079: _firstRowOnPage = 0;
2080: _firstSubmitButton = 0;
2081: }
2082:
2083: /**
2084: * This method will remove all Control Break Footer Components from the
2085: * DataTable.
2086: */
2087: public void resetControlBreakFooterComponents() {
2088: _controlBreakFooterComponents.removeAllElements();
2089: }
2090:
2091: /**
2092: * This method will remove all Control Break Heading Components from the
2093: * DataTable.
2094: */
2095: public void resetControlBreakHeadingComponents() {
2096: _controlBreakHeadingComponents.removeAllElements();
2097: }
2098:
2099: /**
2100: * This method will remove all Footer Components from the DataTable.
2101: */
2102: public void resetFooterComponents() {
2103: _footerComponents.removeAllElements();
2104: }
2105:
2106: /**
2107: * This method will remove all Heading Components from the DataTable.
2108: */
2109: public void resetHeadingComponents() {
2110: _headingComponents.removeAllElements();
2111: }
2112:
2113: /**
2114: * This method will remove all Row Components from the DataTable.
2115: */
2116: public void resetRowComponents() {
2117: _rowComponents.removeAllElements();
2118: }
2119:
2120: /**
2121: * Sets the alignment property for the table.
2122: *
2123: * @param align
2124: * Valid values are ALIGN_LEFT,ALIGN_CENTER,ALIGN_RIGHT and
2125: * ALIGN_NONE.
2126: */
2127:
2128: public void setAlign(String align) {
2129: _align = align;
2130: }
2131:
2132: /**
2133: * Sets the background color for the table.
2134: */
2135: public void setBackgroundColor(String value) {
2136: _bgColor = value;
2137: }
2138:
2139: /**
2140: * This method will set the base click sort column for the datastore. This
2141: * column and direction will be appended to the sort column that the user
2142: * clicked on.
2143: *
2144: * @param column
2145: * The column to sort on
2146: * @param dir
2147: * int DataStoreBuffer.SORT_ASC or DataStoreBuffer.SORT_DES
2148: */
2149: public void setBaseClickSort(String column, int dir) {
2150: _baseSortColumn = _ds.getColumnIndex(column);
2151: _baseSortDir = dir;
2152: }
2153:
2154: /**
2155: * Sets the border width for the table.
2156: */
2157: public void setBorder(int border) {
2158: _border = border;
2159: }
2160:
2161: /**
2162: * Use this method to set the columns that the Data Table will control break
2163: * on.
2164: *
2165: * @param cols
2166: * An array of column numbers to break on.
2167: */
2168: public void setBreakColumns(int[] cols) {
2169: _breakColumns = cols;
2170: }
2171:
2172: /**
2173: * Use this method to set the columns that the Data Table will control break
2174: * on.
2175: *
2176: * @param cols
2177: * An array of column names to break on.
2178: */
2179: public void setBreakColumns(String[] cols) {
2180:
2181: int[] colN = new int[cols.length];
2182:
2183: for (int i = 0; i < colN.length; i++) {
2184: colN[i] = _ds.getColumnIndex(cols[i]);
2185: if (colN[i] == -1) {
2186: MessageLog.writeInfoMessage(
2187: "***Column Not Found Setting Break Columns:"
2188: + cols[i] + "***", this );
2189: }
2190: }
2191: _breakColumns = colN;
2192: }
2193:
2194: /**
2195: * Use this method to set the columns that the Data Table will control break
2196: * on.
2197: *
2198: * @param col
2199: * The column number to break on.
2200: */
2201: public void setBreakColumns(int col) {
2202: _breakColumns = new int[1];
2203: _breakColumns[0] = col;
2204: }
2205:
2206: /**
2207: * Use this method to set the columns that the Data Table will control break
2208: * on.
2209: *
2210: * @param col
2211: * A column name to break on.
2212: */
2213: public void setBreakColumns(String col) {
2214: int colN = _ds.getColumnIndex(col);
2215: if (colN == -1) {
2216: MessageLog.writeInfoMessage(
2217: "***Column Name not Found Setting Break Columns:"
2218: + col + "***", this );
2219: }
2220: _breakColumns = new int[1];
2221: _breakColumns[0] = colN;
2222: }
2223:
2224: public void setCacheKey(long key) {
2225: _cacheKey = key;
2226: }
2227:
2228: /**
2229: * Sets the cell padding for the table.
2230: */
2231: public void setCellPadding(int value) {
2232: _cellPadding = value;
2233: }
2234:
2235: /**
2236: * Sets the cell spacing for the table.
2237: */
2238: public void setCellSpacing(int value) {
2239: _cellSpacing = value;
2240: }
2241:
2242: /**
2243: * Set to true if heading components should be underline links that sort the
2244: * list.
2245: */
2246: public void setClickSort(boolean clickSort) {
2247: _clickSort = clickSort;
2248: }
2249:
2250: /**
2251: * Sets the column width for a particular column in the table.
2252: */
2253: public void setColumnWidth(int column, int width) {
2254: if (column < 0)
2255: return;
2256:
2257: if (column >= _columnWidth.size())
2258: _columnWidth.setSize(column + 1);
2259:
2260: _columnWidth.setElementAt(new Integer(width), column);
2261: }
2262:
2263: /**
2264: * Use this method to set a continuation message for an HtmlDataTable with
2265: * Control Break Columns. The component will be set to visible only for
2266: * control break headings where the first row on the page is not the first
2267: * row in the group.
2268: */
2269: public void setContMessage(HtmlComponent comp) {
2270: _contMessage = comp;
2271: }
2272:
2273: /**
2274: * Sets a control break footer component at a particular row position in the
2275: * table.
2276: */
2277: public void setControlBreakFooterComponentAt(int column,
2278: HtmlComponent comp) {
2279: setControlBreakFooterComponentAt(column, comp, null);
2280: }
2281:
2282: /**
2283: * Sets a control break footer component at a particular column position in
2284: * the table. The cell in the table will use properties specified in the
2285: * props argument.
2286: */
2287: public void setControlBreakFooterComponentAt(int column,
2288: HtmlComponent comp, HtmlTableCellProperties props) {
2289: if (column < 0)
2290: return;
2291:
2292: if (column >= _controlBreakFooterComponents.size())
2293: _controlBreakFooterComponents.setSize(column + 1);
2294:
2295: TwoObjectContainer cont = new TwoObjectContainer(comp, props);
2296:
2297: _controlBreakFooterComponents.setElementAt(cont, column);
2298:
2299: comp.setParent(this );
2300:
2301: }
2302:
2303: /**
2304: * Sets all the control break footer components on a particular row in the
2305: * table. If you want to use HtmlTableCellProperties you will have to use
2306: * setControlBreakFooterComponentAt(int,HtmlComponent,HtmlTableCellProperties)
2307: */
2308: public void setControlBreakFooterComponents(HtmlComponent comp[]) {
2309: for (int colIndex = 0; colIndex < comp.length; colIndex++) {
2310: setControlBreakFooterComponentAt(colIndex, comp[colIndex],
2311: null);
2312: }
2313: }
2314:
2315: /**
2316: * Sets all the control break footer components on a particular row in the
2317: * table. If you want to use HtmlTableCellProperties pass an array of
2318: * HtmlTableCellProperties with the ones that do not need cell props it as
2319: * null.
2320: */
2321: public void setControlBreakFooterComponents(HtmlComponent comp[],
2322: HtmlTableCellProperties props[]) {
2323: for (int colIndex = 0; colIndex < comp.length; colIndex++) {
2324: setControlBreakFooterComponentAt(colIndex, comp[colIndex],
2325: props[colIndex]);
2326: }
2327: }
2328:
2329: /**
2330: * Sets a control break heading component at a particular row position in
2331: * the table.
2332: */
2333: public void setControlBreakHeadingComponentAt(int column,
2334: HtmlComponent comp) {
2335: setControlBreakHeadingComponentAt(column, comp, null);
2336: }
2337:
2338: /**
2339: * Sets a control break heading component at a particular column position in
2340: * the table. The cell in the table will use properties specified in the
2341: * props argument.
2342: */
2343: public void setControlBreakHeadingComponentAt(int column,
2344: HtmlComponent comp, HtmlTableCellProperties props) {
2345: if (column < 0)
2346: return;
2347:
2348: if (column >= _controlBreakHeadingComponents.size())
2349: _controlBreakHeadingComponents.setSize(column + 1);
2350:
2351: TwoObjectContainer cont = new TwoObjectContainer(comp, props);
2352:
2353: _controlBreakHeadingComponents.setElementAt(cont, column);
2354:
2355: comp.setParent(this );
2356:
2357: }
2358:
2359: /**
2360: * Sets all the control break heading components on a particular row in the
2361: * table. If you want to use HtmlTableCellProperties you will have to use
2362: * setControlBreakHeadingComponentAt(int,HtmlComponent,HtmlTableCellProperties)
2363: */
2364: public void setControlBreakHeadingComponents(HtmlComponent comp[]) {
2365: for (int colIndex = 0; colIndex < comp.length; colIndex++) {
2366: setControlBreakHeadingComponentAt(colIndex, comp[colIndex],
2367: null);
2368: }
2369: }
2370:
2371: /**
2372: * Sets all the control break heading components on a particular row in the
2373: * table. If you want to use HtmlTableCellProperties pass an array of
2374: * HtmlTableCellProperties with the ones that do not need cell props it as
2375: * null.
2376: */
2377: public void setControlBreakHeadingComponents(HtmlComponent comp[],
2378: HtmlTableCellProperties props[]) {
2379: for (int colIndex = 0; colIndex < comp.length; colIndex++) {
2380: setControlBreakHeadingComponentAt(colIndex, comp[colIndex],
2381: props[colIndex]);
2382: }
2383: }
2384:
2385: /**
2386: * Sets the internal data store used by the component.
2387: */
2388: public void setDataStore(DataStoreBuffer d) {
2389: _ds = d;
2390: }
2391:
2392: /**
2393: * Use this method if you don't want the datatable to display the band with
2394: * row components.
2395: */
2396: public void setDisplayRowComponents(boolean display) {
2397: _displayRowComponents = display;
2398: }
2399:
2400: /**
2401: * This method sets the first row displayed on the current page.
2402: */
2403: public void setFirstRowOnPage(int firstRowOnPage) {
2404: _firstRowOnPage = firstRowOnPage;
2405: }
2406:
2407: /**
2408: * Sets a footer component at a particular row position in the table.
2409: */
2410: public void setFooterComponentAt(int column, HtmlComponent comp) {
2411: setFooterComponentAt(column, comp, null);
2412: }
2413:
2414: /**
2415: * Sets a footer component at a particular row position in the table. The
2416: * cell in the table will use properties specified in the props argument.
2417: */
2418: public void setFooterComponentAt(int column, HtmlComponent comp,
2419: HtmlTableCellProperties props) {
2420: if (column < 0)
2421: return;
2422:
2423: if (column >= _footerComponents.size())
2424: _footerComponents.setSize(column + 1);
2425:
2426: TwoObjectContainer cont = new TwoObjectContainer(comp, props);
2427:
2428: _footerComponents.setElementAt(cont, column);
2429:
2430: if (comp != null)
2431: comp.setParent(this );
2432:
2433: }
2434:
2435: /**
2436: * Sets all the footer components on a particular row in the table. If you
2437: * want to use HtmlTableCellProperties you will have to use
2438: * setFooterComponentAt(int,HtmlComponent,HtmlTableCellProperties)
2439: */
2440: public void setFooterComponents(HtmlComponent comp[]) {
2441: for (int colIndex = 0; colIndex < comp.length; colIndex++) {
2442: setFooterComponentAt(colIndex, comp[colIndex], null);
2443: }
2444: }
2445:
2446: /**
2447: * Sets all the footer components on a particular row in the table. If you
2448: * want to use HtmlTableCellProperties pass an array of
2449: * HtmlTableCellProperties with the ones that do not need cell props it as
2450: * null.
2451: */
2452: public void setFooterComponents(HtmlComponent comp[],
2453: HtmlTableCellProperties props[]) {
2454: for (int colIndex = 0; colIndex < comp.length; colIndex++) {
2455: setFooterComponentAt(colIndex, comp[colIndex],
2456: props[colIndex]);
2457: }
2458: }
2459:
2460: /**
2461: * Sets whether the or not paging buttons will be generated images or
2462: * regular submit buttons.
2463: *
2464: * @deprecated Use setPageButonType
2465: */
2466: public void setGenImagesForPagingButtons(boolean gen) {
2467: if (gen)
2468: setPageButtonType(PAGE_BUTTON_TYPE_IMAGE);
2469: else
2470: setPageButtonType(PAGE_BUTTON_TYPE_SUBMIT);
2471: }
2472:
2473: /**
2474: * Sets a heading component at a particular row position in the table.
2475: */
2476: public void setHeadingComponentAt(int column, HtmlComponent comp) {
2477: setHeadingComponentAt(column, comp, null);
2478: }
2479:
2480: /**
2481: * Sets a heading component at a particular row position in the table. The
2482: * cell in the table will use properties specified in the props argument.
2483: */
2484: public void setHeadingComponentAt(int column, HtmlComponent comp,
2485: HtmlTableCellProperties props) {
2486: if (column < 0)
2487: return;
2488:
2489: if (column >= _headingComponents.size())
2490: _headingComponents.setSize(column + 1);
2491:
2492: TwoObjectContainer cont = new TwoObjectContainer(comp, props);
2493: // sr 04-19-2001_compLookUpHash.put(HEADING_COMP_HASH_KEY+
2494: // comp.getName(), comp);
2495:
2496: _headingComponents.setElementAt(cont, column);
2497:
2498: if (comp != null)
2499: comp.setParent(this );
2500:
2501: }
2502:
2503: /**
2504: * Sets all the heading components on a particular row in the table. If you
2505: * want to use HtmlTableCellProperties you wil have to use
2506: * setHeadingComponentAt(int,HtmlComponent,HtmlTableCellProperties)
2507: */
2508:
2509: public void setHeadingComponents(HtmlComponent comp[]) {
2510: for (int colIndex = 0; colIndex < comp.length; colIndex++) {
2511: setHeadingComponentAt(colIndex, comp[colIndex], null);
2512: }
2513: }
2514:
2515: /**
2516: * Sets all the heading components on a particular row in the table. If you
2517: * want to use HtmlTableCellProperties pass an array of
2518: * HtmlTableCellProperties with the ones that do not need cell props it as
2519: * null.
2520: */
2521:
2522: public void setHeadingComponents(HtmlComponent comp[],
2523: HtmlTableCellProperties props[]) {
2524: for (int colIndex = 0; colIndex < comp.length; colIndex++) {
2525: setHeadingComponentAt(colIndex, comp[colIndex],
2526: props[colIndex]);
2527: }
2528: }
2529:
2530: /**
2531: * This method set which font will be used for links created with addColumn.
2532: */
2533: public void setLinkFont(String font) {
2534: _linkFont = font;
2535: }
2536:
2537: /**
2538: * This method sets the maximum number of paging buttons to display.
2539: */
2540: public void setMaxPageButtons(int max) {
2541: _maxPageButtons = max;
2542: }
2543:
2544: /**
2545: * This method will scroll to the first row on the current selected page
2546: */
2547: public void setPage(int page) {
2548: _firstRowOnPage = page * _rowsPerPage;
2549: if (_maxPageButtons == 0)
2550: _firstSubmitButton = page;
2551: }
2552:
2553: /**
2554: * Adds a page break to this table for printing purposes (IE 5 and up only).
2555: */
2556: public void setPageBreak(boolean bAddPageBreak) {
2557:
2558: int iBrowserType = getPage().getBrowserType();
2559:
2560: //PageBreak works with IE 5 and up...
2561: if (iBrowserType != HtmlPageBase.BROWSER_MICROSOFT
2562: || (iBrowserType == HtmlPageBase.BROWSER_MICROSOFT && getPage()
2563: .getBrowserVersion() < 5))
2564: return;
2565:
2566: _bAddPageBreak = bAddPageBreak;
2567:
2568: if (bAddPageBreak) {
2569: if (_pageBreak == null) {
2570: _pageBreak = new HtmlStyle("", ".pagebreak",
2571: "page-break-before: always", getPage());
2572: // getPage().add(_pageBreak);
2573: }
2574: }
2575: }
2576:
2577: /**
2578: * add a page break style to the rows depening on the index Creation date:
2579: * (11/15/01 1:40:29 PM)
2580: *
2581: * @param idx
2582: * int
2583: */
2584: public void setPageBreakIndex(int idx) {
2585: _iPageBreakIndex = idx;
2586: }
2587:
2588: /**
2589: * This method sets the background color for the page button generated image
2590: */
2591: public void setPagingButtonBackgroundColor(Color c) {
2592: _backgroundColor = c;
2593: }
2594:
2595: /**
2596: * This method sets the bottom and right border color for the page button
2597: * generated image
2598: */
2599: public void setPagingButtonBottomRightColor(Color c) {
2600: _bottomRightBorder = c;
2601: }
2602:
2603: /**
2604: * This method sets the Display Style for a generated image button. Valid
2605: * Values are PAGE_BUTTON_STYLE_RECTANGLE and PAGE_BUTTON_STYLE_OVAL
2606: */
2607: public void setPagingButtonDisplayStyle(String style) {
2608: _style = style;
2609: }
2610:
2611: /**
2612: * This method sets the font used for dynamically generated page button
2613: * images.
2614: */
2615: public void setPagingButtonFont(Font f) {
2616: _buttonFont = f;
2617: }
2618:
2619: /**
2620: * This method sets the height used for page button images
2621: */
2622: public void setPagingButtonHeight(int height) {
2623: _height = height;
2624: }
2625:
2626: /**
2627: * Sets the background color for the heading band
2628: */
2629: public void setHeadingBackgroundColor(String value) {
2630: _defaultHeadingBackground = value;
2631: }
2632:
2633: /**
2634: * Sets the background color for rows in the data table. Rows can alternate
2635: * in color and this one sets the second color.
2636: */
2637: public void setRowBackgroundColor2(String value) {
2638: _defaultRowBackground2 = value;
2639: }
2640:
2641: /**
2642: * Sets the background color for rows in the data table. Rows can alternate
2643: * in color and this one sets the second color.
2644: */
2645: public void setRowBackgroundColor1(String value) {
2646: _defaultRowBackground1 = value;
2647: }
2648:
2649: /**
2650: * Sets a row component at a particular row position in the table.
2651: */
2652: public void setRowComponentAt(int column, HtmlComponent comp) {
2653: setRowComponentAt(column, comp, null);
2654: }
2655:
2656: /**
2657: * Sets a row component at a particular row position in the table. The cell
2658: * in the table will use properties specified in the props argument.
2659: */
2660: public void setRowComponentAt(int column, HtmlComponent comp,
2661: HtmlTableCellProperties props) {
2662: if (column < 0)
2663: return;
2664:
2665: if (column >= _rowComponents.size())
2666: _rowComponents.setSize(column + 1);
2667:
2668: TwoObjectContainer cont = new TwoObjectContainer(comp, props);
2669:
2670: _rowComponents.setElementAt(cont, column);
2671:
2672: if (comp != null) {
2673: comp.setParent(this );
2674: if (_rowHighlighter == null) {
2675: if (comp instanceof HtmlRowHighlighter)
2676: _rowHighlighter = (HtmlRowHighlighter) comp;
2677: else if (comp instanceof HtmlContainer)
2678: _rowHighlighter = findHighlighterInContainer((HtmlContainer) comp);
2679: }
2680: }
2681: }
2682:
2683: private HtmlRowHighlighter findHighlighterInContainer(HtmlContainer cont) {
2684: Enumeration enum = cont.getComponents();
2685: while (enum.hasMoreElements()) {
2686: HtmlComponent comp = (HtmlComponent) enum.nextElement();
2687: if (comp instanceof HtmlRowHighlighter)
2688: return (HtmlRowHighlighter) comp;
2689: else if (comp instanceof HtmlContainer) {
2690: HtmlRowHighlighter r = findHighlighterInContainer((HtmlContainer) comp);
2691: if (r != null)
2692: return r;
2693: }
2694: }
2695: return null;
2696: }
2697:
2698: /**
2699: * Sets a row component at a particular row position in the table.
2700: */
2701: public void setRowComponents(HtmlComponent comp[]) {
2702: for (int colIndex = 0; colIndex < comp.length; colIndex++) {
2703: setRowComponentAt(colIndex, comp[colIndex], null);
2704: }
2705:
2706: }
2707:
2708: /**
2709: * Sets a row component at a particular row position in the table. If you
2710: * want to use HtmlTableCellProperties pass an array of
2711: * HtmlTableCellProperties with the ones that do not need cell props it as
2712: * null.
2713: */
2714: public void setRowComponents(HtmlComponent comp[],
2715: HtmlTableCellProperties props[]) {
2716: for (int colIndex = 0; colIndex < comp.length; colIndex++) {
2717: setRowComponentAt(colIndex, comp[colIndex], props[colIndex]);
2718: }
2719: }
2720:
2721: /**
2722: * This method sets the number of rows to display on one page of output. A
2723: * value <= 0 will indicate no limit to the number of rows displayed.
2724: */
2725: public void setRowsPerPage(int rowsPerPage) {
2726: if (rowsPerPage <= 0)
2727: _rowsPerPage = MAX_ROW_LIMIT;
2728: else
2729: _rowsPerPage = rowsPerPage;
2730: }
2731:
2732: /**
2733: * This method sets the anchor to scroll to when a paging button on the
2734: * table is clicked. Set it to null for the top of the table.
2735: */
2736: public void setScrollAnchor(String anchor) {
2737: _scrollAnchor = anchor;
2738: }
2739:
2740: /**
2741: * Sets whether the datastore will build scrolling javascript when the user
2742: * clicks on a column heading to sort or a paging button.
2743: */
2744: public void setScrollOnClickSort(boolean scroll) {
2745: _scrollOnSort = scroll;
2746: }
2747:
2748: /**
2749: * Sets whether rows per page selector is visible.
2750: */
2751: public void setSelRowsPerPage(boolean sel) {
2752: _rowPerPageSel = sel;
2753: }
2754:
2755: /**
2756: * This method sets the size option for the table and each cell in it. Valid
2757: * return values are SIZE_PIXELS or SIZE_PERCENT.
2758: */
2759: public void setSizeOption(int option) {
2760: _sizeOption = option;
2761: }
2762:
2763: /**
2764: * This method sets the size option for the table and each cell in it. Valid
2765: * return values are SIZE_PIXELS or SIZE_PERCENT.
2766: */
2767: public void setSummaryRowText(String summaryRowText) {
2768: _summaryRowText = summaryRowText;
2769: }
2770:
2771: /**
2772: * This method sets the property theme for the component.
2773: *
2774: * @param theme
2775: * The theme to use.
2776: */
2777: public void setTheme(String theme) {
2778:
2779: Props prop = getPage().getPageProperties();
2780:
2781: _border = prop.getThemeIntProperty(theme,
2782: Props.DATA_TABLE_BORDER);
2783: _bgColor = prop.getThemeProperty(theme,
2784: Props.DATA_TABLE_BACKGROUND_COLOR);
2785: _cellPadding = prop.getThemeIntProperty(theme,
2786: Props.DATA_TABLE_CELLPADDING);
2787: _cellSpacing = prop.getThemeIntProperty(theme,
2788: Props.DATA_TABLE_CELLSPACING);
2789:
2790: _defaultHeadingBackground = prop.getThemeProperty(theme,
2791: Props.DATA_TABLE_HEADING_BACKGROUND_COLOR);
2792: _defaultRowBackground1 = prop.getThemeProperty(theme,
2793: Props.DATA_TABLE_ROW_BACKGROUND_COLOR_1);
2794: _defaultRowBackground2 = prop.getThemeProperty(theme,
2795: Props.DATA_TABLE_ROW_BACKGROUND_COLOR_2);
2796:
2797: _rowsPerPage = prop.getThemeIntProperty(theme,
2798: Props.DATA_TABLE_ROWS_PER_PAGE);
2799: if (_rowsPerPage <= 0)
2800: _rowsPerPage = 20;
2801:
2802: _maxPageButtons = prop.getThemeIntProperty(theme,
2803: Props.DATA_TABLE_MAX_PAGE_BUTTONS);
2804: if (_maxPageButtons <= 0)
2805: _maxPageButtons = 10;
2806:
2807: String cs = prop.getThemeProperty(theme,
2808: Props.DATA_TABLE_CLICK_SORT);
2809: _clickSort = (cs == null ? false : cs.toUpperCase().equals(
2810: "TRUE"));
2811:
2812: _scrollOnSort = prop.getThemeBooleanProperty(theme,
2813: Props.DATA_TABLE_SCROLL_ON_CLICK_SORT, true);
2814:
2815: //properties for paging buttons
2816: _fontString = prop.getThemeProperty(theme,
2817: Props.SUBMIT_IMAGE_FONT_FACE);
2818: if (_fontString == null)
2819: _fontString = "Helvetica";
2820: _fontSize = prop.getThemeIntProperty(theme,
2821: Props.SUBMIT_IMAGE_FONT_SIZE);
2822: if (_fontSize == -1)
2823: _fontSize = 12;
2824:
2825: _height = prop.getThemeIntProperty(theme,
2826: Props.SUBMIT_IMAGE_DEFAULT_HEIGHT);
2827:
2828: Color c = prop.getThemeColorProperty(theme,
2829: Props.SUBMIT_IMAGE_TEXT_COLOR);
2830: if (c != null)
2831: _textColor = c;
2832:
2833: c = prop.getThemeColorProperty(theme,
2834: Props.SUBMIT_IMAGE_BACKGROUND_COLOR);
2835: if (c != null)
2836: _backgroundColor = c;
2837:
2838: c = prop.getThemeColorProperty(theme,
2839: Props.SUBMIT_IMAGE_TOPLEFT_BORDER_COLOR);
2840: if (c != null)
2841: _topLeftBorder = c;
2842:
2843: c = prop.getThemeColorProperty(theme,
2844: Props.SUBMIT_IMAGE_BOTTOMRIGHT_BORDER_COLOR);
2845: if (c != null)
2846: _bottomRightBorder = c;
2847:
2848: c = prop.getThemeColorProperty(theme,
2849: Props.SUBMIT_IMAGE_TRANSPARENT_COLOR);
2850: if (c != null)
2851: _transparentColor = c;
2852:
2853: String style = prop.getThemeProperty(theme,
2854: Props.SUBMIT_IMAGE_STYLE);
2855: if (style != null) {
2856: if (style.toUpperCase().equals(PAGE_BUTTON_STYLE_OVAL))
2857: _style = PAGE_BUTTON_STYLE_OVAL;
2858: else
2859: _style = PAGE_BUTTON_STYLE_RECTANGLE;
2860: }
2861:
2862: String rowSelectRenderer = prop.getThemeProperty(theme,
2863: Props.DATA_TABLE_PAGE_SELECT_RENDERER);
2864: if (rowSelectRenderer != null)
2865: setPageSelectRenderer(rowSelectRenderer);
2866:
2867: String rowsPerPageRenderer = prop.getThemeProperty(theme,
2868: Props.DATA_TABLE_ROWS_PER_PAGE_RENDERER);
2869: if (rowsPerPageRenderer != null)
2870: setRowsPerPageRenderer(rowsPerPageRenderer);
2871:
2872: _theme = theme;
2873: }
2874:
2875: /**
2876: * If the image is dynamically generated, this method will indicate whether
2877: * or not the Objectstore should cache it.
2878: */
2879: public void setUseCache(boolean useCache) {
2880: _useCache = useCache;
2881: }
2882:
2883: /**
2884: * Sets whether the or not paging buttons will be links or submit.
2885: *
2886: * @deprecated Use setPageButtonType()
2887: */
2888: public void setUseLinksForPagingButtons(boolean gen) {
2889: if (gen)
2890: setPageButtonType(PAGE_BUTTON_TYPE_TEXT);
2891: else
2892: setPageButtonType(PAGE_BUTTON_TYPE_SUBMIT);
2893: }
2894:
2895: /**
2896: * This method sets the minimum width of the table in either pixels or
2897: * percent depending on size option.
2898: */
2899: public void setWidth(int width) {
2900: _containerWidth = width;
2901: }
2902:
2903: /**
2904: * This method was created in VisualAge.
2905: *
2906: * @param comp
2907: * com.salmonllc.html.HtmlComponent
2908: */
2909: protected void sortOnComponent(HtmlComponent comp, int colNo)
2910: throws Exception {
2911: if (colNo == _sortColumn) {
2912: if (_sortDir == DataStore.SORT_ASC)
2913: _sortDir = DataStore.SORT_DES;
2914: else
2915: _sortDir = DataStore.SORT_ASC;
2916: } else
2917: _sortDir = DataStore.SORT_ASC;
2918: _sortColumn = colNo;
2919: int col = 0, dir = 0;
2920: if (comp instanceof HtmlFormComponent) {
2921: int dsCol = ((HtmlFormComponent) comp).getColumnNumber();
2922: col = dsCol;
2923: dir = _sortDir;
2924: } else if (comp instanceof HtmlText) {
2925: DataStoreEvaluator eval = ((HtmlText) comp)
2926: .getExpressionEvaluator();
2927: String exp = eval.getExpression();
2928: int index = -1;
2929: if (exp != null)
2930: index = _ds.getColumnIndex(exp);
2931: if (index > -1) {
2932: col = index;
2933: dir = _sortDir;
2934: } else {
2935: if (_breakColumns != null) {
2936: Object cols[] = new Object[_breakColumns.length + 1];
2937: int dirs[] = new int[_breakColumns.length + 1];
2938: for (int i = 0; i < _breakColumns.length; i++) {
2939: cols[i] = new Integer(_breakColumns[i]);
2940: dirs[i] = DataStore.SORT_ASC;
2941: }
2942: cols[_breakColumns.length] = eval;
2943: dirs[_breakColumns.length] = _sortDir;
2944: _ds.sort(cols, dirs);
2945: } else
2946: _ds.sort(eval, _sortDir);
2947: return;
2948: }
2949: }
2950: if (_breakColumns != null) {
2951: int cols[] = new int[_breakColumns.length + 1];
2952: int dirs[] = new int[_breakColumns.length + 1];
2953: for (int i = 0; i < _breakColumns.length; i++) {
2954: cols[i] = _breakColumns[i];
2955: dirs[i] = DataStore.SORT_ASC;
2956: }
2957: cols[_breakColumns.length] = col;
2958: dirs[_breakColumns.length] = dir;
2959: _ds.sort(cols, dirs);
2960: } else {
2961: if (_baseSortColumn == -1)
2962: _ds.sort(col, dir);
2963: else {
2964: int cols[] = { col, _baseSortColumn };
2965: int dirs[] = { dir, _baseSortDir };
2966: _ds.sort(cols, dirs);
2967: }
2968: }
2969: }
2970:
2971: /**
2972: * A true false value indicating whether the heading band should be
2973: * reprinted after a page break
2974: */
2975:
2976: public boolean getRepeatHeadingsAfterBreak() {
2977: return _repeatHeadingsAfterBreak;
2978: }
2979:
2980: /**
2981: * A true false value indicating whether the heading band should be
2982: * reprinted after a page break
2983: */
2984: public void setRepeatHeadingsAfterBreak(
2985: boolean repeatHeadingsAfterBreak) {
2986: _repeatHeadingsAfterBreak = repeatHeadingsAfterBreak;
2987: }
2988:
2989: /**
2990: * Sets the type of paging buttons for the data table. Valid Types are
2991: * PAGE_BUTTON_TYPE_SUBMIT, PAGE_BUTTON_TYPE_IMAGE, PAGE_BUTTON_TYPE_TEXT,
2992: * PAGE_BUTTON_TYPE_SCROLLBAR
2993: */
2994:
2995: public void setPageButtonType(int type) {
2996: _pageButtonType = type;
2997: if (_pageButtonType == PAGE_BUTTON_TYPE_IMAGE)
2998: getPage().registerImageGenerator(getFullName(), this );
2999: else if (_pageButtonType == PAGE_BUTTON_TYPE_SCROLLBAR)
3000: setRowsPerPage(-1);
3001: }
3002:
3003: /**
3004: * Sets a new render to draw the HTML for the table page selector
3005: */
3006: public void setPageSelectRenderer(DataTablePageSelectRenderer r) {
3007: _pageSelectRenderer = r;
3008: }
3009:
3010: /**
3011: * Sets a new render to draw the HTML for the rows per page selector
3012: */
3013: public void setRowsPerPageRenderer(DataTableRowsPerPageRenderer r) {
3014: _rowsPerPageRenderer = r;
3015: }
3016:
3017: /**
3018: * Sets a new render to draw the HTML for the table page selector, given the
3019: * class name for the renderer
3020: */
3021: public void setPageSelectRenderer(String r) {
3022: if (r != null) {
3023: if (r.equalsIgnoreCase("null")
3024: || r.equalsIgnoreCase("default")) {
3025: _pageSelectRenderer = null;
3026: return;
3027: }
3028: }
3029: try {
3030: Class c = Class.forName(r);
3031: _pageSelectRenderer = (DataTablePageSelectRenderer) c
3032: .newInstance();
3033: } catch (Exception e) {
3034: MessageLog.writeErrorMessage("setRowSelectRenderer", e,
3035: this );
3036: }
3037: }
3038:
3039: /**
3040: * Sets a new render to draw the HTML for the rows per page selector
3041: */
3042: public void setRowsPerPageRenderer(String r) {
3043: if (r != null) {
3044: if (r.equalsIgnoreCase("null")
3045: || r.equalsIgnoreCase("default")) {
3046: _rowsPerPageRenderer = null;
3047: return;
3048: }
3049: }
3050: try {
3051: Class c = Class.forName(r);
3052: _rowsPerPageRenderer = (DataTableRowsPerPageRenderer) c
3053: .newInstance();
3054: } catch (Exception e) {
3055: MessageLog.writeErrorMessage("setRowsPerPageRenderer", e,
3056: this );
3057: }
3058: }
3059:
3060: /**
3061: * Gets the type of paging buttons for the data table. Valid Types are
3062: * PAGE_BUTTON_TYPE_SUBMIT, PAGE_BUTTON_TYPE_IMAGE, PAGE_BUTTON_TYPE_TEXT
3063: */
3064:
3065: public int getPageButtonType() {
3066: return _pageButtonType;
3067: }
3068:
3069: /**
3070: * Gets a vector containing the components in the data table heading.
3071: */
3072: protected Vector getHeadingComponents() {
3073: return _headingComponents;
3074: }
3075:
3076: /**
3077: * Gets a vector containing the components in the data table footer.
3078: */
3079: protected Vector getFooterComponents() {
3080: return _footerComponents;
3081: }
3082:
3083: /**
3084: * Gets a vector containing the components in a data table row.
3085: */
3086: protected Vector getRowComponents() {
3087: return _rowComponents;
3088: }
3089:
3090: /**
3091: * @return the default style sheet class for table rows
3092: */
3093: public String getRowStyleClassName1() {
3094: return _defaultRowStyleClassName1;
3095: }
3096:
3097: /**
3098: * @return the default style sheet class for table alternate rows
3099: */
3100: public String getRowStyleClassName2() {
3101: return _defaultRowStyleClassName2;
3102: }
3103:
3104: /**
3105: * @param string
3106: * sets the default style sheet class for table rows
3107: */
3108: public void setRowStyleClassName1(String string) {
3109: _defaultRowStyleClassName1 = string;
3110: }
3111:
3112: /**
3113: * @param string
3114: * sets the default style sheet class for table alternate rows
3115: */
3116: public void setRowStyleClassName2(String string) {
3117: _defaultRowStyleClassName2 = string;
3118: }
3119:
3120: /**
3121: * @return the default style sheet class for heading rows
3122: */
3123: public String getHeadingStyleClassName() {
3124: return _defaultHeadingStyleClassName;
3125: }
3126:
3127: /**
3128: * @param string
3129: * sets the default style sheet class for heading rows
3130: */
3131: public void setHeadingStyleClassName(String string) {
3132: _defaultHeadingStyleClassName = string;
3133: }
3134:
3135: /**
3136: * @return Returns true if the component will generate THEAD, TBODY and
3137: * TFOOT tags around the sections of the table.
3138: */
3139: public boolean getGenTHeadAndBody() {
3140: return _genTHeadAndBody;
3141: }
3142:
3143: /**
3144: * @param true
3145: * if the component will generate THEAD, TBODY and TFOOT tags
3146: * around the sections of the table.
3147: */
3148: public void setGenTHeadAndBody(boolean genTHeadAndBody) {
3149: _genTHeadAndBody = genTHeadAndBody;
3150: }
3151:
3152: /**
3153: * @return Returns the table height (used for tables with
3154: * pageButtonType=PAGE_BUTTON_TYPE_SCROLLBAR).
3155: */
3156: public int getTableHeight() {
3157: return _tableHeight;
3158: }
3159:
3160: /**
3161: * @param Sets
3162: * the table height (used for tables with
3163: * pageButtonType=PAGE_BUTTON_TYPE_SCROLLBAR).
3164: */
3165: public void setTableHeight(int tableHeight) {
3166: _tableHeight = tableHeight;
3167: }
3168: }
|