You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by cr...@apache.org on 2006/11/04 00:03:27 UTC

svn commit: r471039 - in /beehive/branches/v1.0.2/netui: src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/pager/ src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/ src/tags-databinding/org/apache/bee...

Author: crogers
Date: Fri Nov  3 15:03:26 2006
New Revision: 471039

URL: http://svn.apache.org/viewvc?view=rev&rev=471039
Log:
For v1.0.2 branch... This revision rolls back the incomplete work on the partial data set support in svn revision 431515 as well as the "checkpoint work" to the PagedDataSet class, etc. from revision 415150, and unit test change in 415202.

Tests: NetUI BVT (WinXP pass)


Removed:
    beehive/branches/v1.0.2/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/PartialDataSetTest.java
    beehive/branches/v1.0.2/netui/test/webapps/drt/testRecorder/tests/DataGridShowAll.xml
    beehive/branches/v1.0.2/netui/test/webapps/drt/testRecorder/tests/DataGridSimplePartialDataSet.xml
    beehive/branches/v1.0.2/netui/test/webapps/drt/web/databinding/datagrid/misc/showAll.jsp
    beehive/branches/v1.0.2/netui/test/webapps/drt/web/databinding/datagrid/pager/partialdata/
Modified:
    beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/pager/PagerModel.java
    beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/DataGridTagModel.java
    beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/rendering/cell/SpanCellDecorator.java
    beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/util/PagedDataSet.java
    beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/ConfigurePager.java
    beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/DataGrid.java
    beehive/branches/v1.0.2/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/DataGridTestUtil.java
    beehive/branches/v1.0.2/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml

Modified: beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/pager/PagerModel.java
URL: http://svn.apache.org/viewvc/beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/pager/PagerModel.java?view=diff&rev=471039&r1=471038&r2=471039
==============================================================================
--- beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/pager/PagerModel.java (original)
+++ beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/pager/PagerModel.java Fri Nov  3 15:03:26 2006
@@ -55,16 +55,10 @@
     public static final int DEFAULT_PAGE_SIZE = 10;
     public static final int DEFAULT_ROW = 0;
 
-    private boolean _partialDataSet = false;
-    private boolean _showAll = false;
-    
     private String _pageHref = null;
     private String _pageAction = null;
-    private Integer _offset = null;
     private Integer _currentRow = null;
-
     private Integer _dataSetSize = null;
-
     private Integer _explicitPageSize = null;
     private Integer _defaultPageSize = null;
 
@@ -75,40 +69,6 @@
         _currentRow = new Integer(DEFAULT_ROW);
     }
 
-    public boolean isPartialDataSet() {
-        return _partialDataSet;
-    }
-
-    public void setPartialDataSet(boolean partialDataSet) {
-        _partialDataSet = partialDataSet;
-    }
-
-    public boolean isShowAll() {
-        return _showAll;
-    }
-
-    public void setShowAll(boolean showAll) {
-        _showAll = showAll;
-    }
-
-    /**
-     * Get the offset index.  An offset is used when rendering partial data sets as the actual
-     * data set used to render a data grid may not contain all of the rows for that data grid.
-     * The offset is the absolute number of rows "into" the data set being currently rendered.
-     * @return the offset
-     */
-    public int getOffset() {
-        return _offset != null ? _offset.intValue() : 0;
-    }
-
-    /**
-     * Set the offset index.
-     * @param offset the offset index
-     */
-    public void setOffset(int offset) {
-        _offset = new Integer(offset);
-    }
-
     /**
      * Get the action used when building URLs for navigating to another page.
      * @return the action name or <code>null</code> if no action name is set
@@ -175,7 +135,9 @@
      * @return the size
      */
     public int getDataSetSize() {
-        return _dataSetSize == null ? 0 : _dataSetSize.intValue();
+        if(_dataSetSize == null)
+            return 0;
+        else return _dataSetSize.intValue();
     }
 
     /**
@@ -206,15 +168,15 @@
     }
 
     /**
-     * Get the current page number given a current row and page size.  The page number is zero-based and should
-     * generally be incremented by one to display the current page.
+     * Get the page number given the current page size and current row.  The page number is zero based and should be
+     * adjusted by one when being displayed to users.
      * @return the page number
      */
     public int getPage() {
+        int row = getRow();
+        assert row % getPageSize() == 0 : "Invalid current row \"" + row + "\" for page size \"" + getPageSize() + "\"";
         assert getPageSize() > 0;
-        assert getRow() % getPageSize() == 0 : "Invalid current row \"" + getRow() + "\" for page size \"" + getPageSize() + "\"";
-        
-        return getRow() / getPageSize();
+        return row / getPageSize();
     }
 
     /**
@@ -236,21 +198,20 @@
      * @return the current row
      */
     public int getRow() {
-        int row = DEFAULT_ROW;
-
-        // current row is specified
         if(_currentRow != null) {
-            row = _currentRow.intValue();
+            int row = _currentRow.intValue();
 
-            // the index of the last row if the current row is past the end of the data set
+            /* if the row is out of range, simply adjust to the last row */
             if(_dataSetSize != null && (row > _dataSetSize.intValue()))
                 row = _dataSetSize.intValue();
 
-            if(row % getPageSize() != 0)
-                row = row - (row % getPageSize());
+            if(row % getPageSize() != 0) {
+                int adjustedPage = row - (row % getPageSize());
+                return adjustedPage;
+            }
+            else return row;
         }
-
-        return row;
+        else return DEFAULT_ROW;
     }
 
     /**
@@ -371,7 +332,7 @@
      */
     public int getPreviousPage() {
         int previousPageRow = getRowForPreviousPage();
-        return previousPageRow == -1 ? previousPageRow : (previousPageRow / getPageSize());
+        return previousPageRow == -1 ? previousPageRow : (int)(previousPageRow / getPageSize());
     }
 
     /**
@@ -379,7 +340,7 @@
      * @return the next page
      */
     public int getNextPage() {
-        return (getRowForNextPage() / getPageSize());
+        return (int)(getRowForNextPage() / getPageSize());
     }
 
     /**
@@ -410,9 +371,7 @@
               12 / 2: 0-1, 2-3, 4-5, 6-7, 8-9, 10-11, 12-13 _lastRow=10
               12 / 5: 0-4, 5-9, 10-14 _lastRow=5
              */
