You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by do...@apache.org on 2005/10/19 17:31:56 UTC

svn commit: r326581 [3/9] - in /beehive/trunk/netui: ant/ src/bootstrap/org/apache/beehive/netui/tools/tld/xdoclet/ src/jar-assembly/ src/pageflow/org/apache/beehive/netui/pageflow/ src/simple-tags/ src/simple-tags/org/ src/simple-tags/org/apache/ src/...

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlBehavior.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlBehavior.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlBehavior.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlBehavior.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,203 @@
+package org.apache.beehive.netui.simpletags.behaviors;
+
+import org.apache.beehive.netui.simpletags.appender.Appender;
+import org.apache.beehive.netui.simpletags.core.IDocumentTypeProducer;
+import org.apache.beehive.netui.simpletags.core.TagContext;
+import org.apache.beehive.netui.simpletags.core.services.ErrorReporter;
+import org.apache.beehive.netui.simpletags.core.services.ScriptReporter;
+import org.apache.beehive.netui.simpletags.html.HtmlConstants;
+import org.apache.beehive.netui.simpletags.rendering.AbstractHtmlState;
+import org.apache.beehive.netui.simpletags.rendering.HtmlTag;
+import org.apache.beehive.netui.simpletags.rendering.TagRenderingBase;
+import org.apache.beehive.netui.simpletags.util.ContextUtils;
+import org.apache.beehive.netui.simpletags.util.PageFlowAdaptor;
+import org.apache.beehive.netui.util.Bundle;
+
+import java.util.Locale;
+
+
+public class HtmlBehavior extends ScriptContainerBehavior
+        implements HtmlConstants, IDocumentTypeProducer
+{
+    /**
+     * Constant representing the document type html 4.01
+     */
+    public static final String HTML_401 = "html4-loose";
+
+    /**
+     * Constant representing the document type html 4.01
+     */
+    public static final String HTML_401_QUIRKS = "html4-loose-quirks";
+
+    /**
+     * Constant representing the document type XHTML 1.0 Transitional.
+     */
+    public static final String XHTML_10 = "xhtml1-transitional";
+
+    private HtmlTag.State _state = new HtmlTag.State();
+    private TagRenderingBase _br;
+    private boolean _useLocale = false;     // include xml:lang=defaultLocale.getLanguage()
+    private String _docType;                // The document type
+
+    // This is set with the rendering type of the document
+    private int _rendering = TagRenderingBase.UNKNOWN_RENDERING;
+
+    /**
+     * Returns the name of the Tag.
+     */
+    public String getTagName()
+    {
+        return "Html";
+    }
+
+    /**
+     * This method will return the TagRenderBase enum value for the document type.  The default
+     * value is HTML 4.01.
+     * @return int
+     */
+    public int getTargetDocumentType()
+    {
+        // have we set the rendering type?
+        if (_rendering != TagRenderingBase.UNKNOWN_RENDERING)
+            return _rendering;
+
+        // check the _docType for the rendering type set on this behavior
+        _rendering = TagRenderingBase.getDefaultDocType();
+        if (_docType != null) {
+            if (_docType.equals(HTML_401))
+                _rendering = TagRenderingBase.HTML_RENDERING;
+            else if (_docType.equals(HTML_401_QUIRKS))
+                _rendering = TagRenderingBase.HTML_RENDERING_QUIRKS;
+            else if (_docType.equals(XHTML_10))
+                _rendering = TagRenderingBase.XHTML_RENDERING;
+        }
+        return _rendering;
+    }
+
+    /////////////////////////// Attributes ////////////////////////////
+
+    /**
+     * Sets the dir value of the html.
+     * @param dir the direction of text, "LTR" or "RTL"
+     * @jsptagref.attributedescription Specifies the direction of text. (<code>LTR | RTL</code>)
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_dir</i>
+     * @netui:attribute required="false"  rtexprvalue="true"
+     * description="Sets the dir value (ltr or rtl) of the html."
+     */
+    public void setDir(String dir)
+    {
+        _state.dir = dir;
+    }
+
+    /**
+     * Gets whether the default locale's language should be used.
+     * @return true or false
+     */
+    public boolean isUseLocale()
+    {
+        return _useLocale;
+    }
+
+    /**
+     * Sets whether the default locale's language should be used.
+     * @param locale true or false
+     * @jsptagref.attributedescription Sets whether the default locale's language should be used.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>boolean_locale</i>
+     * @netui:attribute required="false" rtexprvalue="true" type="boolean"
+     * description="Sets whether the default locale's language should be used."
+     */
+    public void setUseLocale(boolean locale)
+    {
+        _useLocale = locale;
+    }
+
+    /**
+     * Set the document type (html4-loose or xhtml1-transitional) of the document.
+     * @jsptagref.attributedescription Set the document type (html4-loose or xhtml1-transitional) of the document.
+     * The default is html4-loose-quirks.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_doctype</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="Set the document type (html4-loose or xhtml1-transitional) of the document."
+     */
+    public void setDocumentType(String docType)
+    {
+        _docType = docType;
+    }
+
+    /**
+     * Set an attribute that will be displayed on the generated HTML tag.
+     * @param name The name of the attribute to set.
+     * @param value The value of the attribute.
+     * @param facet Facet is not supported and will report an error.
+     */
+    public void setAttribute(String name, String value, String facet)
+    {
+        boolean error = false;
+
+        if (facet != null) {
+            String s = Bundle.getString("Tags_AttributeFacetNotSupported", new Object[]{facet});
+            registerTagError(s, null);
+        }
+        // validate the name attribute, in the case of an error simply return.
+        if (name == null || name.length() <= 0) {
+            String s = Bundle.getString("Tags_AttributeNameNotSet");
+            registerTagError(s, null);
+            error = true;
+        }
+        if (error)
+            return;
+
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, name, value);
+    }
+
+    //******************* Lifecycle Methods ************************************
+
+
+    public void preRender()
+    {
+        // The super prerender will push the scopeId onto the stack
+        super.preRender();
+
+        TagContext tagCtxt = ContextUtils.getTagContext();
+        tagCtxt.setDocTypeProducer(this);
+
+        // set the locale
+        Locale currentLocale = PageFlowAdaptor.currentLocale(_useLocale);
+        if (currentLocale == null) {
+            currentLocale = Locale.getDefault();
+        }
+        _state.lang = currentLocale.getLanguage();
+
+        // if there is an Id scope set then set the attribute to be output
+        String idScope = getIdScope();
+        if (idScope != null) {
+            _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, "netui:idScope", idScope);
+        }
+    }
+
+    public void renderStart(Appender appender)
+    {
+        _br = TagRenderingBase.Factory.getRendering(TagRenderingBase.HTML_TAG);
+        _br.doStartTag(appender, _state);
+        appender.append("\n");
+    }
+
+    public void renderEnd(Appender appender)
+    {
+        TagContext tagCtxt = ContextUtils.getTagContext();
+
+        // if there are errors then we should output the error table
+        ErrorReporter er = tagCtxt.getErrorReporter();
+        er.reportCollectedErrors(appender);
+
+        // the script can be written out by another tag,  typically this would be the <body> tag.
+        ScriptReporter sr = tagCtxt.getScriptReporter();
+        sr.writeScript(appender);
+
+        // close the html tag
+        _br.doEndTag(appender);
+    }
+}

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlBehavior.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlDataSourceBehavior.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlDataSourceBehavior.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlDataSourceBehavior.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlDataSourceBehavior.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,119 @@
+package org.apache.beehive.netui.simpletags.behaviors;
+
+import org.apache.beehive.netui.simpletags.core.ExpressionHandling;
+import org.apache.beehive.netui.simpletags.jsptags.AbstractSimpleTag;
+import org.apache.beehive.netui.simpletags.rendering.AbstractHtmlControlState;
+
+import javax.servlet.jsp.el.VariableResolver;
+import java.util.List;
+
+abstract public class HtmlDataSourceBehavior extends HtmlFocusBaseBehavior
+{
+    protected String _dataSource;
+    protected VariableResolver _vr;
+
+    /**
+     * 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 true
+     * @jsptagref.attributesyntaxvalue <i>expression_datasource</i>
+     * @netui:attribute required="true"
+     * description="The <code>dataSource</code> attribute determines both
+     * the source of populating data for the tag and
+     * the object to which the tag submits data."
+     */
+    public void setDataSource(String dataSource)
+    {
+        _dataSource = dataSource;
+    }
+
+    /**
+     * This method will set the variable resolver.  This required for all DataSource Behaviors in order
+     * to resolve the expression.
+     * @param vr The variable resolver used for this page...
+     */
+    public void setVariableResolver(VariableResolver vr)
+    {
+        _vr = vr;
+    }
+
+    /**
+     * 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 AbstractSimpleTag.DefaultNamingChain;
+    }
+
+    /**
+     * Return the Object that is represented by the specified data source.
+     * @return Object
+     */
+    protected Object evaluateDataSource()
+    {
+        // @todo: at some point we need to switch the expression evaluation to not require '{'
+        ExpressionHandling expr = new ExpressionHandling(this, _vr);
+        String datasource = "{" + _dataSource + "}";
+        String ds = expr.ensureValidExpression(datasource, "dataSource", "DataSourceError");
+        if (ds == null)
+            return null;
+
+        // have a valid expression
+        return expr.evaluateExpression(datasource, "dataSource");
+    }
+
+    /**
+     * This method will create the name of the form element (HTML Control) that has a name. The
+     * <b>name</b> attribute represent the "control name" for the control.  This name is scoped
+     * into the form element.  In addition, a control may have a <b>id</b> attribute which is
+     * specified by setting the <b>tagId</b>.  These two value are set in this routine.  The name
+     * is always the expression mapping the data to it's backing element and is conotrolled
+     * by the optional naming chain provided by the tag.  The <b>tagId</b> specifies the <b>id</b>
+     * attribute.  If this is present then we write out a JavaScript that allows mapping
+     * the tagId set on the tag to both the real <b>id</b> value and also the <b>name</b> value.
+     * The <b>id</b> is formed by passing the <b>tagId</b> to the URL rewritter service.
+     * @param state      The tag state structure.  This contains both the name and id attributes.  The
+     *                   id attribute should be set with the initial value from the tagId.
+     */
+    protected void nameHtmlControl(AbstractHtmlControlState state)
+    {
+        assert (state != null) : "parameter 'state' may not be null";
+        assert (_dataSource != null) : "dataSource is Null";
+
+        // create the expression (name)
+        String datasource = "{" + _dataSource + "}";
+        state.name = applyNamingChain(datasource);
+
+        FormBehavior parentForm = getNearestForm();
+        renderNameAndId(state, parentForm);
+    }
+}

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlDataSourceBehavior.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlDefaultableDataSourceBehavior.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlDefaultableDataSourceBehavior.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlDefaultableDataSourceBehavior.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlDefaultableDataSourceBehavior.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,36 @@
+package org.apache.beehive.netui.simpletags.behaviors;
+
+abstract public class HtmlDefaultableDataSourceBehavior extends HtmlDataSourceBehavior 
+{
+    protected Object _defaultValue;           // A String that contains or references the data to render for the default value of this tag.
+
+     /**
+      * Sets the default value (can be an expression).
+      * @param defaultValue the default value
+      * @jsptagref.attributedescription <p><b>Use in &lt;netui:checkBoxGroup>, &lt;netui:checkBox>,
+      * &lt;netui:radioButtonGroup>, and &lt;netui:select> tags</b></p>
+      * <p>Sets the preselected value or values.
+      * <p>The <code>defaultValue</code> attribute takes either a String literal or
+      * a data binding expression.
+      * <p>If the <code>defaultValue</code> attribute has a String value (or if
+      * the data binding expression points to a String), then a single value
+      * will be preselected.
+      * <p>If the <code>defaultValue</code> attribute points to a String[] object
+      * (or any object which can be iterated over), then
+      * multiple values will be preselected.
+      *
+      *
+      * <p><b>Use in &lt;netui:textArea> and &lt;netui:textBox> tags</b></p>
+      * <p>Sets the initial display text.</p>
+      * <p>The <code>defaultValue</code> attribute takes either a String literal or
+      * a data binding expression that points to a String.
+      * @jsptagref.databindable Read / Write
+      * @jsptagref.attributesyntaxvalue <i>string_or_expression_default</i>
+      * @netui:attribute required="false" rtexprvalue="true"  type="java.lang.Object"
+      * description="Sets the default value of the control which is used if the object bound to is null."
+      */
+     public void setDefaultValue(Object defaultValue)
+     {
+         _defaultValue = defaultValue;
+     }
+}

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlDefaultableDataSourceBehavior.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlFocusBaseBehavior.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlFocusBaseBehavior.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlFocusBaseBehavior.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlFocusBaseBehavior.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,95 @@
+package org.apache.beehive.netui.simpletags.behaviors;
+
+import org.apache.beehive.netui.simpletags.rendering.AbstractHtmlState;
+
+abstract public class HtmlFocusBaseBehavior extends HtmlBaseBehavior
+{
+    private boolean _disabled;              // Is the html control disabled?
+
+    /**
+     * Set the disable state either with the literal "true" or "false"
+     * or with an expression.
+     * @param disabled true or false or an expression
+     * @jsptagref.attributedescription Set the disable state either with the literal "true"
+     * or "false" or with an expression.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>boolean_disabled</i>
+     * @netui:attribute required="false" rtexprvalue="true" type="boolean"
+     * description="Set the disable state either with the literal "true" or "false"
+     * or with an expression."
+     */
+    public void setDisabled(boolean disabled)
+    {
+        _disabled = disabled;
+    }
+
+    /**
+     * This method will a boolean indicating if the control is disabled or not.  This will cause the
+     * disable attribute to be evaluated which may result in a runtime error or a JspException.
+     * @return <code>true</code> if the control is disabled.
+     */
+    protected final boolean isDisabled()
+    {
+        return _disabled;
+    }
+
+    /**
+     * Sets the onBlur javascript event.
+     * @param onblur the onBlur event.
+     * @jsptagref.attributedescription The onBlur JavaScript event.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_onBlur</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="Sets the onBlur javascript event."
+     */
+    public void setOnBlur(String onblur)
+    {
+        AbstractHtmlState tsh = getState();
+        tsh.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONBLUR, onblur);
+    }
+
+    /**
+     * Sets the onFocus javascript event.
+     * @param onfocus the onFocus event.
+     * @jsptagref.attributedescription The onFocus JavaScript event.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_onFocus</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="Sets the onFocus javascript event."
+     */
+    public void setOnFocus(String onfocus)
+    {
+        AbstractHtmlState tsh = getState();
+        tsh.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONFOCUS, onfocus);
+    }
+
+    /**
+     * Sets the onChange javascript event.
+     * @param onchange the onChange event.
+     * @jsptagref.attributedescription The onChange JavaScript event.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_onChange</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="Sets the onChange javascript event."
+     */
+    public void setOnChange(String onchange)
+    {
+        AbstractHtmlState tsh = getState();
+        tsh.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONCHANGE, onchange);
+    }
+
+    /**
+     * Sets the onSelect javascript event.
+     * @param onselect the onSelect event.
+     * @jsptagref.attributedescription The onSelect JavaScript event.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_onSelect</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="Sets the onSelect javascript event."
+     */
+    public void setOnSelect(String onselect)
+    {
+        AbstractHtmlState tsh = getState();
+        tsh.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONSELECT, onselect);
+    }
+}
\ No newline at end of file

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/HtmlFocusBaseBehavior.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ImageAnchorBehavior.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ImageAnchorBehavior.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ImageAnchorBehavior.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ImageAnchorBehavior.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,361 @@
+package org.apache.beehive.netui.simpletags.behaviors;
+
+import org.apache.beehive.netui.pageflow.PageFlowContext;
+import org.apache.beehive.netui.simpletags.appender.Appender;
+import org.apache.beehive.netui.simpletags.core.TagContext;
+import org.apache.beehive.netui.simpletags.core.services.ScriptReporter;
+import org.apache.beehive.netui.simpletags.javascript.CoreScriptFeature;
+import org.apache.beehive.netui.simpletags.rendering.AbstractHtmlState;
+import org.apache.beehive.netui.simpletags.rendering.ImageTag;
+import org.apache.beehive.netui.simpletags.rendering.TagRenderingBase;
+import org.apache.beehive.netui.simpletags.util.ContextUtils;
+import org.apache.beehive.netui.simpletags.util.PageFlowTagUtils;
+import org.apache.beehive.netui.util.Bundle;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.JspException;
+import java.net.URISyntaxException;
+
+public class ImageAnchorBehavior extends AnchorBehavior
+{
+    private ImageTag.State _imgState = new ImageTag.State();
+    private String _rolloverImage = null; // The roll-over image of the ImageAnchor.
+    private TagRenderingBase _imgRb;
+    private TagRenderingBase _anchorRb;
+
+    /**
+     * Return the name of the Tag.
+     */
+    public String getTagName()
+    {
+        return "ImageAnchor";
+    }
+
+    /**
+     * Base support for the attribute tag.  This is overridden to prevent setting the <code>src</code>
+     * attribute. ImageAnchor supports two facets, <code>image</code> and <code>anchor<code>.  The default
+     * facet is anchor, meaning if the facet is not specified, the attribute will be applied to the
+     * &lt;a> element.  To apply an attribute to the &lt;img> element you must specify the
+     * <code>image</code> facet.
+     * @param name  The name of the attribute.  This value may not be null or the empty string.
+     * @param value The value of the attribute.  This may contain an expression.
+     * @param facet The name of a facet to which the attribute will be applied.  This is optional.
+     */
+    public void setAttribute(String name, String value, String facet)
+    {
+        if (name != null && name.equals(SRC)) {
+            String s = Bundle.getString("Tags_AttributeMayNotBeSet", new Object[]{name});
+            registerTagError(s, null);
+        }
+        if (facet != null) {
+            if (facet.equals("image")) {
+                setStateAttribute(name, value, _imgState);
+                return;
+            }
+        }
+        super.setAttribute(name, value, facet);
+    }
+
+    /**
+     * Sets the property to specify where to align the image.
+     * @param align the image alignment.
+     * @jsptagref.attributedescription The alignment of the image.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_align</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The alignment of the image."
+     */
+    public void setAlign(String align)
+    {
+        _imgState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ALIGN, align);
+    }
+
+    /**
+     * Sets the property to specify the alt text of the image.
+     * @param alt the image alignment.
+     * @jsptagref.attributedescription The alternative text of the image
+     * @jsptagref.databindable Read Only
+     * @jsptagref.attributesyntaxvalue <i>string_alt</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The alternative text of the image."
+     */
+    public void setAlt(String alt)
+    {
+        _imgState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ALT, alt);
+    }
+
+    /**
+     * Sets the property to specify a link to the the long description to supplement
+     * the short description in the <code>alt</code> attribute.
+     * @param longdesc the longdesc.
+     * @jsptagref.attributedescription Specifies a link to the the long description.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_longdesc</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="Specifies a link to the the long description."
+     */
+    public void setLongdesc(String longdesc)
+    {
+        _imgState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, LONGDESC, longdesc);
+    }
+
+    /**
+     * Sets the border size around the image.
+     * @param border the border size.
+     * @jsptagref.attributedescription The border size around the image
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>integer_pixelBorder</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The border size around the image."
+     */
+    public void setBorder(String border)
+    {
+        _imgState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, BORDER, border);
+    }
+
+    /**
+     * Sets the image height.
+     * @param height the height.
+     * @jsptagref.attributedescription The image height
+     * @jsptagref.databindable Read Only
+     * @jsptagref.attributesyntaxvalue <i>integer_height</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The image height."
+     */
+    public void setHeight(String height)
+    {
+        _imgState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HEIGHT, height);
+    }
+
+    /**
+     * Sets the the horizontal spacing around the image.
+     * @param hspace the horizontal spacing.
+     * @jsptagref.attributedescription The horizontal spacing around the image.
+     * @jsptagref.databindable Read Only
+     * @jsptagref.attributesyntaxvalue <i>integer_hspace</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The horizontal spacing around the image."
+     */
+    public void setHspace(String hspace)
+    {
+        _imgState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HSPACE, hspace);
+    }
+
+    /**
+     * Sets the server-side image map declaration.
+     * @param ismap the image map declaration.
+     * @jsptagref.attributedescription The server-side map declaration.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_isMap</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The server-side map declaration."
+     */
+    public void setIsmap(String ismap)
+    {
+        _imgState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ISMAP, ismap);
+    }
+
+    /**
+     * Sets the roll-over image of the ImageAnchor.
+     * @param rolloverImage the rollover image.
+     * @jsptagref.attributedescription The URI of the rollover image.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_rolloverImage</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The URI of the rollover image."
+     */
+    public void setRolloverImage(String rolloverImage)
+    {
+        _rolloverImage = rolloverImage;
+    }
+
+    /**
+     * Sets the image source URI.
+     * @param src the image source URI.
+     * @jsptagref.attributedescription The image source URI
+     * @jsptagref.databindable Read Only
+     * @jsptagref.attributesyntaxvalue <i>string_src</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The image source URI"
+     * reftype="img-url"
+     */
+    public void setSrc(String src)
+            throws JspException
+    {
+        _imgState.src = src;
+    }
+
+    /**
+     * Sets the client-side image map declaration.
+     * @param usemap the map declaration.
+     * @jsptagref.attributedescription The client-side image map declaration
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_useMap</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The client-side image map declaration"
+     */
+    public void setUsemap(String usemap)
+    {
+        _imgState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, USEMAP, usemap);
+    }
+
+    /**
+     * Sets the vertical spacing around the image.
+     * @param vspace the vertical spacing.
+     * @jsptagref.attributedescription The vertical spacing around the image.
+     * @jsptagref.databindable Read Only
+     * @jsptagref.attributesyntaxvalue <i>string_vspace</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The vertical spacing around the image."
+     */
+    public void setVspace(String vspace)
+    {
+        _imgState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, VSPACE, vspace);
+    }
+
+    /**
+     * Set the &lt;img> style for the contained image. When the tag library is
+     * running in legacy mode, this will override the <code>style</code> attribute if that is
+     * set.  If this is not set, and <code>style</code> is set, then it will be applied to
+     * the image.
+     * @param imageStyle the label style
+     * @jsptagref.attributedescription For legacy documents. Specifies style information for the
+     * contained image. When the tag library is running in legacy mode, this will override the
+     * <code>style</code> attribute.  If this is not set, and <code>style</code> is set,
+     * then it will be applied to the image.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_imagestyle</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="Set the style for the contained image."
+     */
+    public void setImageStyle(String imageStyle)
+    {
+        _imgState.style = imageStyle;
+    }
+
+    /**
+     * Set the label style class for each contained Image. When the tag library is
+     * running in legacy mode, this will override the <code>styleClass</code> attribute if that is
+     * set.  If this is not set, and <code>styleClass</code> is set, then it will be applied to
+     * the image.
+     * @param imageClass the image class
+     * @jsptagref.attributedescription For legacy documents. The style class (a style sheet selector).
+     * When the tag library is running in legacy mode, this will override the <code>styleClass</code>
+     * attribute. If this is not set, and <code>styleClass</code> is set, then it will be applied to
+     * the image.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_imageclass</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="Set the label style class for each contained image."
+     */
+    public void setImageStyleClass(String imageClass)
+    {
+        _imgState.styleClass = imageClass;
+    }
+
+    /**
+     * Sets the image width.
+     * @param width the image width.
+     * @jsptagref.attributedescription The image width.
+     * @jsptagref.databindable Read Only
+     * @jsptagref.attributesyntaxvalue <i>integer_pixelWidth</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The image width."
+     */
+    public void setWidth(String width)
+    {
+        _imgState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, WIDTH, width);
+    }
+
+    //******************* Lifecycle Methods ************************************
+    /**
+     * This method will push the Behavior on the behavior stack.  All overrides of
+     * this method should call this method so that the stack is maintained correctly.
+     */
+    public void preRender()
+    {
+    }
+
+    /**
+     * This method will render the start tag for the markup generated by the behavior.
+     * @param appender The <code>Appender</code> to write the markup into.
+     */
+    public void renderStart(Appender appender)
+    {
+        // report errors that may have occurred when the required attributes are being set
+        if (hasErrors()) {
+            reportErrors(appender);
+            return;
+        }
+
+        PageFlowContext pfCtxt = ContextUtils.getPageFlowContext();
+        TagContext tagCtxt = ContextUtils.getTagContext();
+        HttpServletResponse response = pfCtxt.getResponse();
+
+        if (_rolloverImage != null && getJavaScriptAttribute(ONMOUSEOVER) == null) {
+            // cause the roll over script to be inserted
+            ScriptReporter sr = tagCtxt.getScriptReporter();
+            sr.writeFeature(CoreScriptFeature.ROLLOVER, true, false, null);
+        }
+
+        // build the anchor into the results
+        // render the anchor tag
+        _anchorRb = TagRenderingBase.Factory.getRendering(TagRenderingBase.ANCHOR_TAG);
+        if (!createAnchorBeginTag(_anchorRb, appender, REQUIRED_ATTR)) {
+            reportErrors(appender);
+            return;
+        }
+
+        // set the source and lowsrc attributes
+        // the lowsrc is deprecated and should be removed.
+        if (_imgState.src != null) {
+            try {
+                String uri = PageFlowTagUtils.rewriteResourceURL(_imgState.src, null, null);
+                _imgState.src = response.encodeURL(uri);
+            }
+            catch (URISyntaxException e) {
+                // report the error...
+                String s = Bundle.getString("Tags_Image_URLException",
+                        new Object[]{_imgState.src, e.getMessage()});
+                registerTagError(s, e);
+            }
+        }
+
+        // set the rollover image
+        if (_rolloverImage != null) {
+            try {
+                String uri = PageFlowTagUtils.rewriteResourceURL(_rolloverImage, null, null);
+                _rolloverImage = response.encodeURL(uri);
+            }
+            catch (URISyntaxException e) {
+                // report the error...
+                String s = Bundle.getString("Tags_Rollover_Image_URLException",
+                        new Object[]{_rolloverImage, e.getMessage()});
+                registerTagError(s, e);
+            }
+
+            if (getJavaScriptAttribute(ONMOUSEOUT) == null) {
+                String s = "swapImage(this,'" + response.encodeURL(_imgState.src) + "')";
+                _imgState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONMOUSEOUT, s);
+            }
+            if (getJavaScriptAttribute(ONMOUSEOVER) == null) {
+                String s = "swapImage(this,'" + response.encodeURL(_rolloverImage) + "')";
+                _imgState.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONMOUSEOVER, s);
+            }
+        }
+
+        // render the image tag.
+        _imgRb = TagRenderingBase.Factory.getRendering(TagRenderingBase.IMAGE_TAG);
+        _imgRb.doStartTag(appender, _imgState);
+    }
+
+    /**
+     * This method will render teh end tag for the markup generted by the behavior.
+     * @param appender The <code>Appender</code> to write the markup into.
+     */
+    public void renderEnd(Appender appender)
+    {
+        _imgRb.doEndTag(appender);
+        _anchorRb.doEndTag(appender);
+    }
+}

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ImageAnchorBehavior.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ImageBehavior.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ImageBehavior.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ImageBehavior.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ImageBehavior.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,297 @@
+package org.apache.beehive.netui.simpletags.behaviors;
+
+import org.apache.beehive.netui.pageflow.PageFlowContext;
+import org.apache.beehive.netui.simpletags.appender.Appender;
+import org.apache.beehive.netui.simpletags.core.IUrlParams;
+import org.apache.beehive.netui.simpletags.rendering.AbstractHtmlState;
+import org.apache.beehive.netui.simpletags.rendering.ImageTag;
+import org.apache.beehive.netui.simpletags.rendering.TagRenderingBase;
+import org.apache.beehive.netui.simpletags.util.ContextUtils;
+import org.apache.beehive.netui.simpletags.util.PageFlowTagUtils;
+import org.apache.beehive.netui.util.Bundle;
+import org.apache.beehive.netui.util.ParamHelper;
+
+import javax.servlet.jsp.JspException;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ImageBehavior extends HtmlBaseBehavior
+        implements IUrlParams
+{
+    private ImageTag.State _state = new ImageTag.State();
+
+    private String _location = null;         // The location hash to append to the url.
+    private Map _params;
+
+    /**
+     * Return the name of the Tag.
+     */
+    public String getTagName()
+    {
+        return "Image";
+    }
+
+    /**
+     * This method will return the state associated with the tag.  This is used by this
+     * base class to access the individual state objects created by the tags.
+     * @return a subclass of the <code>AbstractHtmlState</code> class.
+     */
+    protected AbstractHtmlState getState()
+    {
+        return _state;
+    }
+
+    /**
+     * Base support for the attribute tag.  This is overridden to prevent setting the <code>src</code>
+     * attribute.
+     * @param name  The name of the attribute.  This value may not be null or the empty string.
+     * @param value The value of the attribute.  This may contain an expression.
+     * @param facet The name of a facet to which the attribute will be applied.  This is optional.
+     */
+    public void setAttribute(String name, String value, String facet)
+    {
+        if (name != null && name.equals(SRC)) {
+            String s = Bundle.getString("Tags_AttributeMayNotBeSet", new Object[]{name});
+            registerTagError(s, null);
+        }
+        super.setAttribute(name, value, facet);
+    }
+
+    /**
+     * Sets the property to specify where to align the image.
+     * @param align the image alignment.
+     * @jsptagref.attributedescription The alignment of the image.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_align</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The alignment of the image."
+     */
+    public void setAlign(String align)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ALIGN, align);
+    }
+
+    /**
+     * Sets the property to specify the alt text of the image.
+     * @param alt the image alignment.
+     * @jsptagref.attributedescription The alternative text of the image
+     * @jsptagref.databindable Read Only
+     * @jsptagref.attributesyntaxvalue <i>string_alt</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The alternative text of the image."
+     */
+    public void setAlt(String alt)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ALT, alt, true);
+    }
+
+    /**
+     * Sets the property to specify a link to the the long description to supplement
+     * the short description in the <code>alt</code> attribute.
+     * @param longdesc the longdesc.
+     * @jsptagref.attributedescription Specifies a link to the the long description.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_longdesc</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="Specifies a link to the the long description."
+     */
+    public void setLongdesc(String longdesc)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, LONGDESC, longdesc);
+    }
+
+    /**
+     * Sets the border size around the image.
+     * @param border the border size.
+     * @jsptagref.attributedescription The border size around the image
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>integer_pixelBorder</i>
+     * @netui:attribute required="false"  rtexprvalue="true"
+     * description="The border size around the image."
+     */
+    public void setBorder(String border)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, BORDER, border);
+    }
+
+    /**
+     * Sets the image height.
+     * @param height the height.
+     * @jsptagref.attributedescription The image height
+     * @jsptagref.databindable Read Only
+     * @jsptagref.attributesyntaxvalue <i>integer_height</i>
+     * @netui:attribute required="false"  rtexprvalue="true"
+     * description="The image height."
+     */
+    public void setHeight(String height)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HEIGHT, height);
+    }
+
+    /**
+     * Sets the the horizontal spacing around the image.
+     * @param hspace the horizontal spacing.
+     * @jsptagref.attributedescription The horizontal spacing around the image.
+     * @jsptagref.databindable Read Only
+     * @jsptagref.attributesyntaxvalue <i>integer_hspace</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The horizontal spacing around the image."
+     */
+    public void setHspace(String hspace)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HSPACE, hspace);
+    }
+
+    /**
+     * Sets the server-side image map declaration.
+     * @param ismap the image map declaration.
+     * @jsptagref.attributedescription The server-side map declaration.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_isMap</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The server-side map declaration."
+     */
+    public void setIsmap(String ismap)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ISMAP, ismap);
+    }
+
+    /**
+     * Sets the location hash to append to the url.
+     * @param location the location hash.
+     * @jsptagref.attributedescription The location hash to append to the URL.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_location</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The location hash to append to the URL."
+     */
+    public void setLocation(String location)
+    {
+        _location = location;
+    }
+
+    /**
+     * Sets the image source URI.
+     * @param src the source URI.
+     * @jsptagref.attributedescription The image source URI
+     * @jsptagref.databindable Read Only
+     * @jsptagref.attributesyntaxvalue <i>string_src</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The image source URI"
+     */
+    public void setSrc(String src)
+            throws JspException
+    {
+        _state.src = src;
+    }
+
+    /**
+     * Sets the client-side image map declaration.
+     * @param usemap the map declaration.
+     * @jsptagref.attributedescription The client-side image map declaration
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_useMap</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The client-side image map declaration"
+     */
+    public void setUsemap(String usemap)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, USEMAP, usemap);
+    }
+
+    /**
+     * Sets the vertical spacing around the image.
+     * @param vspace the vertical spacing.
+     * @jsptagref.attributedescription The vertical spacing around the image.
+     * @jsptagref.databindable Read Only
+     * @jsptagref.attributesyntaxvalue <i>string_vspace</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The vertical spacing around the image."
+     */
+    public void setVspace(String vspace)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, VSPACE, vspace);
+    }
+
+    /**
+     * Sets the image width.
+     * @param width the image width.
+     * @jsptagref.attributedescription The image width.
+     * @jsptagref.databindable Read Only
+     * @jsptagref.attributesyntaxvalue <i>integer_pixelWidth</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The image width."
+     */
+    public void setWidth(String width)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, WIDTH, width);
+    }
+
+    /**
+     * Adds a URL parameter to the generated hyperlink.
+     * @param name  the name of the parameter to be added.
+     * @param value the value of the parameter to be added (a String or String[]).
+     * @param facet
+     */
+    public void addParameter(String name, Object value, String facet)
+    {
+        assert(name != null) : "Parameter 'name' must not be null";
+
+        if (_params == null) {
+            _params = new HashMap();
+        }
+        ParamHelper.addParam(_params, name, value);
+    }
+
+    /**
+     * This method will render the start tag for the markup generated by the behavior.
+     * @param appender The <code>Appender</code> to write the markup into.
+     */
+    public void renderStart(Appender appender)
+    {
+        // report errors that may have occurred
+        if (hasErrors()) {
+            reportErrors(appender);
+            return;
+        }
+
+        // Generate the name definition or image element
+        String uri = null;
+        if (_state.src != null) {
+            try {
+                uri = PageFlowTagUtils.rewriteResourceURL(_state.src, _params, _location);
+            }
+            catch (URISyntaxException e) {
+                // report the error...
+                String s = Bundle.getString("Tags_Image_URLException", new Object[]{_state.src, e.getMessage()});
+                registerTagError(s, e);
+            }
+        }
+
+        if (uri != null) {
+            PageFlowContext pfCtxt = ContextUtils.getPageFlowContext();
+            _state.src = pfCtxt.getResponse().encodeURL(uri);
+        }
+
+        // we assume that tagId will over have override id if both
+        // are defined.
+        if (_state.id != null) {
+            renderNameAndId( _state, null);
+        }
+
+        TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.IMAGE_TAG);
+        br.doStartTag(appender, _state);
+
+    }
+
+    /**
+     * This method will render teh end tag for the markup generted by the behavior.
+     * @param appender The <code>Appender</code> to write the markup into.
+     */
+    public void renderEnd(Appender appender)
+    {
+        TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.IMAGE_TAG);
+        br.doEndTag(appender);
+    }
+}

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ImageBehavior.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ScriptContainerBehavior.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ScriptContainerBehavior.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ScriptContainerBehavior.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ScriptContainerBehavior.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,169 @@
+package org.apache.beehive.netui.simpletags.behaviors;
+
+import org.apache.beehive.netui.simpletags.appender.Appender;
+import org.apache.beehive.netui.simpletags.core.Behavior;
+import org.apache.beehive.netui.simpletags.core.TagContext;
+import org.apache.beehive.netui.simpletags.core.services.IdScopeStack;
+import org.apache.beehive.netui.simpletags.core.services.ScriptReporter;
+import org.apache.beehive.netui.simpletags.rendering.AbstractHtmlState;
+import org.apache.beehive.netui.simpletags.rendering.DivTag;
+import org.apache.beehive.netui.simpletags.rendering.TagRenderingBase;
+import org.apache.beehive.netui.simpletags.util.ContextUtils;
+import org.apache.beehive.netui.simpletags.util.RequestUtils;
+
+public class ScriptContainerBehavior extends Behavior
+{
+    private String _idScope = null;
+    private boolean _genScope = false;
+
+    public final static String SCOPE_ID = "netui:scopeId";
+
+    /**
+     * Returns the name of the Tag.
+     */
+    public String getTagName()
+    {
+        return "ScriptContainer";
+    }
+
+    /////////////////////////// Attributes ////////////////////////////
+
+    /**
+     * Set the idScope associated with the code methods
+     * @jsptagref.attributedescription The id that is associated with the script methods.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_scopeId</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="The id that is associated with the script methods."
+     */
+    public void setIdScope(String idScope)
+    {
+        _idScope = idScope;
+    }
+
+    /**
+     * return the scopeId associated with the ScriptContainer
+     */
+    public String getIdScope()
+    {
+        return _idScope;
+
+    }
+
+    /**
+     * If true generate a scope id for this script container.  If this is set to true
+     * and a scopeId is also set, the scopeId set will be written.
+     * @jsptagref.attributedescription Automatically generate a scopeId for this script container.
+     * @jsptagref.databindable true
+     * @jsptagref.attributesyntaxvalue <i>string_generateScopeId</i>
+     * @netui:attribute required="false" rtexprvalue="true"
+     * description="Automatically generate a ScopeId."
+     */
+    public void setGenerateIdScope(boolean genScopeValue)
+    {
+        _genScope = genScopeValue;
+    }
+
+    //******************* Lifecycle Methods ************************************
+
+    public void preRender()
+    {
+        super.preRender();
+
+        // push the scopeId onto the stack
+        TagContext tagContext = ContextUtils.getTagContext();
+        setRealIdScope(tagContext);
+        pushIdScope(tagContext);
+    }
+
+    public void renderStart(Appender appender)
+    {
+        TagContext tagContext = ContextUtils.getTagContext();
+        ScriptReporter sr = tagContext.getScriptReporter();
+
+        sr.writeBeforeBlocks(appender);
+
+        // if there is a scopeId, then we need to create a div to contains everything
+        if (_idScope != null) {
+            TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.DIV_TAG);
+            DivTag.State state = new DivTag.State();
+            state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, "netui:idScope", _idScope);
+            br.doStartTag(appender,state);
+        }
+    }
+
+    public void renderEnd(Appender appender)
+    {
+        // if we wrote out the scopeId then we end it.
+        if (_idScope != null) {
+            TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.DIV_TAG);
+            br.doEndTag(appender);
+        }
+
+        TagContext tagContext = ContextUtils.getTagContext();
+        ScriptReporter sr = tagContext.getScriptReporter();
+
+        sr.writeFrameworkScript(appender);
+        sr.writeAfterBlocks(appender);
+    }
+
+    public void postRender()
+    {
+        TagContext tagContext = ContextUtils.getTagContext();
+        popIdScope(tagContext);
+    }
+
+    /////////////////////////////////// Private Support ////////////////////////////////////
+
+    /**
+     * If the <code>idScope</code> is set, then we push this onto the id stack.  This method
+     * is called in the <code>preRender</code> method and adds the scope to the stack.  Before this
+     * method is called, the <code>setRealIdScope</code> method must be called to transform the
+     * <code>idScope</code> into the real scoped value.
+     * @param tagCtxt
+     */
+    private void pushIdScope(TagContext tagCtxt)
+    {
+        if (_idScope != null) {
+            IdScopeStack scopeStack = tagCtxt.getIdScopeMgr();
+            scopeStack.push(_idScope);
+        }
+    }
+
+    /**
+     * This method will pop the <code>idScope</code> value off of the id stack.  This methd is
+     * called in the <code>postRender</code> method as the behavior goes out of scope.
+     * @param tagCtxt
+     */
+    private void popIdScope(TagContext tagCtxt)
+    {
+        if (_idScope != null) {
+            IdScopeStack scopeStack = tagCtxt.getIdScopeMgr();
+            String idScope = scopeStack.pop();
+            assert(idScope.equals(_idScope)) : "Mismatch between Id Scopes during pop, found '" +
+                    idScope + "', expected: '" + _idScope + "'";
+        }
+    }
+
+    /**
+     * This method will transform the <code>idScope</code> property into a real
+     * scoped version of the value.  If the <code>idScope</code> is set, that is the scoped value.
+     * Otherwise, if we are genarating a <code>idScope</code> then we generate that here.  The final
+     * place a scope can come from is the <code>ScopeKey</code> set on the request.
+     */
+    private void setRealIdScope(TagContext tagCtxt)
+    {
+        if (_idScope != null)
+                return;
+
+        // if there isn't a set idScope and generate scope is on, generate the scope id.
+        if (_genScope) {
+            int id = tagCtxt.getNextId();
+            _idScope = "n" + Integer.toString(id);
+            return;
+        }
+
+        // check to see if we have a scopeKey
+        _idScope = RequestUtils.getScopeKey();
+    }
+}

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/ScriptContainerBehavior.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/TextBoxBehavior.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/TextBoxBehavior.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/TextBoxBehavior.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/TextBoxBehavior.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,312 @@
+package org.apache.beehive.netui.simpletags.behaviors;
+
+import org.apache.beehive.netui.simpletags.appender.Appender;
+import org.apache.beehive.netui.simpletags.appender.StringBuilderAppender;
+import org.apache.beehive.netui.simpletags.core.IFormattable;
+import org.apache.beehive.netui.simpletags.html.HtmlUtils;
+import org.apache.beehive.netui.simpletags.html.IHtmlAccessable;
+import org.apache.beehive.netui.simpletags.rendering.AbstractHtmlState;
+import org.apache.beehive.netui.simpletags.rendering.InputTextTag;
+import org.apache.beehive.netui.simpletags.rendering.TagRenderingBase;
+import org.apache.beehive.netui.simpletags.behaviors.formatting.Formatter;
+import org.apache.beehive.netui.simpletags.behaviors.formatting.FormatterException;
+import org.apache.beehive.netui.util.Bundle;
+import org.apache.beehive.netui.util.internal.InternalStringBuilder;
+
+import java.util.ArrayList;
+
+public class TextBoxBehavior extends HtmlDefaultableDataSourceBehavior
+    implements IFormattable, IHtmlAccessable
+{
+    private InputTextTag.State _state = new InputTextTag.State();
+
+    private ArrayList _formatters;
+    private boolean _password = false;
+    private boolean _formatErrors = false;
+    private String _bodyContent;
+
+    /**
+     * Return the name of the Tag.
+     */
+    public String getTagName()
+    {
+        return "TextBox";
+    }
+
+    /**
+     * This method will return the state associated with the tag.  This is used by this
+     * base class to access the individual state objects created by the tags.
+     * @return a subclass of the <code>AbstractHtmlState</code> class.
+     */
+    protected AbstractHtmlState getState()
+    {
+        return _state;
+    }
+
+    /**
+     * Base support for the attribute tag.  This is overridden to prevent setting the <code>type</code>,
+     * and <code>value</code> attributes.
+     * @param name  The name of the attribute.  This value may not be null or the empty string.
+     * @param value The value of the attribute.  This may contain an expression.
+     * @param facet The name of a facet to which the attribute will be applied.  This is optional.
+     */
+    public void setAttribute(String name, String value, String facet)
+    {
+        if (name != null) {
+            if (name.equals(TYPE) || name.equals(VALUE)) {
+                String s = Bundle.getString("Tags_AttributeMayNotBeSet", new Object[]{name});
+                registerTagError(s, null);
+            }
+            else {
+                if (name.equals(DISABLED)) {
+                    _state.disabled = new Boolean(value).booleanValue();
+                    return;
+                }
+                else if (name.equals(READONLY)) {
+                    _state.readonly = new Boolean(value).booleanValue();
+                    return;
+                }
+                else if (name.equals(MAXLENGTH)) {
+                    _state.maxlength = Integer.parseInt(value);
+                    return;
+                }
+                else if (name.equals(SIZE)) {
+                    _state.size = Integer.parseInt(value);
+                    return;
+                }
+            }
+        }
+
+        super.setAttribute(name, value, facet);
+    }
+
+    //********************************  ATTRIBUTES *******************************
+
+    /**
+     * Set the maximum length (in characters) of the TextBox.
+     * @param maxlength the max length
+     * @jsptagref.attributedescription Integer. The maximum number of character that can be entered in the rendered &lt;input> element.
+     * @jsptagref.databindable Read Only
+     * @jsptagref.attributesyntaxvalue <i>integer_maxLength</i>
+     * @netui:attribute required="false" rtexprvalue="true" type="int"
+     * description="The maximum number of character that can be entered in the rendered <input> element."
+     */
+    public void setMaxlength(int maxlength)
+    {
+        _state.maxlength = maxlength;
+    }
+
+    /**
+     * Set the password state (true means this is a password field).
+     * @param password the password state
+     * @jsptagref.attributedescription Boolean. Determines whether the password characters that the user enters into the &lt;input> element will be disguised in the browser.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>boolean_password</i>
+     * @netui:attribute required="false" rtexprvalue="true" type="boolean"
+     * description="Determines whether the password characters that the user enters into the &lt;input> element will be disguised in the browser."
+     */
+    public void setPassword(boolean password)
+    {
+        _password = password;
+    }
+
+    /**
+     * Get the password state.
+     * @return <code>true</code> if the text box is used for passwords.  <code>false</code> otherwise.
+     */
+    protected boolean getPassword()
+    {
+        return _password;
+    }
+
+    /**
+     * Set if this TextBox is read-only.
+     * @param readonly the read-only state
+     * @jsptagref.attributedescription Boolean. Determines if the rendered &lt;input> element is read-only.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>boolean_readOnly</i>
+     * @netui:attribute required="false" rtexprvalue="true" type="boolean"
+     * description="Determines if the rendered &lt;input> element is read-only"
+     */
+    public void setReadonly(boolean readonly)
+    {
+        _state.readonly = readonly;
+    }
+
+    /**
+     * Set the size (in characters) of the TextBox.
+     * @param size the size
+     * @jsptagref.attributedescription Integer. The number of characters visible in the &lt;input> element.
+     * @jsptagref.databindable Read Only
+     * @jsptagref.attributesyntaxvalue <i>integer_size</i>
+     * @netui:attribute required="false" rtexprvalue="true" type="int"
+     * description="The number of characters visible in the <input> element."
+     */
+    public void setSize(int size)
+    {
+        _state.size = size;
+    }
+
+    /**
+     * Sets the accessKey attribute value.  This should key value of the
+     * keyboard navigation key.  It is recommended not to use the following
+     * values because there are often used by browsers <code>A, C, E, F, G,
+     * H, V, left arrow, and right arrow</code>.
+     * @param accessKey the accessKey value.
+     * @jsptagref.attributedescription The keyboard navigation key for the element.
+     * The following values are not recommended because they
+     * are often used by browsers: <code>A, C, E, F, G,
+     * H, V, left arrow, and right arrow</code>
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_accessKey</i>
+     * @netui:attribute required="false" rtexprvalue="true" type="char"
+     * description="The keyboard navigation key for the element.
+     * The following values are not recommended because they
+     * are often used by browsers: A, C, E, F, G,
+     * H, V, left arrow, and right arrow"
+     */
+    public void setAccessKey(char accessKey)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ACCESSKEY, Character.toString(accessKey));
+    }
+
+    /**
+     * Sets the alt attribute value.
+     * @param alt the alt value.
+     * @jsptagref.attributedescription The alt attribute of the element.
+     * @jsptagref.databindable Read Only
+     * @jsptagref.attributesyntaxvalue <i>string_alt</i>
+     * @netui:attribute required="false"  rtexprvalue="true"
+     * description="The alt attribute of the element."
+     */
+    public void setAlt(String alt)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ALT, alt);
+    }
+
+    /**
+     * Sets the tabIndex of the rendered html tag.
+     * @param tabindex the tab index.
+     * @jsptagref.attributedescription The tabIndex of the rendered HTML tag.  This attribute determines the position of the
+     * tag in the sequence of page elements that the user may advance through by pressing the TAB key.
+     * @jsptagref.databindable false
+     * @jsptagref.attributesyntaxvalue <i>string_tabIndex</i>
+     * @netui:attribute required="false" rtexprvalue="true" type="int"
+     * description="The tabIndex of the rendered HTML tag.  This attribute determines the position of the
+     * tag in the sequence of page elements that the user may advance through by pressing the TAB key."
+     */
+    public void setTabindex(int tabindex)
+    {
+        _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, TABINDEX, Integer.toString(tabindex));
+    }
+
+    public void preRender()
+    {
+        super.preRender();
+
+        // Create an appropriate "input" element based on our parameters
+        if (_password) {
+            _state.type = INPUT_PASSWORD;
+        }
+        else {
+            _state.type = INPUT_TEXT;
+        }
+
+        // Create the state for the input tag
+        nameHtmlControl(_state);
+
+        _state.disabled = isDisabled();
+        // Create the text value of the TextBox
+        Object textObject = evaluateDataSource();
+        if ((textObject == null) || (textObject.toString().length() == 0)) {
+            textObject = _defaultValue;
+        }
+
+        // Get the text value for the textbox, the result
+        String text = null;
+        if (textObject != null) {
+            text = formatText(textObject);
+            InternalStringBuilder sb = new InternalStringBuilder(text.length() + 16);
+            Appender sbAppend = new StringBuilderAppender(sb);
+            HtmlUtils.filter(text, sbAppend);
+            text = sb.toString();
+        }
+        _state.value = text;
+
+    }
+
+    public void renderStart(Appender appender)
+    {
+        // if there were format errors then report them
+        // @todo: how do we do this?
+        if (_formatErrors) {
+            if (_bodyContent != null) {
+                String value = _bodyContent.trim();
+                appender.append(value);
+            }
+        }
+        if (hasErrors()) {
+            reportErrors(appender);
+            return;
+        }
+
+        // create the input tag.
+        TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.INPUT_TEXT_TAG);
+        assert(br != null) : "Renderer for Textbox was not found.";
+
+        br.doStartTag(appender, _state);
+    }
+
+    public void renderEnd(Appender appender)
+    {
+        TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.INPUT_TEXT_TAG);
+        assert(br != null);
+
+        br.doEndTag(appender);
+    }
+
+    //*************************************** TAG METHODS *****************************************
+
+    /**
+     * Adds a FormatTag.Formatter to the TextBox's set of formatters
+     * @param formatter a FormatTag.Formatter added by a child FormatTag.
+     */
+    public void addFormatter(Formatter formatter)
+    {
+        if (_formatters == null)
+            _formatters = new ArrayList();
+
+        _formatters.add(formatter);
+    }
+
+    /**
+     * Indicate that a formatter has reported an error so the formatter should output it's
+     * body text.
+     */
+    public void formatterHasError()
+    {
+        _formatErrors = true;
+    }
+
+    /**
+     * Apply the formatters to the text to produce the text that will be output.
+     */
+    private String formatText(Object text)
+    {
+        assert(text != null) : "parameter 'text' must not be null";
+
+        if (_formatters == null)
+            return text.toString();
+
+        for (int i = 0; i < _formatters.size(); i++) {
+            Formatter currentFormatter = (Formatter) _formatters.get(i);
+            try {
+                text = currentFormatter.format(text);
+            }
+            catch (FormatterException e) {
+                registerTagError(e.getMessage(), null);
+            }
+        }
+        return text.toString();
+    }
+}

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/TextBoxBehavior.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/formatting/DateFormatter.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/formatting/DateFormatter.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/formatting/DateFormatter.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/formatting/DateFormatter.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,160 @@
+package org.apache.beehive.netui.simpletags.behaviors.formatting;
+
+import org.apache.beehive.netui.util.Bundle;
+import org.apache.beehive.netui.util.internal.InternalStringBuilder;
+import org.apache.beehive.netui.util.logging.Logger;
+
+import java.text.DateFormat;
+import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+
+/**
+ * This class is a <code>Formatter</code> for formatting dates.  It defers
+ * to the underlying Java date formatting.
+ */
+public class DateFormatter extends Formatter
+{
+    private static final Logger logger = Logger.getInstance(DateFormatter.class);
+
+    private static final String[] commonFormats = {"MM/dd/yy", "yyyy-MM-dd", "MMddyy",
+            null};
+
+    private Locale _locale;
+    private String _inputPattern;
+
+    /**
+     * Set the pattern to use to convert a String value into a date.  This
+     * will be used before the common formats.
+     */
+    public void setStringInputPattern(String inputPattern)
+    {
+        _inputPattern = inputPattern;
+    }
+
+    /**
+     * Set the Locale which is used to format the date in some cases.
+     * @param locale
+     */
+    public void setLocale(Locale locale)
+    {
+        _locale = locale;
+    }
+
+    /**
+     * This method applies the formatting to the passed in object.
+     * @param dataToFormat
+     * @return A string representing the object formatted as a date.
+     * @throws FormatterException When there is a failure in formatting 
+     */
+    public String format(Object dataToFormat)
+            throws FormatterException
+    {
+        if (dataToFormat == null) {
+            return null;
+        }
+        InternalStringBuilder formattedString = new InternalStringBuilder(32);
+
+        SimpleDateFormat dateFormat = null;
+        if (getPattern() != null) {
+            try {
+                if (_locale != null) {
+                    dateFormat = new SimpleDateFormat(getPattern(), _locale);
+                }
+                else {
+                    dateFormat = new SimpleDateFormat(getPattern());
+                }
+            }
+            catch (IllegalArgumentException e) {
+                String s = Bundle.getString("Tags_DateFormatPatternException", new Object[]{e.getMessage()});
+                logger.warn(s);
+                registerError(s,e);
+                throw new FormatterException(s,e);
+            }
+        }
+        else {
+            dateFormat = new SimpleDateFormat();
+        }
+
+        if (dataToFormat instanceof java.sql.Date) {
+
+            java.sql.Date date = (java.sql.Date) dataToFormat;
+            formattedString.append(dateFormat.format(date));
+        }
+        else if (dataToFormat instanceof java.util.Date) {
+
+            java.util.Date date = (java.util.Date) dataToFormat;
+            formattedString.append(dateFormat.format(date));
+        }
+        else if (dataToFormat instanceof java.util.Calendar) {
+            java.util.Calendar c = (java.util.Calendar) dataToFormat;
+            java.util.Date date = new java.util.Date(c.getTimeInMillis());
+            formattedString.append(dateFormat.format(date));
+        }
+        else if (dataToFormat instanceof String) {
+            if (dataToFormat.equals("")) {
+                return "";
+            }
+
+            DateFormat df = null;
+            if (_inputPattern != null) {
+                try {
+                    df = new SimpleDateFormat(_inputPattern);
+                }
+                catch (IllegalArgumentException e) {
+                    String s = Bundle.getString("Tags_formatDate_StringPatternError",
+                            new Object[]{_inputPattern, e.getMessage()});
+                    logger.warn(s);
+                    registerError(s,e);
+                    throw new FormatterException(s,e);
+                }
+
+                // let try and convert this to some type of date
+                java.util.Date date = df.parse((String) dataToFormat,
+                        new ParsePosition(0));
+                if (date != null) {
+                    formattedString.append(dateFormat.format(date));
+                    return formattedString.toString();
+                }
+            }
+
+            // this will loop through all of the formats and
+            // try to convert the date to one of them.
+            int i;
+            for (i = 0; i < commonFormats.length; i++) {
+
+                if (commonFormats[i] != null) {
+                    df = new SimpleDateFormat(commonFormats[i]);
+                }
+                else {
+                    df = new SimpleDateFormat();
+
+                }
+
+                // let try and convert this to some type of date
+                java.util.Date date = df.parse((String) dataToFormat,
+                        new ParsePosition(0));
+                if (date != null) {
+                    formattedString.append(dateFormat.format(date));
+                    break;
+                }
+            }
+            if (i == commonFormats.length) {
+                String s = Bundle.getString("Tags_formatDate_String_Error",
+                        new Object[]{dataToFormat});
+                logger.error(s);
+                registerError(s,null);
+                throw new FormatterException(s);
+            }
+        }
+        else {
+            String s = Bundle.getString("Tags_formatDate_Type_Error",
+                    new Object[]{dataToFormat.getClass().getName()});
+            logger.error(s);
+            registerError(s,null);
+            throw new FormatterException(s);
+        }
+
+        return formattedString.toString();
+    }
+}

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/formatting/DateFormatter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/formatting/Formatter.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/formatting/Formatter.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/formatting/Formatter.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/formatting/Formatter.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,136 @@
+package org.apache.beehive.netui.simpletags.behaviors.formatting;
+
+import org.apache.beehive.netui.simpletags.util.PageFlowAdaptor;
+import org.apache.beehive.netui.util.Bundle;
+
+import javax.servlet.jsp.JspException;
+import java.util.Locale;
+
+/**
+ * This is the base class for all formatters.
+ */
+abstract public class Formatter
+{
+    private String _language = null;
+    private String _country = null;
+    private String _pattern = null;
+
+    private String _errorMsg = null;
+    private Throwable _errorCause = null;
+
+    /**
+     * Sets the language code for the locale.
+     */
+    public void setLanguage(String language)
+    {
+        _language = language;
+    }
+
+    /**
+     * Sets the country code for the locale.
+     */
+    public void setCountry(String country)
+    {
+        _country = country;
+    }
+
+    /**
+     * Sets the pattern to be used by this FormatTag.
+     * @param pattern the pattern used during formatting.
+     */
+    public void setPattern(String pattern)
+    {
+        _pattern = pattern;
+    }
+
+
+    /**
+     * This method will return the pattern that was set on the Formatter.
+     * @return The pattern that was set.
+     */
+    public String getPattern()
+    {
+        return _pattern;
+    }
+
+    /**
+     * If formatting causes an error, then the formatter will set
+     * an error message.  This indicates that an error has occurred.
+     * This method will return a boolean value indicating if an error has
+     * occurred or not.
+     * @return returns <code>true</code> if an Error has occurred.
+     */
+    public boolean hasError()
+    {
+        return (_errorMsg != null);
+    }
+
+    /**
+     * This method returns the text of the error messages if an error has occurred
+     * during the formatting of the text.
+     * @return The text of the error message or null if no error has occurred.
+     */
+    public String getErrorMessage()
+    {
+        return _errorMsg;
+    }
+
+    /**
+     * This method will return the <code>Throwable</code> that was register
+     * when an error occurred during formatting.
+     * @return a <code>Throwable</code> that resulted in an error during formatting or null
+     */
+    public Throwable getErrorCause()
+    {
+        return _errorCause;
+    }
+
+    /**
+     * This is method is called by <code>Formatter</code>s when an error occurs during
+     * formatting.  When this method is called, it will implicitly set the <code>hasError</code>
+     * to true if the <code>errorMsg</code> parameter is non-null.
+     * @param errorMsg The error message
+     */
+    protected void registerError(String errorMsg, Throwable cause) {
+        _errorMsg = errorMsg;
+        _errorCause = cause;
+    }
+
+    /**
+     * A <code>Formatter</code> must implement this method to format the passed
+     * in <code>Object</code>.  If an error occurs during formatting, the <code>
+     * Formatter</code> should call the <code>setErrorMessage</code> method with
+     * the text of the error.
+     * @param dataToFormat An object that is is being formatted.
+     * @return A string representing the formatted object.
+     */
+    abstract public String format(Object dataToFormat)
+        throws FormatterException;
+
+    /**
+     * Returns the locale based on the country and language.
+     * @return the locale
+     */
+    public Locale getLocale()
+            throws JspException
+    {
+        Locale loc = null;
+        if (_language != null || _country != null) {
+            // language is required
+            if (_language == null) {
+                String s = Bundle.getString("Tags_LocaleRequiresLanguage", new Object[]{_country});
+                registerError(s, null);
+                return PageFlowAdaptor.getUserLocale();
+            }
+
+            if (_country == null)
+                loc = new Locale(_language);
+            else
+                loc = new Locale(_language, _country);
+        }
+        else
+            loc =PageFlowAdaptor.getUserLocale();
+
+        return loc;
+    }
+}

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/formatting/Formatter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/formatting/FormatterException.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/formatting/FormatterException.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/formatting/FormatterException.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/formatting/FormatterException.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,21 @@
+package org.apache.beehive.netui.simpletags.behaviors.formatting;
+
+/**
+ * This class is thrown by a <code>Formatter</code> when an error
+ * occurs during formatting.
+ */
+public class FormatterException extends IllegalArgumentException
+{
+    public FormatterException() {
+        super();
+    }
+    public FormatterException(String message) {
+        super(message);
+    }
+    public FormatterException(String message, Throwable cause) {
+        super(message,cause);
+    }
+    public FormatterException(Throwable cause) {
+        super(cause);
+    }
+}

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/behaviors/formatting/FormatterException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/AbstractPageError.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/AbstractPageError.java?rev=326581&view=auto
==============================================================================
--- beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/AbstractPageError.java (added)
+++ beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/AbstractPageError.java Wed Oct 19 08:29:22 2005
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.simpletags.core;
+
+/**
+ * This is a "struct" class that contains the base information for
+ * an error occuring in a tag on a page.
+ */
+abstract public class AbstractPageError
+{
+    /**
+     * The number of the error on the page.
+     */
+    public int errorNo;
+
+    /**
+     * The number of the error on the page.
+     */
+    public String tagType;
+}
+

Propchange: beehive/trunk/netui/src/simple-tags/org/apache/beehive/netui/simpletags/core/AbstractPageError.java
------------------------------------------------------------------------------
    svn:eol-style = native