You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2007/05/09 20:07:50 UTC

svn commit: r536607 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/renderkit/ core/src/main/java/org/apache/myfaces/tobago/renderkit/html/ core/src/main/java/org/apache/myfaces/tobago/webapp/ core/src/test/java/org/apache/myfa...

Author: lofwyr
Date: Wed May  9 11:07:48 2007
New Revision: 536607

URL: http://svn.apache.org/viewvc?view=rev&rev=536607
Log:
TOBAGO-393: Create OptimizedResponseWriter to move the non-standard-compliant optimization stuff to

Inital setup

Added:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/OptimizedResponseWriter.java
Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/LayoutableRendererBase.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
    myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java
    myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/sandbox/standard/tag/InputNumberSliderRenderer.java
    myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SeparatorRenderer.java
    myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
    myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/mozilla_4_7/tag/BoxRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/mozilla_4_7/tag/ProgressRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ProgressRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeOldRenderer.java
    myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/LayoutableRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/LayoutableRendererBase.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/LayoutableRendererBase.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/LayoutableRendererBase.java Wed May  9 11:07:48 2007
@@ -23,18 +23,18 @@
 import org.apache.myfaces.tobago.component.ComponentUtil;
 import org.apache.myfaces.tobago.component.UICell;
 import org.apache.myfaces.tobago.component.UICommand;
-import org.apache.myfaces.tobago.util.LayoutUtil;
-import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
+import org.apache.myfaces.tobago.util.LayoutUtil;
+import org.apache.myfaces.tobago.webapp.OptimizedResponseWriter;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
-import java.awt.Dimension;
+import java.awt.*;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
-import java.util.Arrays;
 
 public abstract class LayoutableRendererBase
     extends RendererBase implements LayoutInformationProvider {
@@ -138,13 +138,13 @@
     }
   }
 
-  protected void checkForCommandFacet(UIComponent component, FacesContext facesContext, TobagoResponseWriter writer)
+  protected void checkForCommandFacet(UIComponent component, FacesContext facesContext, OptimizedResponseWriter writer)
       throws IOException {
     checkForCommandFacet(component, Arrays.asList(component.getClientId(facesContext)) , facesContext, writer);
   }
 
   protected void checkForCommandFacet(UIComponent component, List<String> clientIds, FacesContext facesContext,
-      TobagoResponseWriter writer) throws IOException {
+      OptimizedResponseWriter writer) throws IOException {
     Map<String, UIComponent> facets = component.getFacets();
     for (Map.Entry<String, UIComponent> entry: facets.entrySet()) {
       if (entry.getValue() instanceof UICommand) {
@@ -155,7 +155,7 @@
 
   // TODO create HtmlRendererBase
   private void addCommandFacet(List<String> clientIds, Map.Entry<String, UIComponent> facetEntry,
-      FacesContext facesContext, TobagoResponseWriter writer) throws
+      FacesContext facesContext, OptimizedResponseWriter writer) throws
       IOException {
     for (String clientId: clientIds) {
       writeScriptForClientId(clientId, facetEntry, facesContext, writer);
@@ -163,7 +163,7 @@
   }
 
   private void writeScriptForClientId(String clientId, Map.Entry<String, UIComponent> facetEntry,
-      FacesContext facesContext, TobagoResponseWriter writer) throws IOException {
+      FacesContext facesContext, OptimizedResponseWriter writer) throws IOException {
     if (facetEntry.getValue() instanceof UICommand
         && ((UICommand) facetEntry.getValue()).getRenderedPartially().length > 0) {
       String script =
@@ -175,7 +175,7 @@
               ((UICommand) facetEntry.getValue()).getRenderedPartially()[0]) + "','"
               + facetEntry.getValue().getClientId(facesContext)  + "', {})});\n"
               + "}";
-      HtmlRendererUtil.writeJavascript(writer, script);
+      writer.writeJavascript(script);
     } else {
       String script =
           "var element = Tobago.element(\"" + clientId  + "\");\n"
@@ -183,7 +183,7 @@
               + "   Tobago.addEventListener(element, \"" + facetEntry.getKey() + "\", function(){Tobago.submitAction('"
               + facetEntry.getValue().getClientId(facesContext) + "')});\n"
               + "}";
-      HtmlRendererUtil.writeJavascript(writer, script);
+      writer.writeJavascript(script);
     }
   }
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java Wed May  9 11:07:48 2007
@@ -30,9 +30,9 @@
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE_BODY;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE_HEADER;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE_INNER;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
 import static org.apache.myfaces.tobago.TobagoConstants.FACET_LAYOUT;
 import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_OUT;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
 import org.apache.myfaces.tobago.component.ComponentUtil;
 import org.apache.myfaces.tobago.component.UIPage;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
@@ -41,6 +41,7 @@
 import org.apache.myfaces.tobago.renderkit.RenderUtil;
 import org.apache.myfaces.tobago.renderkit.RendererBaseWrapper;
 import org.apache.myfaces.tobago.util.LayoutUtil;
+import org.apache.myfaces.tobago.webapp.OptimizedResponseWriter;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
 import javax.faces.component.UIComponent;
@@ -78,10 +79,8 @@
         LOG.warn("page focusId = \"" + page.getFocusId() + "\" ignoring new value \""
             + id + "\"");
       } else {
-        ResponseWriter writer = facesContext.getResponseWriter();
-        startJavascript(writer);
-        writer.writeText("Tobago.focusId = '" + id + "';", null);
-        endJavascript(writer);
+        OptimizedResponseWriter writer = HtmlRendererUtil.getOptimizedResponseWriter(facesContext);
+        writer.writeJavascript("Tobago.focusId = '" + id + "';");
       }
     }
   }
@@ -129,8 +128,7 @@
     return null;
   }
 
-  public static void writeLabelWithAccessKey(ResponseWriter writer,
-      LabelWithAccessKey label)
+  public static void writeLabelWithAccessKey(ResponseWriter writer, LabelWithAccessKey label)
       throws IOException {
     int pos = label.getPos();
     String text = label.getText();
@@ -432,7 +430,7 @@
     classes.addMarkupClass(component, rendererName);
   }
 
-  public static void addImageSources(FacesContext facesContext, ResponseWriter writer, String src, String id)
+  public static void addImageSources(FacesContext facesContext, OptimizedResponseWriter writer, String src, String id)
       throws IOException {
     StringBuilder buffer = new StringBuilder();
     buffer.append("new Tobago.Image('");
@@ -444,7 +442,7 @@
     buffer.append("','");
     buffer.append(ResourceManagerUtil.getImageWithPath(facesContext, createSrc(src, "Hover"), true));
     buffer.append("');");
-    writeJavascript(writer, buffer.toString());
+    writer.writeJavascript(buffer.toString());
   }
 
   public static String createSrc(String src, String ext) {
@@ -457,21 +455,37 @@
     }
   }
 