-            int lastRow =
-                getPageSize() * 
-                (int)Math.floor((double)(_dataSetSize.intValue()-1) / (double)getPageSize());
+            int lastRow = getPageSize() * (int)Math.floor((double)(_dataSetSize.intValue()-1) / (double)getPageSize());
             return new Integer(lastRow);
         }
         else return null;

Modified: beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/DataGridTagModel.java
URL: http://svn.apache.org/viewvc/beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/DataGridTagModel.java?view=diff&rev=471039&r1=471038&r2=471039
==============================================================================
--- beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/DataGridTagModel.java (original)
+++ beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/DataGridTagModel.java Fri Nov  3 15:03:26 2006
@@ -213,6 +213,7 @@
     public void setDataSet(PagedDataSet dataSet) {
         /* todo: would be nice to address this side-effect outside of the setter */
         _dataSet = dataSet;
+        _dataGridState.getPagerModel().setDataSetSize(_dataSet.getSize());
     }
 
     /**

Modified: beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/rendering/cell/SpanCellDecorator.java
URL: http://svn.apache.org/viewvc/beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/rendering/cell/SpanCellDecorator.java?view=diff&rev=471039&r1=471038&r2=471039
==============================================================================
--- beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/rendering/cell/SpanCellDecorator.java (original)
+++ beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/rendering/cell/SpanCellDecorator.java Fri Nov  3 15:03:26 2006
@@ -28,7 +28,6 @@
 import org.apache.beehive.netui.databinding.datagrid.runtime.util.JspUtil;
 import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender;
 import org.apache.beehive.netui.tags.rendering.TagRenderingBase;
-import org.apache.beehive.netui.tags.rendering.ConstantRendering;
 
 /**
  *
@@ -37,7 +36,7 @@
     extends CellDecorator {
 
     public void decorate(JspContext jspContext, AbstractRenderAppender appender, CellModel cellModel)
-        throws CellDecoratorException {
+            throws CellDecoratorException {
 
         assert cellModel instanceof SpanCellModel;
         SpanCellModel spanCellModel = (SpanCellModel)cellModel;
@@ -46,9 +45,7 @@
         TagRenderingBase span = TagRenderingBase.Factory.getRendering(TagRenderingBase.SPAN_TAG, request);
 
         String formatted = cellModel.formatText(spanCellModel.getValue());
-        if(formatted == null)
-            formatted = "";
-        
+
         span.doStartTag(appender, spanCellModel.getSpanState());
         appender.append(formatted);
         span.doEndTag(appender);

Modified: beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/util/PagedDataSet.java
URL: http://svn.apache.org/viewvc/beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/util/PagedDataSet.java?view=diff&rev=471039&r1=471038&r2=471039
==============================================================================
--- beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/util/PagedDataSet.java (original)
+++ beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/util/PagedDataSet.java Fri Nov  3 15:03:26 2006
@@ -18,173 +18,103 @@
  */
 package org.apache.beehive.netui.databinding.datagrid.runtime.util;
 
-import java.util.Collections;
 import java.util.Iterator;
