Author: dolander
Date: Thu Jan 27 07:46:32 2005
New Revision: 126620

URL: http://svn.apache.org/viewcvs?view=rev&rev=126620
Log:
Create a ScriptTag which will replace the rendering of the HTML Script
Remove a bunch of dead code due to the refactoring of ScriptRequestState



Added:
   
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/rendering/ScriptTag.java
Modified:
   
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java
   
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java
   
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlConstants.java
   
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupSupport.java
   
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptBlock.java
   
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptContainer.java
   
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptRequestState.java
   
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/rendering/TagRenderingBase.java
   
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java

Modified: 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java?view=diff&rev=126620&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java&r1=126619&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java&r2=126620
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java
      (original)
+++ 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java
      Thu Jan 27 07:46:32 2005
@@ -441,7 +441,8 @@
         if (_state.onClick == null) {
             if (_formSubmit && formAction != null) {
                 String realFormName = getFormId();
-                _state.onClick = srs.writeAnchorFormSubmitAction(realFormName, 
_state.href);
+                _state.onClick = 
ScriptRequestState.getString("anchorFormSubmitAction",
+                        new Object[] {realFormName, _state.href});
                 if (_form != null)
                     _form.insureRealId();
             }
@@ -464,7 +465,7 @@
                 srs.writeFeature(getScriptReporter(), scriptWriter, 
CoreScriptFeature.ANCHOR_SUBMIT,true,false,
                         null);
             if (_popupSupport != null)
-                _popupSupport.writeScript(srs, getScriptReporter(), 
scriptWriter);
+                _popupSupport.writeScript(request, srs, getScriptReporter(), 
scriptWriter);
             if (idScript != null)
                 scriptWriter.append(idScript);
             scriptRef.setRef(script.toString());

Modified: 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java?view=diff&rev=126620&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java&r1=126619&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java&r2=126620
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java
     (original)
+++ 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java
     Thu Jan 27 07:46:32 2005
@@ -549,56 +549,6 @@
     }
 
     /**
-     * This method will add a tagId and value to the ScriptRepoter TagId map.
-     * The a ScriptContainer tag will create a JavaScript table that allows
-     * the container, such as a portal, to rewrite the id so it's unique.
-     * The real name may be looked up based  upon the tagId.
-     *
-     * If the no ScriptReporter is found, a script string will be returned
-     * to the caller so they can output the script block.
-     * @param tagId
-     * @param value
-     * @return String
-     */
-    /*
-    // @todo: delete this
-    protected String mapLegacyTagId(String tagId, String value)
-    {
-        IScriptReporter scriptReporter = getScriptReporter();
-        if (scriptReporter != null) {
-            scriptReporter.addLegacyTagIdMappings(tagId, value);
-            return null;
-        }
-
-        // without a scripRepoter we need to create the actual JavaScript that 
will be written out
-        ScriptRequestState jsu = 
ScriptContainer.getScriptRequestState((HttpServletRequest) 
pageContext.getRequest());
-        StringBuilder sb = new StringBuilder(64);
-        StringBuilderRenderAppender writer = new 
StringBuilderRenderAppender(sb);
-        jsu.getTagIdMapping(tagId, value, writer);
-        return sb.toString();
-    }
-    */
-
-    /*
-    // @todo: delete this
-    protected String mapTagId(String tagId, String realId, String realName)
-    {
-        IScriptReporter scriptReporter = getScriptReporter();
-        if (scriptReporter != null) {
-            scriptReporter.addTagIdMappings(tagId, realId, realName);
-            return null;
-        }
-
-        // without a scripRepoter we need to create the actual JavaScript that 
will be written out
-        ScriptRequestState jsu = 
ScriptContainer.getScriptRequestState((HttpServletRequest) 
pageContext.getRequest());
-        StringBuilder sb = new StringBuilder(128);
-        StringBuilderRenderAppender writer = new 
StringBuilderRenderAppender(sb);
-        jsu.getTagIdMapping(tagId, realId, realName, writer);
-        return sb.toString();
-    }
-    */
-
-    /**
      * This method will take any absolute URL that doesn't contain the scheme 
part and append
      * the context path.  In other words, if the URL starts with '/' and the 
context path isn't
      * present it will be added.

Modified: 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlConstants.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlConstants.java?view=diff&rev=126620&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlConstants.java&r1=126619&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlConstants.java&r2=126620
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlConstants.java
   (original)
+++ 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlConstants.java
   Thu Jan 27 07:46:32 2005
@@ -268,6 +268,11 @@
     /**
      * The name of the <code>longdesc</code> attribute.
      */
