Author: ekoneil
Date: Tue Apr 19 06:46:09 2005
New Revision: 161886

URL: http://svn.apache.org/viewcvs?view=rev&rev=161886
Log:
Remove the DataSourceTag base class.  This was only used by the CellRepeater 
and the Repeater.  The base class functionality has been moved into the 
subclasses since DataSourceTag served very little purpose.

Also deleted two now empty directories.

BB: self
DRT: NetUI pass
BVT: NetUI pass (100%, woo-hoo!)


Removed:
    
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/DataSourceTag.java
    incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/cache/
    
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/classloader/
Modified:
    
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/cellrepeater/CellRepeater.java
    
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/repeater/Repeater.java
    
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java

Modified: 
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/cellrepeater/CellRepeater.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/cellrepeater/CellRepeater.java?view=diff&r1=161885&r2=161886
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/cellrepeater/CellRepeater.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/cellrepeater/CellRepeater.java
 Tue Apr 19 06:46:09 2005
@@ -26,7 +26,9 @@
 import javax.servlet.jsp.tagext.TryCatchFinally;
 import javax.servlet.jsp.tagext.SimpleTagSupport;
 
-import org.apache.beehive.netui.tags.DataSourceTag;
+import org.apache.beehive.netui.tags.AbstractClassicTag;
+import org.apache.beehive.netui.tags.ExpressionHandling;
+import org.apache.beehive.netui.tags.html.HtmlDataSourceTag;
 import 
org.apache.beehive.netui.tags.databinding.cellrepeater.style.CellRepeaterStyleBean;
 import org.apache.beehive.netui.util.Bundle;
 import 
org.apache.beehive.netui.util.exception.LocalizedUnsupportedOperationException;
@@ -144,7 +146,7 @@
  * @netui.tldx:tag 
renderer="workshop.netui.jspdesigner.tldx.CellRepeaterRenderer"
  */
 public class CellRepeater
-        extends DataSourceTag
+        extends AbstractClassicTag
         implements IDataAccessProvider, TryCatchFinally {
 
     private static final Logger LOGGER = 
Logger.getInstance(CellRepeater.class);
@@ -161,6 +163,7 @@
     private ArrayList _dataList = null;
     private Object _currentItem = null;
     private CellRepeaterStyleBean _styleContext = new CellRepeaterStyleBean();
+    private String _dataSource = null;
 
     /**
      * Get the name of this tag.  This is used to identify the type of this tag
@@ -617,6 +620,7 @@
         _styleContext = new CellRepeaterStyleBean();
         _valid = true;
         _contentBuffer = null;
+        _dataSource = null;
     }
 
     private void reportBasicError(String message)
@@ -706,16 +710,93 @@
     }
 
     private boolean ensureItem(int index, List data) {
-        if(LOGGER.isDebugEnabled())
-            LOGGER.debug("item: " + 0 + " data: " + (data == null ? "null 
data" :
-                    (index < data.size() ? "" + index : "index out of bounds 
for size " + data.size())));
+        LOGGER.debug("item: " + 0 + " data: " + (data == null ? "null data" :
+                     (index < data.size() ? "" + index : "index out of bounds 
for size " + data.size())));
 
         if(data != null && index < data.size()) {
             _currentItem = data.get(index);
             _currentIndex = index;
             return true;
         }
-        else
-            return false;
+        else return false;
+    }
+
+    /**
+     * Return an <code>ArrayList</code> which represents a chain of 
<code>INameInterceptor</code>
+     * objects.  This method by default returns <code>null</code> and should 
be overridden
+     * by objects that support naming.
+     * @return an <code>ArrayList</code> that will contain 
<code>INameInterceptor</code> objects.
+     */
+    protected List getNamingChain() {
+        return AbstractClassicTag.DefaultNamingChain;
+    }
+
+    /**
+     * Sets the tag's data source (can be an expression).
+     * @param dataSource - the data source
+     * @jsptagref.attributedescription <p>The <code>dataSource</code> 
attribute determines both
+     * (1) the source of populating data for the tag and
+     * (2) the object to which the tag submits data.
+     *
+     * <p>For example, assume that the Controller file (= JPF file) contains
+     * a Form Bean with the property foo.  Then the following 
&lt;netui:textBox> tag will
+     * (1) draw populating data from the Form Bean's foo property and (2)
+     * submit user defined data to the same property.
+     *
+     * <p>&nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;netui:textBox 
dataSource="{actionForm.foo}" /></code>
+     *
+     * <p>The <code>dataSource</code> attribute takes either a data binding 
expression or
+     * the name of a Form Bean property.  In the
+     * above example, <code>&lt;netui:textBox dataSource="foo" /></code>
+     * would have the exactly same behavior.
+     *
+     * <p>When the tag is used to submit data, the data binding expression must
+     * refer to a Form Bean property.
+     * In cases where the tag is not used to submit data, but is used for
+     * displaying data only, the data
+     * binding expression need not refer to a Form Bean property.  For example,
+     * assume that myIterativeData is a member variable on
+     * the Controller file ( = JPF file).  The following 
&lt;netui-data:repeater>
+     * tag draws its data from myIterativeData.
+     *
+     * <p>&nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;netui-data:repeater 
dataSource="{pageFlow.myIterativeData}"></code>
+     * @jsptagref.databindable Read / Write
+     * @jsptagref.attributesyntaxvalue <i>expression_datasource</i>
+     * @netui:attribute required="true"
+     * @netui.tldx:attribute language="netuiel"
+     */
+    public void setDataSource(String dataSource) {
+        _dataSource = dataSource;
+    }
+
+    /**
+     * Gets the tag's data source (can be an expression).
+     * @return the data source
+     */
+    public String getDataSource() {
+        return "{" + _dataSource + "}";
+    }
+
+    /**
+     * Return the Object that is represented by the specified data source.
+     * @return Object
+     * @throws JspException
+     */
+    private Object evaluateDataSource()
+        throws JspException {
+        ExpressionHandling expr = new ExpressionHandling(this);
+        String dataSource = getDataSource();
+        String ds = expr.ensureValidExpression(dataSource, "dataSource", 
"DataSourceError");
+        if (ds == null)
+            return null;
+
+        // have a valid expression
+        Object o = expr.evaluateExpression(dataSource, "dataSource", 
pageContext);
+        return o;
+    }
+
+    private String doNaming()
+            throws JspException {
+        return applyNamingChain(getDataSource());
     }
 }

