public int doStartTag ( ) throws JspException { ServletRequest request = pageContext . getRequest ( ) ; _tableRenderer = TagRenderingBase . Factory . getRendering ( TagRenderingBase . TABLE_TAG , request ) ; _trRenderer = TagRenderingBase . Factory . getRendering ( TagRenderingBase . TR_TAG , request ) ; _tdRenderer = TagRenderingBase . Factory . getRendering ( TagRenderingBase . TD_TAG , request ) ; _htmlConstantRendering = TagRenderingBase . Factory . getConstantRendering ( request ) ; _sb = new InternalStringBuilder ( 1024 ) ; _appender = new StringBuilderRenderAppender ( _sb ) ; Object source = evaluateDataSource ( ) ; if ( hasErrors ( ) ) return SKIP_BODY ; if ( source != null ) { Iterator iterator = IteratorFactory . createIterator ( source ) ; if ( iterator == null ) { LOGGER . info ( "CellRepeater: The data structure from which to create an iterator is null." ) ; iterator = Collections . EMPTY_LIST . iterator ( ) ; } if ( iterator != null ) { _dataList = new ArrayList ( ) ; while ( iterator . hasNext ( ) ) { _dataList . add ( iterator . next ( ) ) ; } } } if ( _rows == DIMENSION_DEFAULT_VALUE || _columns == DIMENSION_DEFAULT_VALUE ) { /* try to guess the dimensions of the table */ if ( _dataList != null && _dataList . size ( ) > 0 ) { guessDimensions ( _dataList ) ; if ( hasErrors ( ) ) return SKIP_BODY ; } /* the size of the data set isn't guessable */ else { _valid = false ; return SKIP_BODY ; } } /* check to make sure the rows / columns are actually valid before starting to render */ if ( _rows <= 0 ) { String msg = Bundle . getString ( "Tags_CellRepeater_invalidRowValue" , new Object [ ] { getTagName ( ) , new Integer ( _rows ) } ) ; registerTagError ( msg , null ) ; } if ( _columns <= 0 ) { String msg = Bundle . getString ( "Tags_CellRepeater_invalidColumnValue" , new Object [ ] { getTagName ( ) , new Integer ( _columns ) } ) ; registerTagError ( msg , null ) ; } if ( hasErrors ( ) ) return SKIP_BODY ; openTableTag ( _appender , _tableState ) ; _currentRow = 0 ; _currentColumn = 0 ; DataAccessProviderStack . addDataAccessProvider ( this , pageContext ) ; _containerInPageContext = true ; boolean haveItem = ensureItem ( 0 , _dataList ) ; if ( haveItem ) { openRowTag ( _appender , _trState ) ; openCellTag ( _appender , _currentColumn ) ; return EVAL_BODY_BUFFERED ; } else { // special case -- with no items, render the entire table here for ( int i = 0 ; i < _rows ; i ++ ) { openRowTag ( _appender , _trState ) ; for ( int j = 0 ; j < _columns ; j ++ ) { openCellTag ( _appender , computeStyleIndex ( i , j ) ) ; _htmlConstantRendering . NBSP ( _appender ) ; closeCellTag ( _appender ) ; } closeRowTag ( _appender ) ; _appender . append ( "\n" ) ; } _currentRow = _rows ; _currentColumn = _columns ; return SKIP_BODY ; } }
Prepare to render the dataset that was specified in the dataSource attribute . The dataSource expression is evaluated and the table s dimensions are computed . If there is no data in the dataset but the rows and columns attributes were specified an empty table of the given dimensions is rendered .