+    static final String LANGUAGE = "language";
+
+    /**
+     * The name of the <code>longdesc</code> attribute.
+     */
     static final String LONGDESC = "longdesc";
 
     /**
@@ -523,6 +528,11 @@
      * The name of the <code>option</code> element.
      */
     static final String OPTION = "option";
+
+    /**
+     * The name of the <code>script</code> element.
+     */
+    static final String SCRIPT = "script";
 
     /**
      * The name of the <code>select</code> element.

Modified: 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupSupport.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupSupport.java?view=diff&rev=126620&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupSupport.java&r1=126619&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupSupport.java&r2=126620
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupSupport.java
    (original)
+++ 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupSupport.java
    Thu Jan 27 07:46:32 2005
@@ -170,7 +170,7 @@
         return ret;
     }
     
-    public void writeScript(ScriptRequestState srs, IScriptReporter 
scriptReporter, AbstractRenderAppender results)
+    public void writeScript(ServletRequest req, ScriptRequestState srs, 
IScriptReporter scriptReporter, AbstractRenderAppender results)
     {
         // Write the generic function for popping a window.
         srs.writeFeature(scriptReporter, results, 
CoreScriptFeature.POPUP_FUNC, true, false, null);
@@ -182,7 +182,7 @@
             scriptReporter.addScriptFunction(func);
         }
         else {
-            ScriptRequestState.writeScriptBlock(results, func);
+            ScriptRequestState.writeScriptBlock(req, results, func);
         }
     }
     

Modified: 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptBlock.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptBlock.java?view=diff&rev=126620&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptBlock.java&r1=126619&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptBlock.java&r2=126620
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptBlock.java
       (original)
+++ 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptBlock.java
       Thu Jan 27 07:46:32 2005
@@ -87,7 +87,7 @@
 
         // if we are writting the javaScript inline then do it....
        if (_placement == Placement.INLINE || sr == null) {
-            ScriptRequestState.writeScriptBlock(writer,script);
+            
ScriptRequestState.writeScriptBlock(pageContext.getRequest(),writer,script);
             return;
         }
 

Modified: 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptContainer.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptContainer.java?view=diff&rev=126620&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptContainer.java&r1=126619&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptContainer.java&r2=126620
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptContainer.java
   (original)
+++ 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptContainer.java
   Thu Jan 27 07:46:32 2005
@@ -428,7 +428,7 @@
 
         String s = ScriptRequestState.getString("defineNetUI", null);
         assert(s != null) : "Didn't find the Script 'defineNetUI'";
-        ScriptRequestState.writeScriptBlock(sb, s);
+        ScriptRequestState.writeScriptBlock(pageContext.getRequest(),sb, s);
     }
 
     protected void writeBeforeBlocks(AbstractRenderAppender sb)
@@ -441,7 +441,7 @@
             s.append(code);
             s.append("\n");
         }
-        ScriptRequestState.writeScriptBlock(sb, s.toString());
+        ScriptRequestState.writeScriptBlock(pageContext.getRequest(),sb, 
s.toString());
 
     }
 
@@ -455,7 +455,7 @@
             s.append(code);
             s.append("\n");
         }
-        ScriptRequestState.writeScriptBlock(sb, s.toString());
+        ScriptRequestState.writeScriptBlock(pageContext.getRequest(),sb, 
s.toString());
     }
 
     /**
@@ -621,6 +621,7 @@
         ScriptRequestState srs = (ScriptRequestState) 
RequestUtils.getOuterAttribute(request,JAVASCRIPT_STATUS);
         if (srs == null) {
             srs = new ScriptRequestState();
+            srs.setRequest(request);
             RequestUtils.setOuterAttribute(request,JAVASCRIPT_STATUS, srs);
         }
         assert (srs != null);

Modified: 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptRequestState.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptRequestState.java?view=diff&rev=126620&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptRequestState.java&r1=126619&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptRequestState.java&r2=126620
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptRequestState.java
        (original)
+++ 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptRequestState.java
        Thu Jan 27 07:46:32 2005
@@ -18,9 +18,9 @@
 package org.apache.beehive.netui.tags.javascript;
 
 import org.apache.beehive.netui.tags.TagConfig;
-import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender;
-import org.apache.beehive.netui.tags.rendering.StringBuilderRenderAppender;
+import org.apache.beehive.netui.tags.rendering.*;
 
+import javax.servlet.ServletRequest;
 import java.io.Serializable;
 import java.text.MessageFormat;
 import java.util.ResourceBundle;
@@ -34,20 +34,28 @@
 {
     private static final String BUNDLE_NAME = 
"org.apache.beehive.netui.tags.javascript.javaScript";
 
-    // bit positions for the JavaScript features that can be written out.
-    private static final int LEGACY_LOOKUP = 0x0001;
-    private static final int ID_LOOKUP = 0x0002;
-    private static final int NAME_LOOKUP = 0x0004;
-    private static final int SCOPE_LOOKUP = 0x0008;
-    private static final int ALLOCATE_LEGACY = 0x0080;
-    private static final int ALLOCATE_ID = 0x0100;
-    private static final int ALLOCATE_NAME = 0x0200;
-    private static final int LEGACY_SCOPE_LOOKUP = 0x0400;
-   
     private int _javaScriptFeatures;            // this is a integer bitmap 
indicating various feature have been written out or not
     private static ResourceBundle _bundle;      // This points to the bundle
+    ServletRequest _req;
 
 
+    /**
+     *
+     * @param req
+     */
+    public void setRequest(ServletRequest req) {
+        _req = req;
+    }
+
+    /**
+     *
+     * @param scriptReporter
+     * @param results
+     * @param feature
+     * @param singleInstance
+     * @param inline
+     * @param args
+     */
     public void writeFeature(IScriptReporter scriptReporter, 
AbstractRenderAppender results,
                              CoreScriptFeature feature, boolean 
singleInstance, boolean inline,
                              Object[] args)