Modified: 
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/repeater/Repeater.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/repeater/Repeater.java?view=diff&r1=161885&r2=161886
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/repeater/Repeater.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/repeater/Repeater.java
 Tue Apr 19 06:46:09 2005
@@ -17,18 +17,19 @@
  */
 package org.apache.beehive.netui.tags.databinding.repeater;
 
-import org.apache.beehive.netui.util.internal.InternalStringBuilder;
-
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.tagext.*;
 import java.util.Iterator;
+import java.util.List;
 
 import org.apache.beehive.netui.script.common.DataAccessProviderStack;
 import org.apache.beehive.netui.script.common.IDataAccessProvider;
-import org.apache.beehive.netui.tags.DataSourceTag;
+import org.apache.beehive.netui.tags.AbstractClassicTag;
+import org.apache.beehive.netui.tags.ExpressionHandling;
 import org.apache.beehive.netui.tags.databinding.repeater.pad.PadContext;
 import org.apache.beehive.netui.util.Bundle;
 import 
org.apache.beehive.netui.util.exception.LocalizedUnsupportedOperationException;
+import org.apache.beehive.netui.util.internal.InternalStringBuilder;
 import org.apache.beehive.netui.util.iterator.IteratorFactory;
 import org.apache.beehive.netui.util.logging.Logger;
 
@@ -160,7 +161,7 @@
  * renderer="workshop.netui.jspdesigner.tldx.RepeaterRenderer"
  */
 public class Repeater