-import java.util.LinkedList;
+import java.util.ArrayList;
+import java.util.Collections;
+
+import org.apache.beehive.netui.util.logging.Logger;
 
 /**
- * This is an internal class used by the data grid to support paging through a data set.
+ *
  */
 public final class PagedDataSet
     implements Iterator {
 
-    /*
-      todo: need to support the following features:
-      x rendering the entire data set (show all rows)
-      x rendering a "page size" number of items starting from zero (partial data sets)
-      - adding a ceiling on the number of items to render (max row)
-    */
-
-    private boolean _initialized = false;
-    private boolean _partial = false;
-    private boolean _showAll = false;
-    private int _currentRow = -1;
-
-    private Integer _size;
-    private Integer _firstRow;
-    private Integer _lastRow;
-    private Integer _maxRow;
-    private Integer _pageSize;
+    private static final Logger LOGGER = Logger.getInstance(PagedDataSet.class);
+
+    private boolean _completedBootstrap = false;
+    private int _dataSetSize = 0;
+    private int _currentIndex = -1;
+    private int _startWindow = -1;
+    private int _endWindow = -1;
 
     private String _dataSource = null;
-    private Iterator _iterator = null;
+    private ArrayList _list = null;
+    private Iterator _dataSetIterator = null;
     private Object _currentItem = null;
 
     public PagedDataSet(String dataSource, Iterator iterator) {
         _dataSource = dataSource;
 
         if(iterator == null)
-            _iterator = Collections.EMPTY_LIST.iterator();
-        else _iterator = iterator;
-    }
-
-    public boolean isPartial() {
-        return _partial;
-    }
-
-    public void setPartial(boolean partial) {
-        _partial = partial;
-    }
-
-    public void setFirstRow(int firstRow) {
-        _firstRow = new Integer(firstRow);
-    }
-
-    public void setPageSize(int pageSize) {
-        _pageSize = new Integer(pageSize);
-    }
-
-    public void setSize(int size) {
-        _size = new Integer(size);
-    }
-
-    public void setMaxRow(int maxRow) {
-        _maxRow = new Integer(maxRow);
+            _dataSetIterator = Collections.EMPTY_LIST.iterator();
+        else
+            _dataSetIterator = iterator;
+
+        LOGGER.debug("iterator type: " + _dataSetIterator.getClass().getName());
+
+        /* todo: would be nice to have a limit here so that this isn't needed in order to find the end of the data set */
+        _list = new ArrayList();
+        while(_dataSetIterator.hasNext()) {
+            _list.add(_dataSetIterator.next());
+            _dataSetSize++;
+        }
+        _dataSetIterator = _list.iterator();
     }
 
-    public void setShowAll(boolean showAll) {
-        _showAll = showAll;
+    public void createWindow(int startWindow, int windowSize) {
+        /* todo: error checking */
+        _startWindow = startWindow;
+        /* the size of the window is inclusive, so remove one from the total size */
+        _endWindow = _startWindow + windowSize - 1;
     }
 
-    public int getSize() {
-        return _size.intValue();
-    }
+    public boolean hasNext() {
+        if(!_completedBootstrap && _startWindow > 0) {
 
-    /**
-     * Perform initializations on a PagedDataSet.  This method must be called before starting to use the
-     * {@link Iterator} functionality of this class.
-     */
-    public void initialize() {
-
-        assert _firstRow != null;
-        assert _pageSize != null;
-
-        // calculate the size of the data set
-        if(_size == null) {
-            int size = 0;
-            LinkedList list = new LinkedList();
-            while(_iterator.hasNext()) {
-                list.add(_iterator.next());
-                size++;
+            while(_dataSetIterator.hasNext() && (_currentIndex+1) != _startWindow) {
+                _dataSetIterator.next();
+                _currentIndex++;
             }
-            _size = new Integer(size);
-            _iterator = list.iterator();
-        }
-
-        assert _size != null;
-
-        // set the position of the first row in the interator
-        if(_partial) {
-            _currentRow = -1;
+            _completedBootstrap = true;
         }
-        else {
-            if(_firstRow.intValue() > 0) {
-                while(_iterator.hasNext() && (_currentRow +1 != _firstRow.intValue())) {
-                    _iterator.next();
-                    _currentRow++;
-                }
-            }
+        else if(_endWindow > -1 && (_currentIndex >= _endWindow)) {
+            LOGGER.debug("current index: " + _currentIndex + " _endRenderWindiw: " + _endWindow + " end data set: " + (_currentIndex >= _endWindow));
+            return false;
         }
 
-        // configure the stopping point for the iterator.
-        // display all rows
-        if(_showAll)
-            _lastRow = new Integer(_size.intValue() - 1);
-        // display all rows up to a maximum row limit
-        else if(_maxRow != null && (_maxRow.intValue() < _lastRow.intValue()))
-            _lastRow = _maxRow;
-        // display all rows for a given page size
-        else _lastRow = new Integer(_firstRow.intValue() + (_pageSize.intValue()-1));
+        boolean hasNext = _dataSetIterator.hasNext();
+        if(!hasNext) {
+            _currentIndex = -1;
+            _currentItem = null;
+        }
 
-        _initialized = true;
+        return hasNext;
     }
 
-    /* ---------------------------------------------------------------
-
-       org.apache.beehive.netui.script.IDataAccessProvider implementation
+    public Object next() {
+        _currentItem = _dataSetIterator.next();
+        _currentIndex++;
+        return _currentItem;
+    }
 
-       --------------------------------------------------------------- */
+    public void remove() {
+        throw new UnsupportedOperationException();
+    }
 
     public String getDataSource() {
         return _dataSource;
     }
 
-    public int getCurrentIndex() {
-        return _currentRow;
-    }
-
-    public Object getCurrentItem() {
-        return _currentItem;
+    public int getSize() {
+        return _dataSetSize;
     }
 
-    /* ---------------------------------------------------------------
-
-       java.util.Iterator implementation
-
-       --------------------------------------------------------------- */
-    public boolean hasNext() {
-        assert _initialized : "Iterating without having initialized";
-
-        // reached the end of the window to render
-        if(_lastRow != null && (_currentRow >= _lastRow.intValue()))
-            return false;
-
-        boolean hasNext = _iterator.hasNext();
-        if(!hasNext) {
-            _currentRow = -1;
-            _currentItem = null;
-        }
-
-        return hasNext;
+    public int getCurrentIndex() {
+        return _currentIndex;
     }
 
-    public Object next() {
-        _currentItem = _iterator.next();
-        _currentRow++;
+    public Object getCurrentItem() {
         return _currentItem;
     }
-
-    public void remove() {
-        throw new UnsupportedOperationException();
-    }
-}
\ No newline at end of file
+}

Modified: beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/ConfigurePager.java
URL: http://svn.apache.org/viewvc/beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/ConfigurePager.java?view=diff&rev=471039&r1=471038&r2=471039
==============================================================================
--- beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/ConfigurePager.java (original)
+++ beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/ConfigurePager.java Fri Nov  3 15:03:26 2006
@@ -61,12 +61,9 @@
     private static final String PAGER_FORMAT_FIRST_LAST_PREV_NEXT = "firstPrevNextLast";
     private static final String PAGER_FORMAT_PREV_NEXT = "prevNext";
 
-    private boolean _showAll;
-    private boolean _partialDataSet;
     private Boolean _disableDefaultPager = null;
     private Integer _pageSize = null;
     private Integer _defaultPageSize = null;
-    private Integer _dataSetSize = null;
     private String _pagerFormat = null;
     private String _pageHref = null;
     private String _pageAction = null;
@@ -229,37 +226,6 @@
     }
 
     /**
-     * @param dataSetSize Size estimate of the number of rows in the data set bound to the data grid
-     * @jsptagref.attributesyntaxvalue <i>int</i>
-     * @netui:attribute required="false" rtexprvalue="true"
-     *                  description="Size estimate of the number of rows in the data set bound to the data grid"
-     */
-    public void setDataSetSize(int dataSetSize) {
-        _dataSetSize = new Integer(dataSetSize);
-    }
-
-    /**
-     * <p>
-     * Set a flag indicating whether the data set is 'partial'.  A 'partial' data set contains a subset of the complete data set.
-     * </p>
-     * @jsptagref.attributedescription The cellpadding for the HTML table tag.
-     * @jsptagref.attributesyntaxvalue <i>string_cellpadding</i>
-     * @netui:attribute required="false" rtexprvalue="true" description="Flag indicating that the data set is 'partial'."
-     * @param partialDataSet the partial data set flag
-     */
-    public void setPartialDataSet(boolean partialDataSet) {
-        _partialDataSet = partialDataSet;
-    }
-
-    /**
-     * @netui:attribute required="false" rtexprvalue="true"
-     *                  description="Flag that disables paging functionality and displays all rows"
-     */
-    public void setShowAll(boolean showAll) {
-        _showAll = showAll;
-    }
-
-    /**
      * Execute the ConfigurePager tag.  When the ConfigurePager tag runs, it applies its tag attributes
      * onto a {@link DataGridTagModel} state object which is used when the data grid renders its pager.
      * @throws JspException when errors occur when processing this tag's attribute values
@@ -271,16 +237,9 @@
         if(dgm == null)
             throw new JspException(Bundle.getErrorString("DataGridTags_MissingDataGridModel"));
 
-        if(_showAll &&
-            (_pageSize != null || _defaultPageSize != null || _dataSetSize != null || _pageHref != null || _pageAction != null))
-            LOGGER.info("Configuration parameters of the " + 
-                getTagName() +
-                " will be ignored in the presence of the showAll attribute");
-
         PagerModel pm = dgm.getState().getPagerModel();
         assert pm != null;
 
-        // Configure pager properties
         if(_disableDefaultPager != null)
             dgm.setDisableDefaultPagerRendering(_disableDefaultPager.booleanValue());
 
@@ -290,7 +249,6 @@
         if(_defaultPageSize != null)
             pm.setDefaultPageSize(_defaultPageSize.intValue());
 
-        // Configure a custom pager renderer
         PagerRenderer pagerRenderer = null;
         if(_pagerRendererClass != null) {
             try {
@@ -299,16 +257,17 @@
             }
             catch(DataGridExtensionException e) {
                 String msg = Bundle.getErrorString("ConfigurePager_CantCreateCustomPagerRenderer", new Object[]{e});
-
                 JspException jsp = new JspException(msg, e);
-                // protect against ServletException thrown by Servlet 2.5 API if a Throwable cause is reinitialized
-                if (jsp.getCause() == null)
+
+                // todo: future cleanup
+                // The 2.5 Servlet api will set the initCause in the Throwable superclass during construction,
+                // this will cause an IllegalStateException on the following call.
+                if (jsp.getCause() == null) {
                     jsp.initCause(e);
-                
+                }
                 throw jsp;
             }
         }
-        // Configure pre-configured pager renderers
         else if(_pagerFormat != null) {
             if(_pagerFormat.equals(PAGER_FORMAT_FIRST_LAST_PREV_NEXT))
                 pagerRenderer = new FirstPreviousNextLastPagerRenderer();
@@ -321,12 +280,9 @@
         if(pagerRenderer != null)
             dgm.setPagerRenderer(pagerRenderer);
 
-        // Configure URIs used to perform paging
         if(_pageHref != null && _pageAction != null)
             throw new JspException(Bundle.getErrorString("ConfigurePager_CantSetHrefAndAction"));
 
-        // If no pager was configured, default the pager URI to the current request URI.  In the case of a .jsp page,
-        // this will re-use the current page
         if(_pageHref == null && _pageAction == null) {
             LOGGER.info("The configurePager tag has no page action or HREF specified; using the current request URI instead.");
             _pageHref = JspUtil.getRequest(getJspContext()).getRequestURI();
@@ -337,12 +293,6 @@
 
         if(_pageAction != null)
             pm.setPageAction(_pageAction);
-
-        if(_dataSetSize != null)
-            pm.setDataSetSize(_dataSetSize.intValue());
-
-        pm.setShowAll(_showAll);
-        pm.setPartialDataSet(_partialDataSet);
     }
 }
 

Modified: beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/DataGrid.java
URL: http://svn.apache.org/viewvc/beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/DataGrid.java?view=diff&rev=471039&r1=471038&r2=471039
==============================================================================
--- beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/DataGrid.java (original)
+++ beehive/branches/v1.0.2/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/datagrid/DataGrid.java Fri Nov  3 15:03:26 2006
@@ -245,10 +245,7 @@
 
     private static final String FACET_RESOURCE = "resource";
 
-    private boolean _partialDataSet = false;
     private boolean _renderRowGroups = false;
-    private boolean _showAll = false;
-    
     private String _name = null;
     private String _styleClassPrefix = null;
     private String _stylePolicyName = null;
@@ -747,7 +744,7 @@
      * @param name the name of the behavior
      * @param value the value of the behavior
      * @param facet th ebehavior's facet
-     * @throws JspException when the behavior's facet is not recognized
+     * @throws JspException when the behavior's facet isnot recognized
     */
     public void setBehavior(String name, Object value, String facet)
             throws JspException {
@@ -769,16 +766,14 @@
      * @throws IOException when an error occurs writing to the output strema
      */
     public void doTag()
-        throws JspException, IOException {
+            throws JspException, IOException {
 
-        // Initialize the data set.  Data grids canonicalize all data sets into an Iterator.  In the case of user error
-        // defining a data grid, this process can generated tag errors, so complete it first to avoid doing extra
-        // work if errors occur.
+        // ensure the dataSource is a valid expression
         String dataSource = getDataSource();
         ExpressionHandling expr = new ExpressionHandling(this);
         String validExpr = expr.ensureValidExpression(dataSource, "dataSource", "DataSourceError");
-        Object ods = expr.evaluateExpression(validExpr, "dataSource", getPageContext());
-        Iterator dataSetIterator = IteratorFactory.createIterator(ods);
+        Object ds = expr.evaluateExpression(validExpr, "dataSource", getPageContext());
+        Iterator iterator = IteratorFactory.createIterator(ds);
 
         JspContext jspContext = getJspContext();
         HttpServletRequest request = JspUtil.getRequest(jspContext);
@@ -786,9 +781,11 @@
         if(_dataGridConfig == null)
             _dataGridConfig = DataGridConfigFactory.getInstance();
 
-        PagedDataSet dataSet = new PagedDataSet(dataSource, dataSetIterator);
-        StyleModel styleModel = _dataGridConfig.getStyleModel(_stylePolicyName, _styleClassPrefix);
         TableRenderer tableRenderer = new TableRenderer(request);
+        PagedDataSet dataSet = new PagedDataSet(dataSource, iterator);
+
+        StyleModel styleModel = _dataGridConfig.getStyleModel(_stylePolicyName, _styleClassPrefix);
+
         DataGridResourceProvider resourceProvider = null;
         if(_resourceBundlePath == null)
             resourceProvider = _dataGridConfig.getDefaultResourceProvider();
@@ -806,10 +803,10 @@
         JspFragment fragment = getJspBody();
         if(fragment != null) {
             String javascript = null;
-
-            // render any JavaScript needed to support framework features           
-            if (_tableState.id != null)
+            /* render any JavaScript needed to support framework features */
+            if (_tableState.id != null) {
                 javascript = renderNameAndId(request, _tableState, null);
+            }
 
             boolean addedDataAccessProvider = false;
             try {
@@ -827,21 +824,12 @@
                    this makes it possible to have tags out of order and to
                    have rendering work correctly
                  */
-                /* todo: perf -- should it be possible to disable this? */
+                /* todo: perf -- should you be able to turn this off for perf? */
                 fragment.invoke(sw);
 
-                // Initialize the pager state of the data grid
+                /* todo: this needs to move into the DataGridTagModel */
                 PagerModel pm = _dataGridTagModel.getState().getPagerModel();
-                PagedDataSet pagedDataSet = _dataGridTagModel.getDataSet();
-                pagedDataSet.setPartial(pm.isPartialDataSet());
-                pagedDataSet.setShowAll(pm.isShowAll());
-                pagedDataSet.setFirstRow(pm.getRow());
-                pagedDataSet.setPageSize(pm.getPageSize());
-                pagedDataSet.initialize();
-
-                // if no data set size was configured, use the size of the data set
-                if(pm.getDataSetSize() == 0)
-                    pm.setDataSetSize(pagedDataSet.getSize());
+                _dataGridTagModel.getDataSet().createWindow(pm.getRow(), pm.getPageSize());
 
                 /* now that the model objects have been initialized, it's time to start rendering */
                 _dataGridTagModel.changeRenderState(DataGridTagModel.RENDER_STATE_START);
@@ -868,13 +856,13 @@
                 if(header != null)
                     appender.append(header);
 
-                /*
-                intermediate storage for the body and footer content
-                these are required by the HTML spec:
-                   http://www.w3.org/TR/REC-html40/struct/tables.html#h-11.2.3
-                as when the row groups are used, they must be re-ordered so that
-                <tfoot> preceeds <tbody>
+                /* intermediate storage for the body and footer content
+                   these are required by the HTML spec:
+                       http://www.w3.org/TR/REC-html40/struct/tables.html#h-11.2.3
+                   as when the row groups are used, they must be re-ordered so that
+                   <tfoot> preceeds <tbody>
                  */
+
                 String tbody = null;
                 String tfoot = null;
 
@@ -893,8 +881,6 @@
                 if(footer != null && !trimmed.trim().equals(""))
                     tfoot = footer;
 
-                // as per the (X)HTML specification, use of row groups requires changing
-                // the order in which they render
                 if(_dataGridTagModel.isRenderRowGroups()) {
                     if(tfoot != null)
                         appender.append(tfoot);
@@ -934,7 +920,7 @@
     /**
      * Get the index of the current item in the data set.  This is a zero-based absolute
      * index into the entire data set being rendered by the data grid.  This value
-     * should only be data bound inside of the {@link Rows} nested tag.
+     * should only be data bound inside of the {@link Rows}.
      * @return the index of the current item
      */
     public int getCurrentIndex() {
@@ -944,7 +930,7 @@
     /**
      * Get the current item in the data set.  As the data grid iterates over the data set, this
      * value will change to provide access to the current item in the data set.  This value
-     * should only be data bound inside of the {@link Rows} nested tag.
+     * should only be data bound inside of the {@link Rows}.
      * @return the current item
      */
     public Object getCurrentItem() {
@@ -978,7 +964,7 @@
      * @return the parent data access provider
      */
     public IDataAccessProvider getProviderParent() {
-        // todo: need to support nested data grids.  this should be done via the stack of objects in the PageContext
+        /* todo: support nested data grids.  this should be done via the stack of objects in the PageContext */
         return (IDataAccessProvider)SimpleTagSupport.findAncestorWithClass(this, IDataAccessProvider.class);
     }
 }

Modified: beehive/branches/v1.0.2/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/DataGridTestUtil.java
URL: http://svn.apache.org/viewvc/beehive/branches/v1.0.2/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/DataGridTestUtil.java?view=diff&rev=471039&r1=471038&r2=471039
==============================================================================
--- beehive/branches/v1.0.2/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/DataGridTestUtil.java (original)
+++ beehive/branches/v1.0.2/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/DataGridTestUtil.java Fri Nov  3 15:03:26 2006
@@ -22,20 +22,14 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Locale;
-import java.util.List;
 import javax.servlet.ServletRequest;
 import javax.servlet.jsp.JspContext;
 import javax.servlet.jsp.PageContext;
 
 import org.apache.beehive.netui.databinding.datagrid.api.pager.PagerModel;
 import org.apache.beehive.netui.databinding.datagrid.api.rendering.DataGridTagModel;
+import org.apache.beehive.netui.databinding.datagrid.api.*;
 import org.apache.beehive.netui.databinding.datagrid.api.sort.SortModel;
-import org.apache.beehive.netui.databinding.datagrid.api.DataGridState;
-import org.apache.beehive.netui.databinding.datagrid.api.DataGridStateFactory;
-import org.apache.beehive.netui.databinding.datagrid.api.DataGridURLBuilder;
-import org.apache.beehive.netui.databinding.datagrid.api.DataGridConfigFactory;
-import org.apache.beehive.netui.databinding.datagrid.api.DataGridResourceProvider;
-import org.apache.beehive.netui.databinding.datagrid.api.DataGridConfig;
 import org.apache.beehive.netui.databinding.datagrid.runtime.util.PagedDataSet;
 import org.apache.beehive.netui.test.servlet.HttpServletRequestHandler;
 
@@ -50,7 +44,7 @@
     private DataGridTestUtil() {
     }
 
-    static void initQueryString(ServletRequest request, String queryString) {
+    static final void initQueryString(ServletRequest request, String queryString) {
         assert request != null : "Received null request!";
         assert Proxy.getInvocationHandler(request) instanceof HttpServletRequestHandler;
 
@@ -62,29 +56,27 @@
         return ((PageContext)jspContext).getRequest();
     }
 
-    static void initQueryString(JspContext jspContext, String queryString) {
+    static final void initQueryString(JspContext jspContext, String queryString) {
         initQueryString(getRequest(jspContext), queryString);
     }
 
-    static DataGridTagModel getDataGridTagModel(JspContext jspContext) {
+    static final DataGridTagModel getDataGridTagModel(JspContext jspContext) {
         return buildDataGridTagModel(jspContext, DEFAULT_DATA_GRID_NAME, getPagedDataSet());
     }
 
-    static DataGridTagModel getDataGridTagModel(JspContext jspContext, String name) {
+    static final DataGridTagModel getDataGridTagModel(JspContext jspContext, String name) {
         return buildDataGridTagModel(jspContext, name, getPagedDataSet());
     }
 
-    static DataGridTagModel getEmptyDataGridTagModel(JspContext jspContext) {
+    static final DataGridTagModel getEmptyDataGridTagModel(JspContext jspContext) {
         return buildDataGridTagModel(jspContext, DEFAULT_DATA_GRID_NAME, getEmptyPagedDataSet());
     }
 
-   static PagedDataSet getEmptyPagedDataSet() {
-       PagedDataSet pagedDataSet = new PagedDataSet("${actionForm.emptyDataSource}", Collections.EMPTY_LIST.iterator());
-       pagedDataSet.setSize(0);
-       return pagedDataSet;
+   static final PagedDataSet getEmptyPagedDataSet() {
+        return new PagedDataSet("${actionForm.emptyDataSource}", Collections.EMPTY_LIST.iterator());
     }
 
-    static ArrayList getDataSet() {
+    static final PagedDataSet getPagedDataSet() {
         ArrayList/*<String>*/ list = new ArrayList/*<String>*/();
         list.add("abc");
         list.add("def");
@@ -98,55 +90,47 @@
         list.add("123");
         list.add("456");
         list.add("789");
-        return list;
+        return new PagedDataSet("${actionForm.dataSource}", list.iterator());
     }
 
-    static PagedDataSet getPagedDataSet() {
-        List list = getDataSet();
-        PagedDataSet pagedDataSet = new PagedDataSet("${actionForm.dataSource}", list.iterator());
-        pagedDataSet.setSize(list.size());
-        return pagedDataSet;
+    private static final DataGridTagModel buildDataGridTagModel(JspContext jspContext, String name, PagedDataSet dataSet) {
+        DataGridConfig config = getDataGridConfig();
+        DataGridResourceProvider provider = getDataGridConfig().getDefaultResourceProvider();
+        provider.setLocale(Locale.US);
+        DataGridTagModel dgm = new DataGridTagModel(name, config, jspContext);
+        dgm.setDataSet(dataSet);
+        dgm.setResourceProvider(provider);
+        dgm.getState().getPagerModel().setPageAction("fauxPageAction.do");
+        return dgm;
     }
 
-    static PagerModel getPagerModel(DataGridTagModel dgm) {
+    static final PagerModel getPagerModel(DataGridTagModel dgm) {
         return dgm.getState().getPagerModel();
     }
 
-    static DataGridConfig getDataGridConfig() {
+    static final DataGridConfig getDataGridConfig() {
         return DataGridConfigFactory.getInstance();
     }
 
-    static DataGridState createDataGridState(ServletRequest request, String gridName) {
+    static final DataGridState createDataGridState(ServletRequest request, String gridName) {
         DataGridStateFactory factory = DataGridStateFactory.getInstance(request);
         return factory.getDataGridState(gridName, getDataGridConfig());
     }
 
-    static DataGridState createDataGridState(JspContext jspContext, String gridName) {
+    static final DataGridState createDataGridState(JspContext jspContext, String gridName) {
         DataGridStateFactory factory = DataGridStateFactory.getInstance(getRequest(jspContext));
         return factory.getDataGridState(gridName, getDataGridConfig());
     }
 
-    static DataGridURLBuilder createDataGridURLBuilder(ServletRequest request, String gridName) {
+    static final DataGridURLBuilder createDataGridURLBuilder(ServletRequest request, String gridName) {
         DataGridStateFactory factory = DataGridStateFactory.getInstance(request);
         return factory.getDataGridURLBuilder(gridName, getDataGridConfig());
     }
 
-    static SortModel createSortModel(ServletRequest request, String gridNamespace) {
+    static final SortModel createSortModel(ServletRequest request, String gridNamespace) {
         DataGridState state = DataGridTestUtil.createDataGridState(request, gridNamespace);
         SortModel sortModel = state.getSortModel();
         return sortModel;
     }
 
-    private static DataGridTagModel buildDataGridTagModel(JspContext jspContext, String name, PagedDataSet dataSet) {
-        DataGridConfig config = getDataGridConfig();
-        DataGridResourceProvider provider = getDataGridConfig().getDefaultResourceProvider();
-        provider.setLocale(Locale.US);
-
-        DataGridTagModel dataGridTagModel = new DataGridTagModel(name, config, jspContext);
-        dataGridTagModel.setDataSet(dataSet);
-        dataGridTagModel.getState().getPagerModel().setDataSetSize(dataSet.getSize());
-        dataGridTagModel.setResourceProvider(provider);
-        dataGridTagModel.getState().getPagerModel().setPageAction("fauxPageAction.do");
-        return dataGridTagModel;
-    }
 }

Modified: beehive/branches/v1.0.2/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
URL: http://svn.apache.org/viewvc/beehive/branches/v1.0.2/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml?view=diff&rev=471039&r1=471038&r2=471039
==============================================================================
--- beehive/branches/v1.0.2/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml (original)
+++ beehive/branches/v1.0.2/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml Fri Nov  3 15:03:26 2006
@@ -3499,38 +3499,6 @@
          </features>
       </test>
       <test>
-         <name>DataGridShowAll</name>
-         <description>DataGridShowAll</description>
-         <webapp>coreWeb</webapp>
-         <categories>
-            <category>bvt</category>
-            <category>bvt.struts11</category>
-            <category>drt</category>
-            <category>datagrid</category>
-            <category>databinding</category>
-         </categories>
-         <features>
-            <feature>Databinding</feature>
-            <feature>Data Grid</feature>
-         </features>
-      </test>
-      <test>
-         <name>DataGridSimplePartialDataSet</name>
-         <description>DataGridSimplePartialDataSet</description>
-         <webapp>coreWeb</webapp>
-         <categories>
-            <category>bvt</category>
-            <category>bvt.struts11</category>
-            <category>drt</category>
-            <category>datagrid</category>
-            <category>databinding</category>
-         </categories>
-         <features>
-            <feature>Databinding</feature>
-            <feature>Data Grid</feature>
-         </features>
-      </test>
-      <test>
          <name>DataGridSimpleSort</name>
          <description>DataGridSimpleSort</description>
          <webapp>coreWeb</webapp>