@@ -63,29 +71,13 @@
         String s = getString(jsKey, args);
         
         if (inline || scriptReporter == null) {
-            writeScriptBlock(results,s);
+            writeScriptBlock(_req,results,s);
             return;
         }
         
         scriptReporter.addScriptFunction(s);
     }
 
-    private String getFeatureKey(CoreScriptFeature feature)
-    {
-        switch (feature) {
-            case ANCHOR_SUBMIT:
-                return "anchorFormSubmit";
-            case SET_FOCUS:
-                return "setFocus";
-            case POPUP_FUNC:
-                return "popupFunc";
-            case ROLLOVER:
-                return "rollover";
-        }
-        assert(false) : "getFeature Fell through on feature:" + feature;
-        return null;
-    }
-
     /**
      *
      * @param scriptReporter
@@ -135,177 +127,6 @@
     }
 
     /**
-     * @param scriptReporter
-     * @param results
-     */
-    /*
-    public void writeAnchorFormSubmit(IScriptReporter scriptReporter, 
AbstractRenderAppender results)
-
-        // check to see if we have already written out the form submit
-        if ((_javaScriptFeatures & ANCHOR_SUBMIT) != 0)
-            return;
-        _javaScriptFeatures |= ANCHOR_SUBMIT;
-
-        // get the method and write it.
-        String s = getString("anchorFormSubmit", null);
-
-        // if we passed in a script reporter, it will handle the
-        // javaScript, otherwise update the buffer by writing a
-        // script block into it.
-        if (scriptReporter != null) {
-            scriptReporter.addScriptFunction(s);
-            return;
-        }
-
-        writeScriptBlock(results, s);
-    }
-    */
-
-    /**
-     * This will create the onClick JavaScript that will cause an anchor to 
submit a form.
-     * @param action
-     * @param newAction
-     * @return
-     */
-    public String writeAnchorFormSubmitAction(String action, String newAction)
-    {
-        assert (action != null);
-        assert (newAction != null);
-        
-        // @TODO: Need to escape the action? and newAction/
-        String s = getString("anchorFormSubmitAction",
-                             new Object[]{action, newAction});
-        return s;
-    }
-    
-    /**
-     * @param scriptReporter
-     * @param results
-     */
-    /*
-    public void writePopupFunc(IScriptReporter scriptReporter, 
AbstractRenderAppender results)
-    {
-        // check to see if we have already written out the popup function
-        if ((_javaScriptFeatures & POPUP_FUNC) != 0)
-            return;
-        _javaScriptFeatures |= POPUP_FUNC;
-
-        // get the method and write it.
-        String s = getString("popupFunc", null);
-
-        // if we passed in a script reporter, it will handle the
-        // javaScript, otherwise update the buffer by writing a
-        // script block into it.
-        if (scriptReporter != null) {
-            scriptReporter.addScriptFunction(s);
-            return;
-        }
-
-        writeScriptBlock(results, s);
-    }
-    */
-
-    /**
-     * this will write out the form focus script block
-     * @param formName
-     * @param fieldName
-     * @param results
-     */
-    /*
-    public static void getFocusScript(String formName, String fieldName, 
AbstractRenderAppender results)
-    {
-        assert (formName != null);
-        assert (fieldName != null);
-
-        // @TODO: Need to escaping
-        String s = getString("setFocus", new Object[]{formName, fieldName});
-        writeScriptBlock(results, s);
-    }
-    */
-
-    /**
-     * This method will write out a tagId map entry for when there
-     * isn't a ScriptContainer defined.
-     * @param tagId   the tagId value
-     * @param value   the "real" value of the written out
-     * @param results the JavaScript that will be output
-     */
-    private void getTagIdMapping(String tagId, String value, 
AbstractRenderAppender results)
-    {
-        if ((_javaScriptFeatures & CoreScriptFeature.ALLOCATE_LEGACY.value) == 
0) {
-            _javaScriptFeatures |= CoreScriptFeature.ALLOCATE_LEGACY.value;
-            String s = getString("singleIdMappingTable", new Object[]{tagId, 
value});
-            String meths = writeNetuiNameFunctions(null, true, false, false);
-            if (meths != null)
-                s += meths;
-            writeScriptBlock(results, s);
-        }
-        else {
-            String s = getString("idMappingEntry", new Object[]{tagId, value});
-            writeScriptBlock(results, s);
-
-        }
-    }
-
-    /**
-     * @param tagId
-     * @param realId
-     * @param realName
-     * @param results
-     */
-    private void getTagIdMapping(String tagId, String realId, String realName, 
AbstractRenderAppender results)
-    {
-        StringBuilder sb = new StringBuilder(128);
-        if (realId != null) {
-            if ((_javaScriptFeatures & CoreScriptFeature.ALLOCATE_ID.value) == 
0) {
-                _javaScriptFeatures |= CoreScriptFeature.ALLOCATE_ID.value;
-                String meths = writeNetuiNameFunctions(null, false, true, 
false);
-                if (meths != null)
-                    sb.append(meths);
-            }
-        }
-
-        if (realName != null) {
-            if ((_javaScriptFeatures & CoreScriptFeature.ALLOCATE_NAME.value) 
== 0) {
-                _javaScriptFeatures |= CoreScriptFeature.ALLOCATE_NAME.value;
-                String s = getString("singleIdToNameMappingTable", new 
Object[]{tagId, realName});
-                String meths = writeNetuiNameFunctions(null, false, false, 
true);
-                if (meths != null)
-                    s += meths;
-                sb.append(s);
-            }
-            else {
-                String s = getString("tagIdNameMappingEntry", new 
Object[]{tagId, realName});
-                sb.append(s);
-            }
-        }
-        writeScriptBlock(results, sb.toString());
-    }
-
-    /**
-     * @param scriptReporter
-     * @param results
-     */
-    /*
-    public void writeRollover(IScriptReporter scriptReporter, 
AbstractRenderAppender results)
-    {
-        // check if we have already written out the rollover feature
-        if ((_javaScriptFeatures & ROLLOVER) != 0)
-            return;
-        _javaScriptFeatures |= ROLLOVER;
-
-        String s = getString("rollover", null);
-        if (scriptReporter != null) {
-            scriptReporter.addScriptFunction(s);
-            return;
-        }
-
-        writeScriptBlock(results, s);
-        return;
-    }
-    */
-
-    /**
      * @param scriptRepoter
      * @param mapObj
      * @param entries
@@ -337,20 +158,20 @@
 
         // if we are supporting legacy javascript then output the original 
javascript method
         if (TagConfig.isLegacyJavaScript() && writeLegacy) {
-            writeLookupMethod(scriptReporter, sb, "getNetuiTagNameAdvanced", 
LEGACY_LOOKUP);
-            writeLookupMethod(scriptReporter, sb, "getScopeId", 
LEGACY_SCOPE_LOOKUP);
+            writeLookupMethod(scriptReporter, sb, "getNetuiTagNameAdvanced", 
CoreScriptFeature.LEGACY_LOOKUP.value);
+            writeLookupMethod(scriptReporter, sb, "getScopeId", 
CoreScriptFeature.LEGACY_SCOPE_LOOKUP.value);
         }
 
         // if we are supporting the default javascript then output the lookup 
methods for id and name
         if (TagConfig.isDefaultJavaScript()) {
             if (writeId)
-                writeLookupMethod(scriptReporter, sb, "lookupIdByTagId", 
ID_LOOKUP);
+                writeLookupMethod(scriptReporter, sb, "lookupIdByTagId", 
CoreScriptFeature.ID_LOOKUP.value);
 
             if (writeName)
-                writeLookupMethod(scriptReporter, sb, "lookupNameByTagId", 
NAME_LOOKUP);
+                writeLookupMethod(scriptReporter, sb, "lookupNameByTagId", 
CoreScriptFeature.NAME_LOOKUP.value);
 
             if (writeId || writeName)
-                writeLookupMethod(scriptReporter, sb, "lookupScopeId", 
SCOPE_LOOKUP);
+                writeLookupMethod(scriptReporter, sb, "lookupScopeId", 
CoreScriptFeature.SCOPE_LOOKUP.value);
         }
 
         return (sb != null) ? sb.toString() : null;
@@ -363,12 +184,17 @@
      *                tag written into
      * @param script  the JavaScript block
      */