-  public static void writeJavascript(ResponseWriter writer, String script)
-      throws IOException {
+  public static OptimizedResponseWriter getOptimizedResponseWriter(FacesContext facesContext) {
+
+    ResponseWriter writer = facesContext.getResponseWriter();
+    if (writer instanceof OptimizedResponseWriter) {
+      return (OptimizedResponseWriter) writer;
+    } else {
+      // todo: return new OptimizedResponseWriterWrapper(writer);
+      throw new UnsupportedOperationException("No OptimizedResponseWriterWrapper implemented found!");
+    }
+  }
+
+  /** @deprecated use OptiizedScriptLoader */
+  @Deprecated
+  public static void writeJavascript(ResponseWriter writer, String script) throws IOException {
     startJavascript(writer);
-    writer.writeText(script, null);
+    writer.write(script);
     endJavascript(writer);
   }
 
+  /** @deprecated use OptiizedScriptLoader */
+  @Deprecated
   public static void startJavascript(ResponseWriter writer) throws IOException {
     writer.startElement(HtmlConstants.SCRIPT, null);
     writer.writeAttribute(HtmlAttributes.TYPE, "text/javascript", null);
-    writer.writeText("\n<!--\n", null);
+    writer.write("\n<!--\n");
   }
 
+  /** @deprecated use OptiizedScriptLoader */
+  @Deprecated
   public static void endJavascript(ResponseWriter writer) throws IOException {
-    writer.writeText("\n// -->\n", null);
+    writer.write("\n// -->\n");
     writer.endElement(HtmlConstants.SCRIPT);
   }
 
@@ -483,52 +497,47 @@
   public static void writeScriptLoader(
       FacesContext facesContext, String[] scripts, String[] afterLoadCmds)
       throws IOException {
-    TobagoResponseWriter writer
-        = (TobagoResponseWriter) facesContext.getResponseWriter();
-    startJavascript(writer);
+    OptimizedResponseWriter writer = HtmlRendererUtil.getOptimizedResponseWriter(facesContext);
 
     String allScripts = "[]";
     if (scripts != null) {
       allScripts = ResourceManagerUtil.getScriptsAsJSArray(facesContext, scripts);
     }
 
-    writer.writeText("new Tobago.ScriptLoader(\n    ", null);
-    writer.writeText(allScripts, null);
+    StringBuilder script = new StringBuilder();
+    script.append("new Tobago.ScriptLoader(\n    ");
+    script.append(allScripts);
     if (afterLoadCmds != null && afterLoadCmds.length > 0) {
-      writer.writeText(", \n", null);
+      script.append(", \n");
       for (int i = 0; i < afterLoadCmds.length; i++) {
         String cmd = StringUtils.replace(afterLoadCmds[i], "\\", "\\\\");
         cmd = StringUtils.replace(cmd, "\"", "\\\"");
-        writer.writeText(i == 0 ? "          " : "        + ", null);
-        writer.writeText("\"" + cmd + "\"\n", null);
+        script.append(i == 0 ? "          " : "        + ");
+        script.append("\"");
+        script.append(cmd);
+        script.append("\"\n");
       }
     }
-    writer.writeText(");", null);
+    script.append(");");
 
-    endJavascript(writer);
+    writer.writeJavascript(script.toString());
   }
 
   public static void writeStyleLoader(
       FacesContext facesContext, String[] styles) throws IOException {
-    TobagoResponseWriter writer
-        = (TobagoResponseWriter) facesContext.getResponseWriter();
-    startJavascript(writer);
+    OptimizedResponseWriter writer = HtmlRendererUtil.getOptimizedResponseWriter(facesContext);
 
-    String allStyles
-        = ResourceManagerUtil.getStylesAsJSArray(facesContext, styles);
-
-    writer.writeText("Tobago.ensureStyleFiles(\n    ", null);
-    writer.writeText(allStyles, null);
-    writer.writeText(");", null);
-
-    endJavascript(writer);
+    StringBuilder builder = new StringBuilder();
+    builder.append("Tobago.ensureStyleFiles(\n    ");
+    builder.append(ResourceManagerUtil.getStylesAsJSArray(facesContext, styles));
+    builder.append(");");
+    writer.writeJavascript(builder.toString());
   }
 
   public static String getTitleFromTipAndMessages(FacesContext facesContext, UIComponent component) {
     String messages = ComponentUtil.getFacesMessageAsString(facesContext, component);
     return HtmlRendererUtil.addTip(messages, (String) component.getAttributes().get(ATTR_TIP));
   }
-
 
   public static String addTip(String title, String tip) {
     if (tip != null) {

Added: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/OptimizedResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/OptimizedResponseWriter.java?view=auto&rev=536607
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/OptimizedResponseWriter.java (added)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/OptimizedResponseWriter.java Wed May  9 11:07:48 2007
@@ -0,0 +1,65 @@
+package org.apache.myfaces.tobago.webapp;
+
+import javax.faces.component.UIComponent;
+import java.io.IOException;
+
+/**
+ * User: lofwyr
+ * Date: 08.05.2007 13:51:43
+ */
+public interface OptimizedResponseWriter {
+
+  void startElement(String name, UIComponent component) throws IOException;
+
+  void endElement(String name) throws IOException;
+
+  /**
+   * Writes a string attribute. The renderer may set escape=false to switch of escaping of the string,
+   * if it is not necessary.
+   */
+  void writeAttribute(String name, String string, boolean escape) throws IOException;
+
+  /**
+   * Writes a boolean attribute. The value will not escaped.
+   */
+  void writeAttribute(String name, boolean on) throws IOException;
+
+  /**
+   * Writes a integer attribute. The value will not escaped.
+   */
+  void writeAttribute(String name, int number) throws IOException;
+
+  /**
+   * Write the id attribute. The value will not escaped.
+   */
+  void writeIdAttribute(String id) throws IOException;
+
+  /**
+   * Write the name attribute. The value will not escaped.
+   */
+  void writeNameAttribute(String name) throws IOException;
+
+  /**
+   * Write the class attribute. The value will not escaped.
+   */
+  void writeClassAttribute(String cssClass) throws IOException;
+
+  /**
+   * Write the class attribute. The value will not escaped.
+   */
+  void writeClassAttribute() throws IOException;
+
+  /**
+   * Write the style attribute. The value will not escaped.
+   */
+  void writeStyleAttribute(String style) throws IOException;
+
+  /**
+   * Write the style attribute. The value will not escaped.
+   */
+  void writeStyleAttribute() throws IOException;
+
+  void writeJavascript(String script) throws IOException;
+
+  void writeText(String text) throws IOException;
+}

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java Wed May  9 11:07:48 2007
@@ -20,12 +20,13 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.tobago.TobagoConstants;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE_CLASS;
-import org.apache.myfaces.tobago.util.HtmlWriterUtil;
-import org.apache.myfaces.tobago.util.XmlUtils;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
-import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
+import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
+import org.apache.myfaces.tobago.util.HtmlWriterUtil;
+import org.apache.myfaces.tobago.util.XmlUtils;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.ResponseWriter;
@@ -36,21 +37,21 @@
 import java.util.Set;
 import java.util.Stack;
 
-public class TobagoResponseWriter extends ResponseWriter {
+public class TobagoResponseWriter extends ResponseWriter implements OptimizedResponseWriter {
 
   private static final Log LOG = LogFactory.getLog(TobagoResponseWriter.class);
 
   private static final Set<String> EMPTY_TAG = new HashSet<String>(Arrays.asList(
-              HtmlConstants.BR,
-              HtmlConstants.AREA,
-              HtmlConstants.LINK,
-              HtmlConstants.IMG,
-              HtmlConstants.PARAM,
-              HtmlConstants.HR,
-              HtmlConstants.INPUT,
-              HtmlConstants.COL,
-              HtmlConstants.BASE,
-              HtmlConstants.META));
+      HtmlConstants.BR,
+      HtmlConstants.AREA,
+      HtmlConstants.LINK,
+      HtmlConstants.IMG,
+      HtmlConstants.PARAM,
+      HtmlConstants.HR,
+      HtmlConstants.INPUT,
+      HtmlConstants.COL,
+      HtmlConstants.BASE,
+      HtmlConstants.META));
 
   private Writer writer;
 
@@ -64,11 +65,11 @@
 
   private Stack<String> stack;
 
-  /** use XML instead HMTL */
+  /**
+   * use XML instead HMTL
+   */
   private boolean xml;
 
-  private boolean insideScriptOrStyle = false;
-
   private HtmlWriterUtil helper;
 
   public TobagoResponseWriter(final Writer writer, final String contentType,
@@ -170,18 +171,14 @@
       throws IOException {
     closeOpenTag();
     final String value = findValue(text, property);
-    if (insideScriptOrStyle) {
-      write(value);
+    if (xml) {
+      write(XmlUtils.escape(value));
     } else {
-      if (xml) {
-        write(XmlUtils.escape(value));
-      } else {
-        helper.writeText(value);
-      }
+      helper.writeText(value);
     }
   }
 
-  private  void closeOpenTag() throws IOException {
+  private void closeOpenTag() throws IOException {
     if (startStillOpen) {
       writer.write("\n>");
       startStillOpen = false;
@@ -191,15 +188,11 @@
   public void writeText(final char[] text, final int offset, final int length)
       throws IOException {
     closeOpenTag();
-    if (insideScriptOrStyle) {
-      writer.write(text, offset, length);
-    } else {
-      if (xml) {
-        writer.write(XmlUtils.escape(text.toString()).toCharArray(), offset, length);
+    if (xml) {
+      writer.write(XmlUtils.escape(text.toString()).toCharArray(), offset, length);
 // FIXME: not nice:     XmlUtils.escape(text.toString()).toCharArray()
-      } else {
-        helper.writeText(text, offset, length);
-      }
+    } else {
+      helper.writeText(text, offset, length);
     }
   }
 
@@ -219,18 +212,11 @@
     return characterEncoding;
   }
 
-  public void startElement(final String name) throws IOException {
-    startElement(name, null);
-  }
   public void startElement(final String name, final UIComponent currentComponent)
       throws IOException {
     this.component = currentComponent;
     stack.push(name);
-//    closeStartIfNecessary();
-    insideScriptOrStyle = isScriptOrStyle(name);
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("start Element: " + name);
-    }
+//    closeOpenTag();
     if (startStillOpen) {
       writer.write("\n>");
     }
@@ -239,38 +225,6 @@
     startStillOpen = true;
   }
 
-  static boolean isScriptOrStyle(final String name) {
-    try {
-      switch (name.charAt(0)) {
-        case 's' :
-          switch (name.charAt(1)) {
-            case 'c' :
-              if (name.charAt(2) == 'r' && name.charAt(3) == 'i'
-                  && name.charAt(4) == 'p' && name.charAt(5) == 't') {
-                return true;
-              }
-            break;
-            case 't' :
-              if (name.charAt(2) == 'y' && name.charAt(3) == 'l'
-                  && name.charAt(4) == 'e') {
-                return true;
-              }
-            break;
-            default:
-              return false;
-          }
-          break;
-        default:
-          return false;
-      }
-    } catch (NullPointerException e) {
-      // ignore
-    } catch (StringIndexOutOfBoundsException e) {
-      // ignore
-    }
-    return false;
-  }
-
   public void endElement(final String name) throws IOException {
     if (LOG.isDebugEnabled()) {
       LOG.debug("end Element: " + name);
@@ -284,8 +238,6 @@
           + trace.substring(trace.indexOf('(')));
     }
 
-    insideScriptOrStyle = false;
-
     if (EMPTY_TAG.contains(name)) {
       if (xml) {
         writer.write("\n/>");
@@ -314,7 +266,7 @@
       String trace = getCallingClassStackTraceElementString();
       LOG.warn(
           "Comment must not contain the sequence '--', comment = '"
-          + comment + "' " + trace.substring(trace.indexOf('(')));
+              + comment + "' " + trace.substring(trace.indexOf('(')));
       write(StringUtils.replace(comment, "--", "++"));
     }
     write("-->");
@@ -325,18 +277,6 @@
         originalWriter, getContentType(), getCharacterEncoding());
   }
 
-  public void writeAttribute(final String name, final boolean on) throws IOException {
-    if (on) {
-      // boolean attributes don't need escaped
-      writeAttribute(name, name, false);
-    }
-  }
-
-  public void writeComponentAttribute(final String name, final String property)
-      throws IOException {
-    writeAttribute(name, null, property, true);
-  }
-
   public void writeAttribute(final String name, final Object value, final String property)
       throws IOException {
     writeAttribute(name, value, property, true);
@@ -344,7 +284,7 @@
 
   public void writeAttribute(final String name, final Object value, final boolean escape)
       throws IOException {
-      writeAttribute(name, value.toString(), escape);
+    writeAttribute(name, value.toString(), escape);
   }
 
   public void writeAttribute(final String name, final String value, final boolean escape)
@@ -417,6 +357,38 @@
     return stackTrace[i].toString();
   }
 
+  public void writeClassAttribute(StyleClasses styleClasses) throws IOException {
+    writeAttribute(HtmlAttributes.CLASS, styleClasses.toString(), false);
+  }
+
+  public void writeComponentClass() throws IOException {
+    writeAttribute(HtmlAttributes.CLASS, null, ATTR_STYLE_CLASS);
+  }
+
+  public void writeURIAttribute(final String s, final Object obj, final String s1)
+      throws IOException {
+    LOG.error("Not implemented yet!");
+  }
+
+// interface OptimizedResponseWriter //////////////////////////////////////////////////////////////////////////////////
+
+  public void writeAttribute(final String name, final String string) throws IOException {
+    // todo: optimize
+    writeAttribute(name, string, true);
+  }
+
+  public void writeAttribute(final String name, final boolean on) throws IOException {
+    if (on) {
+      // boolean attributes don't need escaped
+      writeAttribute(name, name, false);
+    }
+  }
+
+  public void writeAttribute(final String name, final int number) throws IOException {
+      // integer attributes don't need escaped
+      writeAttribute(name, number, false);
+  }
+
   public void writeIdAttribute(final String id) throws IOException {
     writeAttribute(HtmlAttributes.ID, id, false);
   }
@@ -429,17 +401,30 @@
     writeAttribute(HtmlAttributes.CLASS, cssClass, false);
   }
 
-  public void writeClassAttribute(StyleClasses styleClasses) throws IOException {
-    writeAttribute(HtmlAttributes.CLASS, styleClasses.toString(), false);
+  public void writeClassAttribute() throws IOException {
+    writeComponentClass();
   }
 
-  public void writeComponentClass() throws IOException {
-    writeComponentAttribute(HtmlAttributes.CLASS, ATTR_STYLE_CLASS);
+  public void writeStyleAttribute(String style) throws IOException {
+    writeAttribute(HtmlAttributes.STYLE, style, false);
   }
 
-  public void writeURIAttribute(final String s, final Object obj, final String s1)
-      throws IOException {
-    LOG.error("Not implemented yet!");
+  public void writeStyleAttribute() throws IOException {
+    writeAttribute(HtmlAttributes.STYLE, component.getAttributes().get(TobagoConstants.ATTR_STYLE), false);
+  }
+
+  public void writeText(String text) throws IOException {
+    // xxx optimize
+    writeText(text, null);
+  }
+
+  public void writeJavascript(String script) throws IOException {
+    startElement(HtmlConstants.SCRIPT, null);
+    writeAttribute(HtmlAttributes.TYPE, "text/javascript", false);
+    write("\n<!--\n");
+    write(script);
+    write("\n// -->\n");
+    endElement(HtmlConstants.SCRIPT);
   }
 
 }

Modified: myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java (original)
+++ myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java Wed May  9 11:07:48 2007
@@ -104,13 +104,4 @@
     writer1.close();
     assertEquals("<input value=\"Gutschein &uuml;ber 100 &euro;.\" readonly=\"readonly\"\n>", stringWriter.toString());
   }
-
-  public void testNoneScript() {
-    assertFalse(TobagoResponseWriter.isScriptOrStyle(null));
-    assertFalse(TobagoResponseWriter.isScriptOrStyle("s"));
-    assertFalse(TobagoResponseWriter.isScriptOrStyle("sc"));
-    assertTrue(TobagoResponseWriter.isScriptOrStyle("script"));
-    assertTrue(TobagoResponseWriter.isScriptOrStyle("style"));
-  }
-
 }

Modified: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/sandbox/standard/tag/InputNumberSliderRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/sandbox/standard/tag/InputNumberSliderRenderer.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/sandbox/standard/tag/InputNumberSliderRenderer.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/sandbox/standard/tag/InputNumberSliderRenderer.java Wed May  9 11:07:48 2007
@@ -20,11 +20,13 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.tobago.TobagoConstants;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DISABLED;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_READONLY;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE;
+import org.apache.myfaces.tobago.component.ComponentUtil;
+import org.apache.myfaces.tobago.config.ThemeConfig;
 import org.apache.myfaces.tobago.context.ResourceManager;
 import org.apache.myfaces.tobago.context.ResourceManagerFactory;
-import org.apache.myfaces.tobago.config.ThemeConfig;
-import static org.apache.myfaces.tobago.TobagoConstants.*;
-import org.apache.myfaces.tobago.component.ComponentUtil;
 import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
@@ -89,11 +91,11 @@
     StyleClasses styleClasses = new StyleClasses();
     styleClasses.addAspectClass("inputNumberSlider", "min", StyleClasses.Aspect.DEFAULT);
 
-    writer.startElement(HtmlConstants.TR);
-    writer.startElement(HtmlConstants.TD);
+    writer.startElement(HtmlConstants.TR, null);
+    writer.startElement(HtmlConstants.TD, null);
     writer.writeClassAttribute(styleClasses);
     writer.writeAttribute(HtmlAttributes.STYLE, HtmlRendererUtil.toStyleString("width", sliderWidth / 2), null);
-    writer.startElement(HtmlConstants.SPAN);
+    writer.startElement(HtmlConstants.SPAN, null);
     writer.writeClassAttribute(styleClasses);
     writer.writeText(min, null);
     writer.endElement(HtmlConstants.SPAN);
@@ -102,22 +104,22 @@
     styleClasses.addAspectClass("inputNumberSlider", "max", StyleClasses.Aspect.DEFAULT);
 
     writer.endElement(HtmlConstants.TD);
-    writer.startElement(HtmlConstants.TD);
+    writer.startElement(HtmlConstants.TD, null);
     writer.writeClassAttribute(styleClasses);
     writer.writeAttribute(HtmlAttributes.STYLE,
         HtmlRendererUtil.toStyleString("width", sliderWidth / 2), null);
-    writer.startElement(HtmlConstants.SPAN);
+    writer.startElement(HtmlConstants.SPAN, null);
     writer.writeClassAttribute(styleClasses);
     writer.writeText(max, null);
     writer.endElement(HtmlConstants.SPAN);
     writer.endElement(HtmlConstants.TD);
 
     // the input field starts here
-    writer.startElement(HtmlConstants.TD);
+    writer.startElement(HtmlConstants.TD, null);
     writer.writeAttribute("rowspan", "2", false);
     writer.writeClassAttribute("tobago-inputNumberSlider-input-default");
 
-    writer.startElement(HtmlConstants.INPUT);
+    writer.startElement(HtmlConstants.INPUT, null);
     writer.writeClassAttribute("tobago-in-default");
     writer.writeAttribute(HtmlAttributes.STYLE,
         HtmlRendererUtil.toStyleString("width", inputWidth), null);
@@ -134,20 +136,20 @@
     writer.endElement(HtmlConstants.TD);
 
     writer.endElement(HtmlConstants.TR);
-    writer.startElement(HtmlConstants.TR);
-    writer.startElement(HtmlConstants.TD);
+    writer.startElement(HtmlConstants.TR, null);
+    writer.startElement(HtmlConstants.TD, null);
     writer.writeAttribute("colspan", "2", false);
 
     //track
-    writer.startElement(HtmlConstants.DIV);
+    writer.startElement(HtmlConstants.DIV, null);
     writer.writeClassAttribute("tobago-inputNumberSlider-slider-default");
     writer.writeAttribute(HtmlAttributes.ID, getIdForSliderTrack(facesContext, component), null);
 
     // handle
-    writer.startElement(HtmlConstants.DIV);
+    writer.startElement(HtmlConstants.DIV, null);
     writer.writeAttribute(HtmlAttributes.ID, getIdForSliderHandle(facesContext, component), null);
     writer.writeAttribute(HtmlAttributes.STYLE, "position:relative; top:-6px; width:12px; height:6px", null);
-    writer.startElement(HtmlConstants.IMG);
+    writer.startElement(HtmlConstants.IMG, null);
     writer.writeAttribute(HtmlAttributes.SRC, getAbsoluteImagePath(facesContext, "image/sliderTriangle.gif"), null);
     writer.endElement(HtmlConstants.IMG);
     writer.endElement(HtmlConstants.DIV);
@@ -223,7 +225,7 @@
         + "    Event.observe('value', 'change', function() {\n"
         + "        slider_" + jsId + ".setValue($('" + inputId + "').value);\n"
         + "    });\n";
-    HtmlRendererUtil.writeJavascript(writer, script);
+    writer.writeJavascript(script);
   }
 
 }

Modified: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SeparatorRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SeparatorRenderer.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SeparatorRenderer.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SeparatorRenderer.java Wed May  9 11:07:48 2007
@@ -41,7 +41,7 @@
     TobagoResponseWriter writer = (TobagoResponseWriter) facesContext.getResponseWriter();
     writer.startElement(HtmlConstants.DIV, component);
     writer.writeComponentClass();
-    writer.writeComponentAttribute(HtmlAttributes.STYLE, TobagoConstants.ATTR_STYLE);
+    writer.writeAttribute(HtmlAttributes.STYLE, null, TobagoConstants.ATTR_STYLE);
     if (component.getFacet(FACET_LABEL) != null) {
       writer.startElement(HtmlConstants.TABLE, component);
       writer.writeComponentClass();

Modified: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java Wed May  9 11:07:48 2007
@@ -144,7 +144,7 @@
 
     CommandRendererHelper helper = new CommandRendererHelper(facesContext, node);
 
-    writer.startElement(DIV);
+    writer.startElement(DIV, null);
 
     // div id
     writer.writeIdAttribute(id);
@@ -196,7 +196,7 @@
 
     if (isFolder) {
       String contentStyle = "display: " + (expanded ? "block" : "none") + ";";
-      writer.startElement(DIV);
+      writer.startElement(DIV, null);
       writer.writeIdAttribute(id + "-cont");
       writer.writeAttribute("style", contentStyle, null);
     }
@@ -229,7 +229,7 @@
     String onclick = "new_tobagoTreeNodeToggle(this.parentNode, '" + treeId + "', null, null, '"
         + menuOpen + "', '" + menuClose + "')";
     String src = expanded ? menuOpen : menuClose;
-    writer.startElement(IMG);
+    writer.startElement(IMG, null);
     writer.writeClassAttribute("tobago-tree-menu-icon");
     writer.writeIdAttribute(id + "-menuIcon");
     writer.writeAttribute("src", src, null);
@@ -246,7 +246,7 @@
     String perpendicular = ResourceManagerUtil.getImageWithPath(facesContext, "image/I.gif");
 
     for (Boolean junction : junctions) {
-      writer.startElement(IMG);
+      writer.startElement(IMG, null);
       writer.writeClassAttribute("tree-junction");
       if (junction && !menuMode) {
         writer.writeAttribute("src", perpendicular, null);
@@ -264,7 +264,7 @@
     if (!(!showJunctions
         || !showRootJunction && depth == 0
         || !showRootJunction && !showRoot && depth == 1)) {
-      writer.startElement(IMG);
+      writer.startElement(IMG, null);
       writer.writeClassAttribute("tree-junction");
       writer.writeIdAttribute(id + "-junction");
 
@@ -299,7 +299,7 @@
       throws IOException {
 
     if (showIcons) {
-      writer.startElement(IMG);
+      writer.startElement(IMG, null);
       writer.writeClassAttribute("tree-icon");
       writer.writeIdAttribute(id + "-icon");
 
@@ -346,9 +346,9 @@
       throws IOException {
 
     if (helper.isDisabled()) {
-      writer.startElement(SPAN);
+      writer.startElement(SPAN, null);
     } else {
-      writer.startElement(A);
+      writer.startElement(A, null);
       writer.writeAttribute(HtmlAttributes.HREF, helper.getHref(), null);
       writer.writeAttribute(HtmlAttributes.ONCLICK, helper.getOnclick(), null);
       writer.writeAttribute(HtmlAttributes.ONFOCUS, "storeMarker(this.parentNode, '" + treeId + "')", null);

Modified: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java Wed May  9 11:07:48 2007
@@ -29,8 +29,8 @@
 import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
 import org.apache.myfaces.tobago.model.TreeState;
-import org.apache.myfaces.tobago.renderkit.RenderUtil;
 import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
+import org.apache.myfaces.tobago.renderkit.RenderUtil;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
@@ -164,12 +164,13 @@
     }
 
     if (!TobagoConfig.getInstance(facesContext).isAjaxEnabled()) {
-      HtmlRendererUtil.startJavascript(writer);
+
+      StringBuilder script = new StringBuilder();
       for (String scriptText : scriptTexts) {
-        writer.writeText(scriptText, null);
-        writer.writeText('\n', null);
+        script.append(scriptText);
+        script.append('\n');
       }
-      HtmlRendererUtil.endJavascript(writer);
+      writer.writeJavascript(script.toString());
     } else {
       HtmlRendererUtil.writeScriptLoader(facesContext, scripts, scriptTexts);
     }

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/mozilla_4_7/tag/BoxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/mozilla_4_7/tag/BoxRenderer.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/mozilla_4_7/tag/BoxRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/mozilla_4_7/tag/BoxRenderer.java Wed May  9 11:07:48 2007
@@ -23,12 +23,13 @@
  */
 
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE;
 import static org.apache.myfaces.tobago.TobagoConstants.FACET_LABEL;
 import org.apache.myfaces.tobago.renderkit.BoxRendererBase;
 import org.apache.myfaces.tobago.renderkit.RenderUtil;
-import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
+import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
+import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
+import org.apache.myfaces.tobago.webapp.OptimizedResponseWriter;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
@@ -42,31 +43,28 @@
       FacesContext facesContext, UIComponent component) throws IOException {
 
     UIComponent label = component.getFacet(FACET_LABEL);
-    String labelString
-        = (String) component.getAttributes().get(ATTR_LABEL);
+    String labelString = (String) component.getAttributes().get(ATTR_LABEL);
 
-
-    ResponseWriter writer = facesContext.getResponseWriter();
+    OptimizedResponseWriter writer = HtmlRendererUtil.getOptimizedResponseWriter(facesContext);
 
     // TODO: move fix style attributes to style.css (border, padding, align, etc)
 
     writer.startElement(HtmlConstants.TABLE, component);
-    writer.writeAttribute(HtmlAttributes.STYLE, null, ATTR_STYLE);
-    writer.writeAttribute(HtmlAttributes.BORDER, "1", null);
-    writer.writeAttribute(HtmlAttributes.CELLPADDING, "5", null);
-    writer.writeAttribute(HtmlAttributes.CELLSPACING, "0", null);
-    writer.writeAttribute(HtmlAttributes.SUMMARY, "", null);
+    writer.writeStyleAttribute();
+    writer.writeAttribute(HtmlAttributes.BORDER, 1);
+    writer.writeAttribute(HtmlAttributes.CELLPADDING, 5);
+    writer.writeAttribute(HtmlAttributes.CELLSPACING, 0);
+    writer.writeAttribute(HtmlAttributes.SUMMARY, "", false);
 
     if (label != null || labelString != null) {
 
       writer.startElement(HtmlConstants.TR, null);
       writer.startElement(HtmlConstants.TH, null);
-      writer.writeAttribute(HtmlAttributes.ALIGN, "left", null);
-      writer.writeText("", null);
+      writer.writeAttribute(HtmlAttributes.ALIGN, "left", false);
       if (label != null) {
         RenderUtil.encode(facesContext, label);
       } else {
-        writer.writeText(labelString, null);
+        writer.writeText(labelString);
       }
       writer.endElement(HtmlConstants.TH);
       writer.endElement(HtmlConstants.TR);
@@ -77,8 +75,7 @@
 
   }
 
-  public void encodeEnd(FacesContext facesContext,
-      UIComponent component) throws IOException {
+  public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
 
     ResponseWriter writer = facesContext.getResponseWriter();
 
@@ -88,9 +85,7 @@
   }
 
   public int getPaddingHeight(FacesContext facesContext, UIComponent component) {
-    return 10
-        + (component.getFacet(FACET_LABEL) != null ? 25 : 0);
+    return 10 + (component.getFacet(FACET_LABEL) != null ? 25 : 0);
   }
 
 }
-

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/mozilla_4_7/tag/ProgressRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/mozilla_4_7/tag/ProgressRenderer.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/mozilla_4_7/tag/ProgressRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/mozilla_4_7/tag/ProgressRenderer.java Wed May  9 11:07:48 2007
@@ -19,32 +19,28 @@
 
 /*
  * Created 07.02.2003 16:00:00.
- * : $
  */
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.tobago.component.UICommand;
 import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
-import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
-import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
+import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.util.LayoutUtil;
-import org.apache.myfaces.tobago.component.UICommand;
+import org.apache.myfaces.tobago.webapp.OptimizedResponseWriter;
 
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIOutput;
 import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.swing.BoundedRangeModel;
-import javax.swing.DefaultBoundedRangeModel;
+import javax.swing.*;
 import java.io.IOException;
 
 public class ProgressRenderer extends LayoutableRendererBase {
 
   private static final Log LOG = LogFactory.getLog(ProgressRenderer.class);
        
-  public void encodeEnd(FacesContext facesContext,
-      UIComponent uiComponent) throws IOException {
+  public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
 
     UIOutput component = (UIOutput) uiComponent;
 
@@ -55,7 +51,7 @@
       model = new DefaultBoundedRangeModel(4, 1, 0, 10);
     }
 
-    ResponseWriter writer = facesContext.getResponseWriter();
+    OptimizedResponseWriter writer = (OptimizedResponseWriter) facesContext.getResponseWriter();
 
     String value1 = Integer.toString(model.getValue());
     String value2 = Integer.toString(model.getMaximum() - model.getValue());
@@ -74,25 +70,23 @@
 
 
     writer.startElement(HtmlConstants.TABLE, null);
-    writer.writeAttribute(HtmlAttributes.BORDER, "0", null);
-    writer.writeAttribute(HtmlAttributes.CELLSPACING, "0", null);
-    writer.writeAttribute(HtmlAttributes.CELLPADDING, "0", null);
-    writer.writeAttribute(HtmlAttributes.SUMMARY, "", null);
+    writer.writeAttribute(HtmlAttributes.BORDER, 0);
+    writer.writeAttribute(HtmlAttributes.CELLSPACING, 0);
+    writer.writeAttribute(HtmlAttributes.CELLPADDING, 0);
+    writer.writeAttribute(HtmlAttributes.SUMMARY, "", false);
 
     writer.startElement(HtmlConstants.TR, null);
 
     writer.startElement(HtmlConstants.TD, null);
-    writer.writeAttribute(HtmlAttributes.STYLE, "background-color: #aabbcc;", null);
-    writer.writeAttribute(HtmlAttributes.WIDTH, width1, null);
-    writer.writeText("", null);
-    writer.write("&nbsp;");
+    writer.writeStyleAttribute("background-color: #aabbcc;");
+    writer.writeAttribute(HtmlAttributes.WIDTH, width1, false);
+    writer.writeText("\u00a0"); // non braking space
     writer.endElement(HtmlConstants.TD);
 
     writer.startElement(HtmlConstants.TD, null);
-    writer.writeAttribute(HtmlAttributes.STYLE, "background-color: #ddeeff;", null);
-    writer.writeAttribute(HtmlAttributes.WIDTH, width2, null);
-    writer.writeText("", null);
-    writer.write("&nbsp;");
+    writer.writeStyleAttribute("background-color: #ddeeff;");
+    writer.writeAttribute(HtmlAttributes.WIDTH, width2, false);
+    writer.writeText("\u00a0"); // non braking space
     writer.endElement(HtmlConstants.TD);
 
     writer.endElement(HtmlConstants.TR);
@@ -101,9 +95,7 @@
     if (model.getValue() == model.getMaximum() && facet != null
         && facet instanceof UICommand) {
       UICommand command = (UICommand) facet;
-      HtmlRendererUtil.writeJavascript(writer, "Tobago.submitAction('" + command.getClientId(facesContext) + "');");
+      writer.writeJavascript("Tobago.submitAction('" + command.getClientId(facesContext) + "');");
     }
   }
-
 }
-

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java Wed May  9 11:07:48 2007
@@ -27,9 +27,8 @@
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DISABLED;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_PASSWORD;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_READONLY;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE;
-import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_REQUIRED;
+import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
 import org.apache.myfaces.tobago.ajax.api.AjaxPhaseListener;
 import org.apache.myfaces.tobago.ajax.api.AjaxRenderer;
 import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
@@ -37,19 +36,20 @@
 import org.apache.myfaces.tobago.component.UIPage;
 import org.apache.myfaces.tobago.renderkit.HtmlUtils;
 import org.apache.myfaces.tobago.renderkit.InputRendererBase;
-import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
-import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
+import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
+import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
 import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
+import org.apache.myfaces.tobago.webapp.OptimizedResponseWriter;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
+import javax.faces.component.EditableValueHolder;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIInput;
-import javax.faces.component.EditableValueHolder;
 import javax.faces.context.FacesContext;
 import javax.faces.el.MethodBinding;
-import javax.faces.validator.Validator;
 import javax.faces.validator.LengthValidator;
+import javax.faces.validator.Validator;
 import java.io.IOException;
 import java.util.Iterator;
 import java.util.List;
@@ -78,17 +78,16 @@
     }
 
     String id = component.getClientId(facesContext);
-    TobagoResponseWriter writer = (TobagoResponseWriter)
-        facesContext.getResponseWriter();
+    OptimizedResponseWriter writer = (OptimizedResponseWriter) facesContext.getResponseWriter();
     writer.startElement(HtmlConstants.INPUT, component);
-    writer.writeAttribute(HtmlAttributes.TYPE, type, null);
+    writer.writeAttribute(HtmlAttributes.TYPE, type, false);
     writer.writeNameAttribute(id);
     writer.writeIdAttribute(id);
     if (currentValue != null) {
-      writer.writeAttribute(HtmlAttributes.VALUE, currentValue, null);
+      writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
     }
     if (title != null) {
-      writer.writeAttribute(HtmlAttributes.TITLE, title, null);
+      writer.writeAttribute(HtmlAttributes.TITLE, title, true);
     }
     int maxLength = 0;
     if (component instanceof EditableValueHolder) {
@@ -101,13 +100,13 @@
       }
     }
     if (maxLength > 0) {
-      writer.writeAttribute(HtmlAttributes.MAXLENGTH, Integer.toString(maxLength), null);
+      writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
     }
     writer.writeAttribute(HtmlAttributes.READONLY,
         ComponentUtil.getBooleanAttribute(component, ATTR_READONLY));
     writer.writeAttribute(HtmlAttributes.DISABLED,
         ComponentUtil.getBooleanAttribute(component, ATTR_DISABLED));
-    writer.writeAttribute(HtmlAttributes.STYLE, null, ATTR_STYLE);
+    writer.writeStyleAttribute();
     
     if (currentValue != null && currentValue.length() > 0
         && ComponentUtil.getBooleanAttribute(component, ATTR_REQUIRED)) {
@@ -115,7 +114,7 @@
       String rendererName = HtmlRendererUtil.getRendererName(facesContext, component);
       styleClasses.removeAspectClass(rendererName, StyleClasses.Aspect.REQUIRED);
     }
-    writer.writeComponentClass();
+    writer.writeClassAttribute();
     if (renderAjaxSuggest) {
       writer.writeAttribute(HtmlAttributes.AUTOCOMPLETE, "off", false);
     }
@@ -153,9 +152,9 @@
       page.getScriptFiles().add("script/controls.js");
       page.getScriptFiles().add("script/inputSuggest.js");
 
-      writer.startElement(HtmlConstants.DIV);
+      writer.startElement(HtmlConstants.DIV, null);
       writer.writeClassAttribute("tobago-in-suggest-popup");
-      writer.writeAttribute(HtmlAttributes.STYLE, "display: none;", null);
+      writer.writeStyleAttribute("display: none;");
       writer.writeIdAttribute(popupId);
       writer.endElement(HtmlConstants.DIV);
 

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java Wed May  9 11:07:48 2007
@@ -43,8 +43,8 @@
 import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
 import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
-import org.apache.myfaces.tobago.renderkit.RenderUtil;
 import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
+import org.apache.myfaces.tobago.renderkit.RenderUtil;
 import org.apache.myfaces.tobago.renderkit.html.CommandRendererHelper;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
@@ -129,7 +129,7 @@
     String bac = "green;";
     for (Object o : component.getChildren()) {
       if (o instanceof UIMenu) {
-        writer.startElement(HtmlConstants.SPAN);
+        writer.startElement(HtmlConstants.SPAN, null);
         writer.writeAttribute(HtmlAttributes.STYLE, "position: relative; background: " + bac + ";", null);
         writeMenuEntry(facesContext, writer, (UIMenu) o);
         writer.endElement(HtmlConstants.SPAN);

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java Wed May  9 11:07:48 2007
@@ -35,16 +35,16 @@
 import static org.apache.myfaces.tobago.TobagoConstants.FACET_MENUBAR;
 import static org.apache.myfaces.tobago.TobagoConstants.FORM_ACCEPT_CHARSET;
 import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
+import org.apache.myfaces.tobago.component.ComponentUtil;
 import org.apache.myfaces.tobago.component.UILayout;
 import org.apache.myfaces.tobago.component.UIPage;
-import org.apache.myfaces.tobago.component.ComponentUtil;
 import org.apache.myfaces.tobago.context.ClientProperties;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
 import org.apache.myfaces.tobago.renderkit.PageRendererBase;
 import org.apache.myfaces.tobago.renderkit.RenderUtil;
-import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
-import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
+import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
+import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
 import org.apache.myfaces.tobago.util.AccessKeyMap;
 import org.apache.myfaces.tobago.util.ResponseUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
@@ -53,17 +53,17 @@
 import javax.faces.application.FacesMessage;
 import javax.faces.application.ViewHandler;
 import javax.faces.component.UIComponent;
+import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
-import javax.faces.context.ExternalContext;
 import java.io.IOException;
 import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
-import java.util.Locale;
 
 public class PageRenderer extends PageRendererBase {
   private static final Log LOG = LogFactory.getLog(PageRenderer.class);
@@ -170,7 +170,7 @@
     writer.startElement(HtmlConstants.HTML, null);
     writer.startElement(HtmlConstants.HEAD, null);
 
-    HtmlRendererUtil.writeJavascript(writer, "var TbgHeadStart = new Date();");
+    writer.writeJavascript("var TbgHeadStart = new Date();");
 
     // meta
     // TODO duplicate; see PageTag.doStartTag()
@@ -204,7 +204,6 @@
     if (styleBlocks.size() > 0) {
       writer.startElement(HtmlConstants.STYLE, null);
       for (String cssBlock : styleBlocks) {
-        writer.flush();
         writer.write(cssBlock);
       }
       writer.endElement(HtmlConstants.STYLE);
@@ -252,10 +251,9 @@
     // focus id
     String focusId = page.getFocusId();
     if (focusId != null) {
-      HtmlRendererUtil.writeJavascript(writer, "Tobago.focusId = '" + focusId + "';");
+      writer.writeJavascript("Tobago.focusId = '" + focusId + "';");
     }
 
-    HtmlRendererUtil.startJavascript(writer);
     if (component.getFacets().containsKey(FACET_ACTION)) {
       UIComponent command = component.getFacet(FACET_ACTION);
       if (command != null && command.isRendered()) {
@@ -264,34 +262,33 @@
             + command.getClientId(facesContext) + "')\", " + duration + ");\n");
       }
     }
-    //page.getOnloadScripts()
+    StringBuilder script = new StringBuilder();
+
     // onload script
-    writeEventFunction(writer, page.getOnloadScripts(), "load", false);
+    writeEventFunction(script, page.getOnloadScripts(), "load", false);
 
     // onunload script
-    writeEventFunction(writer, page.getOnunloadScripts(), "unload", false);
+    writeEventFunction(script, page.getOnunloadScripts(), "unload", false);
 
     // onexit script
-    writeEventFunction(writer, page.getOnexitScripts(), "exit", false);
+    writeEventFunction(script, page.getOnexitScripts(), "exit", false);
 
-    writeEventFunction(writer, page.getOnsubmitScripts(), "submit", true);
+    writeEventFunction(script, page.getOnsubmitScripts(), "submit", true);
 
    int debugCounter = 0;
-    for (String script : page.getScriptBlocks()) {
+    for (String scriptBlock : page.getScriptBlocks()) {
 
       if (LOG.isDebugEnabled()) {
-        LOG.debug("write scriptblock " + ++debugCounter + " :\n" + script);
+        LOG.debug("write scriptblock " + ++debugCounter + " :\n" + scriptBlock);
       }
-      writer.write(script);
-      writer.write('\n');
+      script.append(scriptBlock);
+      script.append('\n');
     }
+    writer.writeJavascript(script.toString());
 
     String clientId = page.getClientId(facesContext);
 
-    HtmlRendererUtil.endJavascript(writer);
-//    writer.endElement("script");
-    String defaultActionId = page.getDefaultActionId() != null
-        ? page.getDefaultActionId() : "";
+    String defaultActionId = page.getDefaultActionId() != null ? page.getDefaultActionId() : "";
     writer.endElement(HtmlConstants.HEAD);
     writer.startElement(HtmlConstants.BODY, page);
     writer.writeAttribute(HtmlAttributes.ONLOAD, "Tobago.init('" + clientId + "');", null);
@@ -311,7 +308,7 @@
     images.append("Tobago.OVERLAY_WAIT = '");
     images.append(ResourceManagerUtil.getImageWithPath(facesContext, "image/tobago-overlay-wait.gif"));
     images.append("';\n");
-    HtmlRendererUtil.writeJavascript(writer, images.toString());
+    writer.writeJavascript(images.toString());
 
     if (debugMode) {
       final String[] jsFiles = new String[]{
@@ -322,7 +319,7 @@
       final String[] jsCommand = new String[]{"new LOG.LogArea({hide: " + hideClientLogging + "});"};
       HtmlRendererUtil.writeScriptLoader(facesContext, jsFiles, jsCommand);
     }
-    HtmlRendererUtil.writeJavascript(writer, "TbgTimer.startBody = new Date();");
+    writer.writeJavascript("TbgTimer.startBody = new Date();");
 
     writer.startElement(HtmlConstants.FORM, page);
     writer.writeNameAttribute(
@@ -344,7 +341,7 @@
     writer.endElement(HtmlConstants.INPUT);
 
     if (debugMode) {
-      writer.startElement(HtmlConstants.INPUT);
+      writer.startElement(HtmlConstants.INPUT, null);
       writer.writeAttribute(HtmlAttributes.VALUE, clientLogSeverity, null);
       writer.writeAttribute(HtmlAttributes.ID, clientId + SUBCOMPONENT_SEP + "clientSeverity", null);
       writer.writeAttribute(HtmlAttributes.NAME, clientId + SUBCOMPONENT_SEP + "clientSeverity", null);
@@ -380,7 +377,7 @@
     // write the previously rendered popups
     writer.write(popups.toString());
 
-    writer.startElement(HtmlConstants.SPAN);
+    writer.startElement(HtmlConstants.SPAN, null);
     writer.writeIdAttribute(clientId + SUBCOMPONENT_SEP + "jsf-state-container");
     writer.flush();
     viewHandler.writeState(facesContext);
@@ -412,7 +409,7 @@
           logMessages.toArray(new String[logMessages.size()]));
     }
 
-    HtmlRendererUtil.writeJavascript(writer, "TbgTimer.endBody = new Date();");
+    writer.writeJavascript("TbgTimer.endBody = new Date();");
     writer.endElement(HtmlConstants.BODY);
     writer.endElement(HtmlConstants.HTML);
 
@@ -425,32 +422,34 @@
   }
 
   private void writeEventFunction(
-      TobagoResponseWriter writer, Set<String> eventFunctions, String event, boolean returnBoolean)
+      StringBuilder script, Set<String> eventFunctions, String event, boolean returnBoolean)
       throws IOException {
     if (!eventFunctions.isEmpty()) {
-      writer.write("Tobago.applicationOn" + event + " = function() {\n");
+      script.append("Tobago.applicationOn");
+      script.append(event);
+      script.append(" = function() {\n");
       if (returnBoolean) {
-        writer.write("  var result;\n");
+        script.append("  var result;\n");
       }
       for (String function : eventFunctions) {
         if (returnBoolean) {
-          writer.write("  result = ");
+          script.append("  result = ");
         } else {
-          writer.write("  ");
+          script.append("  ");
         }
-        writer.write(function);
+        script.append(function);
         if (!function.trim().endsWith(";")) {
-          writer.write(";\n");
+          script.append(";\n");
         } else {
-          writer.write("\n");
+          script.append("\n");
         }
         if (returnBoolean) {
-          writer.write("  if (typeof result == \"boolean\" && ! result) {\n");
-          writer.write("    return false;\n");
-          writer.write("  }\n");
+          script.append("  if (typeof result == \"boolean\" && ! result) {\n");
+          script.append("    return false;\n");
+          script.append("  }\n");
         }
       }
-      writer.write("\n  return true;\n}\n");
+      script.append("\n  return true;\n}\n");
     }
   }
 

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java Wed May  9 11:07:48 2007
@@ -27,20 +27,20 @@
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_HEIGHT;
 import static org.apache.myfaces.tobago.TobagoConstants.FACET_LAYOUT;
 import static org.apache.myfaces.tobago.TobagoConstants.FACET_RELOAD;
+import org.apache.myfaces.tobago.ajax.api.AjaxPhaseListener;
+import org.apache.myfaces.tobago.ajax.api.AjaxRenderer;
+import org.apache.myfaces.tobago.ajax.api.AjaxResponseRenderer;
+import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
 import org.apache.myfaces.tobago.component.ComponentUtil;
 import org.apache.myfaces.tobago.component.UIPanel;
 import org.apache.myfaces.tobago.component.UIReload;
-import org.apache.myfaces.tobago.renderkit.RenderUtil;
-import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
+import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.renderkit.LayoutInformationProvider;
+import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
+import org.apache.myfaces.tobago.renderkit.RenderUtil;
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
-import org.apache.myfaces.tobago.config.TobagoConfig;
-import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
-import org.apache.myfaces.tobago.ajax.api.AjaxPhaseListener;
-import org.apache.myfaces.tobago.ajax.api.AjaxRenderer;
-import org.apache.myfaces.tobago.ajax.api.AjaxResponseRenderer;
 
 import javax.faces.component.UIComponent;
 import javax.faces.component.UINamingContainer;
@@ -132,7 +132,7 @@
     writer.writeComponentClass();
     writer.writeIdAttribute(clientId);
     if (TobagoConfig.getInstance(facesContext).isAjaxEnabled()) {
-      HtmlRendererUtil.writeJavascript(writer, "Tobago.addAjaxComponent(\"" + clientId + "\")");
+      writer.writeJavascript("Tobago.addAjaxComponent(\"" + clientId + "\")");
       Integer frequency = null;
       UIComponent facetReload = component.getFacet(FACET_RELOAD);
       if (facetReload != null && facetReload instanceof UIReload && facetReload.isRendered()) {

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java Wed May  9 11:07:48 2007
@@ -30,16 +30,15 @@
 import org.apache.myfaces.tobago.component.UIPopup;
 import org.apache.myfaces.tobago.context.ClientProperties;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
-import org.apache.myfaces.tobago.renderkit.RenderUtil;
 import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
+import org.apache.myfaces.tobago.renderkit.RenderUtil;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
-import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
+import org.apache.myfaces.tobago.webapp.OptimizedResponseWriter;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
 import java.io.IOException;
 
 public class PopupRenderer extends LayoutableRendererBase implements AjaxRenderer {
@@ -115,7 +114,7 @@
 
   public void encodeEnd(FacesContext facesContext,
       UIComponent uiComponent) throws IOException {
-    ResponseWriter writer = facesContext.getResponseWriter();
+    OptimizedResponseWriter writer = (OptimizedResponseWriter) facesContext.getResponseWriter();
     UIPopup component = (UIPopup) uiComponent;
     final String clientId = component.getClientId(facesContext);
 
@@ -123,7 +122,7 @@
 
     String setupScript = "Tobago.setupPopup('" + clientId + "', '"
         + component.getLeft() + "', '" + component.getTop() + "');";
-    HtmlRendererUtil.writeJavascript(writer, setupScript);
+    writer.writeJavascript(setupScript);
   }
 
   public void encodeAjax(FacesContext facesContext, UIComponent component) throws IOException {

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ProgressRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ProgressRenderer.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ProgressRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ProgressRenderer.java Wed May  9 11:07:48 2007
@@ -25,21 +25,19 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
+import org.apache.myfaces.tobago.component.UICommand;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
 import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
-import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
-import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
+import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
-import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
-import org.apache.myfaces.tobago.component.UICommand;
 import org.apache.myfaces.tobago.util.LayoutUtil;
+import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIOutput;
 import javax.faces.context.FacesContext;
-import javax.swing.BoundedRangeModel;
-import javax.swing.DefaultBoundedRangeModel;
+import javax.swing.*;
 import java.io.IOException;
 
 
@@ -115,7 +113,7 @@
     if (model.getValue() == model.getMaximum() && facet != null
         && facet instanceof UICommand) {
       UICommand command = (UICommand) facet;
-      HtmlRendererUtil.writeJavascript(writer, "Tobago.submitAction('" + command.getClientId(facesContext) + "');");
+      writer.writeJavascript("Tobago.submitAction('" + command.getClientId(facesContext) + "');");
     }
 
   }

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java Wed May  9 11:07:48 2007
@@ -31,15 +31,15 @@
 import org.apache.myfaces.tobago.component.ComponentUtil;
 import org.apache.myfaces.tobago.component.UIPage;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
-import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
-import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
-import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.InputRendererBase;
-import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
+import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
+import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
+import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
 import org.apache.myfaces.tobago.util.DateFormatUtils;
+import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
-import javax.faces.component.UIInput;
 import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
 import javax.faces.convert.DateTimeConverter;
@@ -144,7 +144,7 @@
     String imageId = idPrefix + "inc";
     String imageSrc = "image/timeIncrement.gif";
     HtmlRendererUtil.addImageSources(facesContext, writer, imageSrc, imageId);
-    writer.startElement(HtmlConstants.IMG);
+    writer.startElement(HtmlConstants.IMG, null);
     writer.writeIdAttribute(imageId);
     writer.writeAttribute(HtmlAttributes.ONCLICK, "tbgIncTime(this)", false);
     writer.writeClassAttribute("tobago-time-inc-image"
@@ -163,7 +163,7 @@
     imageId = idPrefix + "dec";
     imageSrc = "image/timeDecrement.gif";
     HtmlRendererUtil.addImageSources(facesContext, writer, imageSrc, imageId);
-    writer.startElement(HtmlConstants.IMG);
+    writer.startElement(HtmlConstants.IMG, null);
     writer.writeIdAttribute(imageId);
     writer.writeAttribute(HtmlAttributes.ONCLICK, "tbgDecTime(this)", false);
     writer.writeClassAttribute("tobago-time-dec-image"
@@ -178,15 +178,12 @@
     }
     writer.endElement(HtmlConstants.IMG);
 
-
-
     writer.startElement(HtmlConstants.INPUT, input);
     writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
     writer.writeIdAttribute(id + ":converterPattern");
     writer.writeAttribute(HtmlAttributes.VALUE, converterPattern, null);
     writer.endElement(HtmlConstants.INPUT);
 
-
     writer.startElement(HtmlConstants.INPUT, input);
     writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
     writer.writeIdAttribute(id);
@@ -194,7 +191,6 @@
     writer.writeAttribute(HtmlAttributes.VALUE, hour + ":" + minute + ":" + second, false);
     writer.endElement(HtmlConstants.INPUT);
 
-
     String dateTextBoxId = (String) input.getAttributes().get(ATTR_CALENDAR_DATE_INPUT_ID);
 
     if (dateTextBoxId != null) {
@@ -206,7 +202,7 @@
   }
 
   private void writeInputSeparator(TobagoResponseWriter writer, String sep) throws IOException {
-    writer.startElement(HtmlConstants.SPAN);
+    writer.startElement(HtmlConstants.SPAN, null);
     writer.writeClassAttribute("tobago-time-sep");
     writer.writeText(sep, null);
     writer.endElement(HtmlConstants.SPAN);
@@ -214,7 +210,7 @@
 
   private void writeInput(TobagoResponseWriter writer, String id, String hour, boolean hourMode)
       throws IOException {
-    writer.startElement(HtmlConstants.INPUT);
+    writer.startElement(HtmlConstants.INPUT, null);
     writer.writeAttribute(HtmlAttributes.TYPE, "text", false);
     writer.writeIdAttribute(id);
     writer.writeClassAttribute("tobago-time-input");
@@ -225,4 +221,3 @@
     writer.endElement(HtmlConstants.INPUT);
   }
 }
-

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.java Wed May  9 11:07:48 2007
@@ -35,8 +35,8 @@
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SUPPPRESS_TOOLBAR_CONTAINER;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_VALUE;
-import static org.apache.myfaces.tobago.TobagoConstants.FACET_MENUPOPUP;
 import static org.apache.myfaces.tobago.TobagoConstants.FACET_ITEMS;
+import static org.apache.myfaces.tobago.TobagoConstants.FACET_MENUPOPUP;
 import static org.apache.myfaces.tobago.TobagoConstants.FACET_TOOL_BAR;
 import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_BOX;
 import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_MENUBAR;
@@ -50,12 +50,12 @@
 import org.apache.myfaces.tobago.context.ResourceManagerFactory;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
 import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
-import org.apache.myfaces.tobago.renderkit.RenderUtil;
 import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
-import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
-import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
-import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
+import org.apache.myfaces.tobago.renderkit.RenderUtil;
 import org.apache.myfaces.tobago.renderkit.html.CommandRendererHelper;
+import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
+import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
+import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
 import org.apache.myfaces.tobago.taglib.component.ToolBarTag;
 import org.apache.myfaces.tobago.util.AccessKeyMap;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
@@ -63,9 +63,9 @@
 import javax.faces.component.UICommand;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIPanel;
-import javax.faces.component.UIViewRoot;
 import javax.faces.component.UISelectBoolean;
 import javax.faces.component.UISelectOne;
+import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
 import javax.faces.model.SelectItem;
 import java.io.IOException;
@@ -221,9 +221,7 @@
         if (item.getValue().equals(value) || markFirst) {
           checked = true;
           markFirst = false;
-          HtmlRendererUtil.startJavascript(writer);
-          writer.write("    " + onClickPrefix + formattedValue + "');");
-          HtmlRendererUtil.endJavascript(writer);
+          writer.writeJavascript("    " + onClickPrefix + formattedValue + "');");
         } else {
           checked = false;
         }
@@ -252,17 +250,15 @@
     String clientId = checkbox.getClientId(facesContext);
     onClick = RenderUtil.addMenuCheckToggle(clientId, onClick);
     if (checked) {
-      HtmlRendererUtil.startJavascript(writer);
-      writer.write("    menuCheckToggle('" + clientId + "');\n");
-      HtmlRendererUtil.endJavascript(writer);
+      writer.writeJavascript("    menuCheckToggle('" + clientId + "');\n");
     }
 
     renderToolbarButton(facesContext, command, writer, boxFacet, addExtraHoverClass, checked, onClick);
   }
 
-  private void renderToolbarButton(FacesContext facesContext,
-                                   final UICommand command, TobagoResponseWriter writer, boolean boxFacet,
-                                   boolean addExtraHoverClass, boolean selected, String onClick)
+  private void renderToolbarButton(
+      FacesContext facesContext, final UICommand command, TobagoResponseWriter writer, boolean boxFacet,
+      boolean addExtraHoverClass, boolean selected, String onClick)
       throws IOException {
     if (!command.isRendered()) {
       return;

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java Wed May  9 11:07:48 2007
@@ -31,9 +31,9 @@
 import org.apache.myfaces.tobago.component.UITreeOldNode;
 import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
-import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
-import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
+import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
+import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
 import javax.faces.component.UIComponent;
@@ -107,9 +107,7 @@
     }
 
     if (!TobagoConfig.getInstance(facesContext).isAjaxEnabled()) {
-      HtmlRendererUtil.startJavascript(writer);
-      writer.writeText(scriptText, null);
-      HtmlRendererUtil.endJavascript(writer);
+      writer.writeJavascript(scriptText);
     } else {
       HtmlRendererUtil.writeScriptLoader(facesContext, scripts,
           new String[] {scriptText.replaceAll("\n", " ")});

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeOldRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeOldRenderer.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeOldRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeOldRenderer.java Wed May  9 11:07:48 2007
@@ -17,23 +17,23 @@
  * limitations under the License.
  */
 
-import org.apache.myfaces.tobago.renderkit.RenderUtil;
-import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
-import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
-import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
-import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
+import org.apache.myfaces.tobago.TobagoConstants;
 import org.apache.myfaces.tobago.component.ComponentUtil;
 import org.apache.myfaces.tobago.component.UITreeOld;
 import org.apache.myfaces.tobago.component.UITreeOldNode;
-import org.apache.myfaces.tobago.model.TreeState;
-import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
-import org.apache.myfaces.tobago.TobagoConstants;
+import org.apache.myfaces.tobago.model.TreeState;
+import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
+import org.apache.myfaces.tobago.renderkit.RenderUtil;
+import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
+import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
+import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
+import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
-import javax.faces.context.FacesContext;
-import javax.faces.component.UIComponent;
 import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
 import java.io.IOException;
 import java.io.StringWriter;
 import java.util.List;
@@ -180,12 +180,12 @@
     }
 
     if (!TobagoConfig.getInstance(facesContext).isAjaxEnabled()) {
-      HtmlRendererUtil.startJavascript(writer);
+      StringBuilder script = new StringBuilder();
       for (String scriptText : scriptTexts) {
-        writer.writeText(scriptText, null);
-        writer.writeText('\n', null);
+        script.append(scriptText);
+        script.append('\n');
       }
-      HtmlRendererUtil.endJavascript(writer);
+      writer.writeJavascript(script.toString());
     } else {
       HtmlRendererUtil.writeScriptLoader(facesContext, scripts, scriptTexts);
     }

Modified: myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java?view=diff&rev=536607&r1=536606&r2=536607
==============================================================================
--- myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java (original)
+++ myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java Wed May  9 11:07:48 2007
@@ -36,9 +36,9 @@
 import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
 import org.apache.myfaces.tobago.renderkit.BoxRendererBase;
 import org.apache.myfaces.tobago.renderkit.RenderUtil;
-import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
-import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
+import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
+import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
 import org.apache.myfaces.tobago.renderkit.html.HtmlStyleMap;
 import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
 import org.apache.myfaces.tobago.taglib.component.ToolBarTag;
@@ -81,8 +81,7 @@
     if (style != null) {
       writer.writeAttribute(HtmlAttributes.STYLE, style, null);
     }
-    HtmlRendererUtil.writeJavascript(writer,
-        "Tobago.addAjaxComponent(\"" + clientId + "\")");
+    writer.writeJavascript("Tobago.addAjaxComponent(\"" + clientId + "\")");
 
     encodeBeginInner(facesContext, writer, component);
   }