-        extends DataSourceTag
+        extends AbstractClassicTag
         implements IDataAccessProvider, TryCatchFinally {
 
     private static final Logger LOGGER = Logger.getInstance(Repeater.class);
@@ -194,14 +195,9 @@
      */
     public static final int END = 4;
 
-    private static final int HAVE_NOTHING = 0x000;
-    private static final int HAVE_HEADER = 0x001;
-    private static final int HAVE_ITEM = 0x010;
-    private static final int HAVE_FOOTER = 0x100;
-
     private boolean _ignoreNulls = false;
+    private boolean _haveKids = false;
     private int _currentIndex = -1;
-    private int _have = HAVE_NOTHING;
     private int _renderedItems = 0;
     private int _renderState = INIT;
     private Object _defaultText = null;
@@ -209,6 +205,7 @@
     private Iterator _iterator = null;
     private PadContext _padContext = null;
     private InternalStringBuilder _contentBuffer = null;
+    private String _dataSource = null;
 
     /**
      * Get the name of this tag.  This is used to identify the type of this tag
@@ -241,7 +238,7 @@
         if(_padContext == null)
             _padContext = padContext;
 
-        if(LOGGER.isDebugEnabled()) LOGGER.debug("Repeater has a padContext 
with text: " + _padContext);
+        LOGGER.debug("Repeater has a padContext with text: " + _padContext);
 
         return;
     }
@@ -349,12 +346,7 @@
      * @param repeaterComponent [EMAIL PROTECTED] RepeaterComponent} to 
register with the Repeater parent
      */
     public void registerChildTag(RepeaterComponent repeaterComponent) {
-        if(_renderState < HEADER && repeaterComponent instanceof 
RepeaterHeader)
-            _have |= HAVE_HEADER;
-        else if(repeaterComponent instanceof RepeaterFooter)
-            _have |= HAVE_FOOTER;
-        else if(repeaterComponent instanceof RepeaterItem)
-            _have |= HAVE_ITEM;
+        _haveKids = true;
     }
 
     /**
@@ -439,7 +431,7 @@
         if(hasErrors())
             return SKIP_BODY;
 
-        boolean kids = (_have > 0 ? true : false);
+        boolean kids = _haveKids;
 
         if(LOGGER.isDebugEnabled()) LOGGER.debug("structured repeater: " + 
kids + " render state: " + renderStateToString(_renderState));
 
@@ -505,13 +497,12 @@
      */
     protected void localRelease() {
         super.localRelease();
-
         _currentItem = null;
         _currentIndex = -1;
         _iterator = null;
         _defaultText = null;
         _renderState = INIT;
-        _have = HAVE_NOTHING;
+        _haveKids = false;
         _contentBuffer = null;
         _padContext = null;
         _ignoreNulls = false;
@@ -691,5 +682,84 @@
             default:
                 return "INVALID STATE";
         }
+    }
+
+    /**
+     * Return an <code>ArrayList</code> which represents a chain of 
<code>INameInterceptor</code>
+     * objects.  This method by default returns <code>null</code> and should 
be overridden
+     * by objects that support naming.
+     * @return an <code>ArrayList</code> that will contain 
<code>INameInterceptor</code> objects.
+     */
+    protected List getNamingChain() {
+        return AbstractClassicTag.DefaultNamingChain;
+    }
+
+    /**
+     * Sets the tag's data source (can be an expression).
+     * @param dataSource - the data source
+     * @jsptagref.attributedescription <p>The <code>dataSource</code> 
attribute determines both
+     * (1) the source of populating data for the tag and
+     * (2) the object to which the tag submits data.
+     *
+     * <p>For example, assume that the Controller file (= JPF file) contains
+     * a Form Bean with the property foo.  Then the following 
&lt;netui:textBox> tag will
+     * (1) draw populating data from the Form Bean's foo property and (2)
+     * submit user defined data to the same property.
+     *
+     * <p>&nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;netui:textBox 
dataSource="{actionForm.foo}" /></code>
+     *
+     * <p>The <code>dataSource</code> attribute takes either a data binding 
expression or
+     * the name of a Form Bean property.  In the
+     * above example, <code>&lt;netui:textBox dataSource="foo" /></code>
+     * would have the exactly same behavior.
+     *
+     * <p>When the tag is used to submit data, the data binding expression must
+     * refer to a Form Bean property.
+     * In cases where the tag is not used to submit data, but is used for
+     * displaying data only, the data
+     * binding expression need not refer to a Form Bean property.  For example,
+     * assume that myIterativeData is a member variable on
+     * the Controller file ( = JPF file).  The following 
&lt;netui-data:repeater>
+     * tag draws its data from myIterativeData.
+     *
+     * <p>&nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;netui-data:repeater 
dataSource="{pageFlow.myIterativeData}"></code>
+     * @jsptagref.databindable Read / Write
+     * @jsptagref.attributesyntaxvalue <i>expression_datasource</i>
+     * @netui:attribute required="true"
+     * @netui.tldx:attribute language="netuiel"
+     */
+    public void setDataSource(String dataSource) {
+        _dataSource = dataSource;
+    }
+
+    /**
+     * Gets the tag's data source (can be an expression).
+     * @return the data source
+     */
+    public String getDataSource() {
+        return "{" + _dataSource + "}";
+    }
+
+    /**
+     * Return the Object that is represented by the specified data source.
+     * @return Object
+     * @throws JspException
+     */
+    private Object evaluateDataSource()
+            throws JspException {
+        ExpressionHandling expr = new ExpressionHandling(this);
+        String dataSource = getDataSource();
+        String ds = expr.ensureValidExpression(dataSource, "dataSource", 
"DataSourceError");
+        if (ds == null)
+            return null;
+
+        // have a valid expression
+        Object o = expr.evaluateExpression(dataSource, "dataSource", 
pageContext);
+        return o;
+    }
+
+    private String doNaming()
+            throws JspException {
+        return applyNamingChain(getDataSource());
     }
 }

Modified: 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java?view=diff&r1=161885&r2=161886
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java
 Tue Apr 19 06:46:09 2005
@@ -152,10 +152,10 @@
     ///////////////////////////  Naming and NamingInterceptor support 
////////////////////////////
 
     /**
-     * Return an <code>ArrayList</code> which represents a chain of 
<code>INameInterceptor</code>
+     * Return an <code>List</code> which represents a chain of 
<code>INameInterceptor</code>
      * objects.  This method by default returns <code>null</code> and should 
be overridden
      * by objects that support naming.
-     * @return an <code>ArrayList</code> that will contain 
<code>INameInterceptor</code> objects.
+     * @return an <code>List</code> that will contain 
<code>INameInterceptor</code> objects.
      */
     protected List getNamingChain()
     {


Reply via email to