-    public static void writeScriptBlock(AbstractRenderAppender results, String 
script)
+    public static void writeScriptBlock(ServletRequest req, 
AbstractRenderAppender results, String script)
     {
         assert(results != null);
-        writeScriptStart(results);
+        ScriptTag.State state = new ScriptTag.State();
+        TagRenderingBase br = 
TagRenderingBase.Factory.getRendering(TagRenderingBase.SCRIPT_TAG, req);
+
+        results.append("\n\n");
+        br.doStartTag(results,state);
         results.append(script);
-        writeScriptEnd(results);
+        br.doEndTag(results);
+        results.append("\n\n");
     }
 
     /**
@@ -407,6 +233,30 @@
         return result;
     }
 
+    /////************************* Private Methods 
*******************************************
+
+    /**
+     * This will map the Features into their keys
+     * @param feature
+     * @return
+     */
+    private String getFeatureKey(CoreScriptFeature feature)
+    {
+        switch (feature) {
+            case ANCHOR_SUBMIT:
+                return "anchorFormSubmit";
+            case SET_FOCUS:
+                return "setFocus";
+            case POPUP_FUNC:
+                return "popupFunc";
+            case ROLLOVER:
+                return "rollover";
+        }
+        assert(false) : "getFeature Fell through on feature:" + feature;
+        return null;
+    }
+
+
     /**
      * Returns the resource bundle named Bundle[].properties in the
      * package of the specified class.
@@ -418,6 +268,65 @@
             _bundle = ResourceBundle.getBundle(BUNDLE_NAME);
         return _bundle;
     }
+
+    /**
+    * This method will write out a tagId map entry for when there
+    * isn't a ScriptContainer defined.
+    * @param tagId   the tagId value
+    * @param value   the "real" value of the written out
+    * @param results the JavaScript that will be output
+    */
+   private void getTagIdMapping(String tagId, String value, 
AbstractRenderAppender results)
+   {
+       if ((_javaScriptFeatures & CoreScriptFeature.ALLOCATE_LEGACY.value) == 
0) {
+           _javaScriptFeatures |= CoreScriptFeature.ALLOCATE_LEGACY.value;
+           String s = getString("singleIdMappingTable", new Object[]{tagId, 
value});
+           String meths = writeNetuiNameFunctions(null, true, false, false);
+           if (meths != null)
+               s += meths;
+           writeScriptBlock(_req, results, s);
+       }
+       else {
+           String s = getString("idMappingEntry", new Object[]{tagId, value});
+           writeScriptBlock(_req, results, s);
+
+       }
+   }
+
+   /**
+    * @param tagId
+    * @param realId
+    * @param realName
+    * @param results
+    */
+   private void getTagIdMapping(String tagId, String realId, String realName, 
AbstractRenderAppender results)
+   {
+       StringBuilder sb = new StringBuilder(128);
+       if (realId != null) {
+           if ((_javaScriptFeatures & CoreScriptFeature.ALLOCATE_ID.value) == 
0) {
+               _javaScriptFeatures |= CoreScriptFeature.ALLOCATE_ID.value;
+               String meths = writeNetuiNameFunctions(null, false, true, 
false);
+               if (meths != null)
+                   sb.append(meths);
+           }
+       }
+
+       if (realName != null) {
+           if ((_javaScriptFeatures & CoreScriptFeature.ALLOCATE_NAME.value) 
== 0) {
+               _javaScriptFeatures |= CoreScriptFeature.ALLOCATE_NAME.value;
+               String s = getString("singleIdToNameMappingTable", new 
Object[]{tagId, realName});
+               String meths = writeNetuiNameFunctions(null, false, false, 
true);
+               if (meths != null)
+                   s += meths;
+               sb.append(s);
+           }
+           else {
+               String s = getString("tagIdNameMappingEntry", new 
Object[]{tagId, realName});
+               sb.append(s);
+           }
+       }
+       writeScriptBlock(_req, results, sb.toString());
+   }
 
     private void writeLookupMethod(IScriptReporter scriptReporter, 
StringBuilder sb, String bundleString, int feature)
     {

Added: 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/rendering/ScriptTag.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/rendering/ScriptTag.java?view=auto&rev=126620
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/rendering/ScriptTag.java
  Thu Jan 27 07:46:32 2005
@@ -0,0 +1,87 @@
+/*
+ * 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.tags.rendering;
+
+import org.apache.beehive.netui.tags.html.HtmlConstants;
+
+import java.util.HashMap;
+
+public abstract class ScriptTag extends TagHtmlBase
+{
+    public static void add(HashMap html, HashMap htmlQuirks, HashMap xhtml)
+    {
+        html.put(SCRIPT_TAG, new ScriptTag.Rendering());
+        htmlQuirks.put(SCRIPT_TAG, new ScriptTag.Rendering());
+        xhtml.put(SCRIPT_TAG, new ScriptTag.Rendering());
+    }
+
+    public static class State extends AbstractAttributeState
+    {
+        public String type;
+        public String src;
+        public String language;
+
+        public void clear()
+        {
+            super.clear();
+            type = null;
+            src = null;
+            language = null;
+        }
+    }
+
+    private static class Rendering extends ScriptTag implements HtmlConstants
+    {
+        public void doStartTag(AbstractRenderAppender sb, AbstractTagState 
renderState)
+        {
+            assert(sb != null) : "Parameter 'sb' must not be null";
+            assert(renderState != null) : "Parameter 'renderState' must not be 
null";
+            assert(renderState instanceof State) : "Paramater 'renderState' 
must be an instance of SpanTag.State";
+
+            State state = (State) renderState;
+
+            renderTag(sb, SCRIPT);
+
+            if (state.language == null) {
+                // @todo: this should be all lower case!
+                state.language = "JavaScript";
+            }
+            renderAttribute(sb, LANGUAGE, state.language);
+
+            if (state.type == null) {
+                // @todo: this should be all lower case!
+                state.type = "text/JavaScript";
+            }
+            renderAttribute(sb, TYPE, state.type);
+
+            renderAttribute(sb, SRC, state.src);
+
+            renderAttributes(AbstractHtmlState.ATTR_GENERAL, sb, state);
+            sb.append(">");
+
+            // for javascript will will continue put the script itself into 
html comments
+            sb.append("\n<!--\n");
+        }
+
+        public void doEndTag(AbstractRenderAppender sb)
+        {
+            sb.append("-->\n");
+            renderEndTag(sb, SCRIPT);
+        }
+    }
+}

Modified: 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/rendering/TagRenderingBase.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/rendering/TagRenderingBase.java?view=diff&rev=126620&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/rendering/TagRenderingBase.java&r1=126619&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/rendering/TagRenderingBase.java&r2=126620
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/rendering/TagRenderingBase.java
   (original)
+++ 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/rendering/TagRenderingBase.java
   Thu Jan 27 07:46:32 2005
@@ -123,6 +123,7 @@
     public static final Object THEAD_TAG = new Object();
     public static final Object TFOOT_TAG = new Object();
     public static final Object TR_TAG = new Object();
+    public static final Object SCRIPT_TAG = new Object();
 
     //////////////////////////////////// Abstract Methods  
////////////////////////////
 
@@ -318,6 +319,7 @@
             THeadTag.add(_html, _htmlQuirks, _xhtml);
             TFootTag.add(_html, _htmlQuirks, _xhtml);
             TrTag.add(_html, _htmlQuirks, _xhtml);
+            ScriptTag.add(_html, _htmlQuirks, _xhtml);
         }
 
         /**

Modified: 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java?view=diff&rev=126620&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java&r1=126619&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java&r2=126620
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java
    (original)
+++ 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java
    Thu Jan 27 07:46:32 2005
@@ -1233,25 +1233,6 @@
         return idScript;
     }
 
-    /*
-    // @todo: delete this
-    private String mapTagId(String tagId, String realId)
-    {
-        IScriptReporter scriptReporter = getScriptReporter();
-        if (scriptReporter != null) {
-            scriptReporter.addTagIdMappings(tagId, realId, null);
-            return null;
-        }
-
-        // without a scripRepoter we need to create the actual JavaScript that 
will be written out
-        ScriptRequestState jsu = getJavaScriptUtils((HttpServletRequest) 
getPageContext().getRequest());
-        StringBuilder sb = new StringBuilder(128);
-        StringBuilderRenderAppender writer = new 
StringBuilderRenderAppender(sb);
-        jsu.getTagIdMapping(tagId, realId, null, writer);
-        return sb.toString();
-    }
-    */
-
     /**
      * This method will return the <code>javaScriptUtils</code> that is 
assocated
      * with this request.  If this doesn't exist, it will be created before it 
is

Reply via email to