You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2008/05/12 21:31:55 UTC

svn commit: r655613 - in /myfaces/tobago/trunk: ./ core/src/main/java/org/apache/myfaces/tobago/ajax/api/ core/src/main/java/org/apache/myfaces/tobago/component/ core/src/main/java/org/apache/myfaces/tobago/context/ core/src/main/java/org/apache/myface...

Author: bommel
Date: Mon May 12 12:31:54 2008
New Revision: 655613

URL: http://svn.apache.org/viewvc?rev=655613&view=rev
Log:
(TOBAGO-664) Avoid buffering of the request or request parts as much as possible
(TOBAGO-661) Add immediate update check for UIReload

Added:
    myfaces/tobago/trunk/example/facelets/src/main/webapp/layout.xml   (with props)
Removed:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponse.java
Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxComponent.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxRenderer.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxUtils.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIData.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPopup.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroup.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIInputBase.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPanelBase.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/TobagoFacesContext.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/ApplyRequestValuesExecutor.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/ProcessValidationsExecutor.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/RenderResponseExecutor.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/TobagoLifecycle.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/AbstractAjaxRendererBaseWrapper.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/ReloadTagDeclaration.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/EncodeAjaxCallback.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseJsonWriterImpl.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterImpl.java
    myfaces/tobago/trunk/example/facelets/pom.xml
    myfaces/tobago/trunk/pom.xml
    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/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/SheetRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js
    myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java
    myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java
    myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxComponent.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxComponent.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxComponent.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxComponent.java Mon May 12 12:31:54 2008
@@ -22,6 +22,6 @@
 
 public interface AjaxComponent {
 
-  int encodeAjax(FacesContext context) throws IOException;
+  void encodeAjax(FacesContext context) throws IOException;
 
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxRenderer.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxRenderer.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxRenderer.java Mon May 12 12:31:54 2008
@@ -25,5 +25,5 @@
  * !! copy of sandbox org.apache.myfaces.custom.ajax.api.AjaxRenderer !!
  */
 public interface AjaxRenderer {
-    int encodeAjax(FacesContext context, UIComponent component) throws IOException;
+    void encodeAjax(FacesContext context, UIComponent component) throws IOException;
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java Mon May 12 12:31:54 2008
@@ -21,18 +21,16 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_CHARSET;
-import static org.apache.myfaces.tobago.ajax.api.AjaxResponse.CODE_RELOAD_REQUIRED;
-import static org.apache.myfaces.tobago.ajax.api.AjaxResponse.CODE_SUCCESS;
 import org.apache.myfaces.tobago.util.ComponentUtil;
 import static org.apache.myfaces.tobago.lifecycle.TobagoLifecycle.FACES_MESSAGES_KEY;
 import static org.apache.myfaces.tobago.lifecycle.TobagoLifecycle.VIEW_ROOT_KEY;
 import org.apache.myfaces.tobago.util.EncodeAjaxCallback;
-import org.apache.myfaces.tobago.util.FastStringWriter;
 import org.apache.myfaces.tobago.util.RequestUtils;
 import org.apache.myfaces.tobago.util.ResponseUtils;
 import org.apache.myfaces.tobago.util.JndiUtils;
 import org.apache.myfaces.tobago.compat.FacesUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseJsonWriterImpl;
+import org.apache.myfaces.tobago.context.TobagoFacesContext;
 
 import javax.faces.FactoryFinder;
 import javax.faces.application.StateManager;
@@ -55,6 +53,10 @@
 import java.util.Map;
 
 public class AjaxResponseRenderer {
+  public static final int CODE_SUCCESS = 200;
+  public static final int CODE_NOT_MODIFIED = 304;
+  public static final int CODE_RELOAD_REQUIRED = 309;
+  public static final int CODE_ERROR = 500;
 
   private static final Log LOG = LogFactory.getLog(AjaxResponseRenderer.class);
 
@@ -106,63 +108,54 @@
         //noinspection unchecked
         sessionMap.put(FACES_MESSAGES_KEY, messageHolders);
       }
-      writeResponseReload(facesContext);
+      writeResponse(facesContext, renderKit, true);
     } else {
-      List<AjaxResponse> responseParts = new ArrayList<AjaxResponse>();
-      Map<String, UIComponent> ajaxComponents = AjaxUtils.getAjaxComponents(facesContext);
-
-      for (Map.Entry<String, UIComponent> entry : ajaxComponents.entrySet()) {
-        AjaxComponent component = (AjaxComponent) entry.getValue();
-        responseParts.add(renderComponent(facesContext, renderKit, entry.getKey(), component));
-      }
-
-      String state = saveState(facesContext, renderKit);
-      writeResponse(facesContext, responseParts, state);
+      writeResponse(facesContext, renderKit, false);
     }
   }
 
-  private AjaxResponse renderComponent(FacesContext facesContext, RenderKit renderKit, String clientId,
+  private void renderComponent(FacesContext facesContext, RenderKit renderKit, String clientId,
       AjaxComponent component) throws IOException {
-    FastStringWriter content = new FastStringWriter();
-    ResponseWriter contentWriter = renderKit.createResponseWriter(content, contentType, null);
+    PrintWriter writer = getPrintWriter(facesContext.getExternalContext());
+    ResponseWriter contentWriter = renderKit.createResponseWriter(writer, contentType, null);
     facesContext.setResponseWriter(contentWriter);
+
     if (LOG.isDebugEnabled()) {
       LOG.debug("write ajax response for " + component);
     }
+    writer.write("{\n    ajaxId: \"");
+    writer.write(clientId);
+    writer.write("\",\n");
+
+    writer.write("    responseCode: ");
+    writer.write(Integer.toString(CODE_SUCCESS));
+    writer.write(",\n");
 
+    writer.write("    html: \"");
     try {
       FacesUtils.invokeOnComponent(facesContext, facesContext.getViewRoot(), clientId, callback);
     } catch (EmptyStackException e) {
-      LOG.error(" content = \"" + content.toString() + "\"");
+      //LOG.error(" content = \"" + content.toString() + "\"");
       throw e;
     }
 
     if (contentWriter instanceof TobagoResponseJsonWriterImpl) {
-       return new AjaxResponse(clientId, callback.getResponseCode(), content.toString(),
-           ((TobagoResponseJsonWriterImpl) contentWriter).getJavascript());
-    } else {
-      return new AjaxResponse(clientId, callback.getResponseCode(), content.toString());
+      writer.write("\",\n");
+      writer.write("    script: function() {\n");
+      writer.write(((TobagoResponseJsonWriterImpl) contentWriter).getJavascript());
+      writer.write("\n    }\n  }");
     }
   }
 
-  private void writeResponseReload(FacesContext facesContext)
+  private void saveState(FacesContext facesContext, RenderKit renderKit)
       throws IOException {
-    ArrayList<AjaxResponse> responseParts = new ArrayList<AjaxResponse>();
-    responseParts.add(new AjaxResponse("", CODE_RELOAD_REQUIRED, ""));
-    writeResponse(facesContext, responseParts, "");
-  }
-
-  private String saveState(FacesContext facesContext, RenderKit renderKit)
-      throws IOException {
-    FastStringWriter jsfState = new FastStringWriter();
-    ResponseWriter stateWriter = renderKit.createResponseWriter(jsfState, null, null);
+    ResponseWriter stateWriter =
+        renderKit.createResponseWriter(getPrintWriter(facesContext.getExternalContext()), contentType, null);
     facesContext.setResponseWriter(stateWriter);
 
     StateManager stateManager = facesContext.getApplication().getStateManager();
-    StateManager.SerializedView serializedView
-        = stateManager.saveSerializedView(facesContext);
+    StateManager.SerializedView serializedView = stateManager.saveSerializedView(facesContext);
     stateManager.writeState(facesContext, serializedView);
-    return jsfState.toString();
   }
 
   private static void ensureContentTypeHeader(FacesContext facesContext, String charset, String contentType) {
@@ -180,9 +173,8 @@
     }
   }
 
-  private void writeResponse(FacesContext facesContext,
-                             List<AjaxResponse> responseParts, String jsfState)
-      throws IOException {
+  private void writeResponse(FacesContext facesContext, RenderKit renderKit, boolean reloadRequired) throws IOException {
+
     ExternalContext externalContext = facesContext.getExternalContext();
     RequestUtils.ensureEncoding(externalContext);
     ResponseUtils.ensureNoCacheHeader(externalContext);
@@ -195,32 +187,31 @@
     }
     ensureContentTypeHeader(facesContext, charset, contentType);
 
-    boolean reloadRequired = false;
-
-    for (AjaxResponse response : responseParts) {
-      if (response.getResponseCode() == CODE_RELOAD_REQUIRED) {
-        reloadRequired = true;
-        break;
-      }
-    }
-
     PrintWriter writer = getPrintWriter(externalContext);
     writer.write("{\n  tobagoAjaxResponse: true,\n");
     writer.write("  responseCode: ");
     writer.write(reloadRequired ? Integer.toString(CODE_RELOAD_REQUIRED) : Integer.toString(CODE_SUCCESS));
-    writer.write(",\n");
-    writer.write("  jsfState: \"");
-    writer.write(AjaxUtils.encodeJavascriptString(jsfState));
-    writer.write("\"");
 
+    if (!reloadRequired) {
+      writer.write(",\n");
+      writer.write("  jsfState: \"");
+      saveState(facesContext, renderKit);
+      writer.write("\"");
+    }
+
+    Map<String, UIComponent> ajaxComponents = AjaxUtils.getAjaxComponents(facesContext);
     int i = 0;
-    // add parts to response
-    for (AjaxResponse part : responseParts) {
+    for (Map.Entry<String, UIComponent> entry : ajaxComponents.entrySet()) {
       writer.write(",\n");
       writer.write("  ajaxPart_");
       writer.write(Integer.toString(i++));
       writer.write(": ");
-      part.writeJson(writer);
+
+      AjaxComponent component = (AjaxComponent) entry.getValue();
+      if (facesContext instanceof TobagoFacesContext) {
+        ((TobagoFacesContext) facesContext).setAjaxComponentId(entry.getKey());
+      }
+      renderComponent(facesContext, renderKit, entry.getKey(), component);
     }
 
     writer.write("\n}\n");

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxUtils.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxUtils.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxUtils.java Mon May 12 12:31:54 2008
@@ -22,8 +22,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.tobago.util.ComponentUtil;
-import static org.apache.myfaces.tobago.ajax.api.AjaxResponse.CODE_ERROR;
-import static org.apache.myfaces.tobago.ajax.api.AjaxResponse.CODE_SUCCESS;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
@@ -57,18 +55,17 @@
 
 
 
-  public static int encodeAjaxComponent(FacesContext facesContext, UIComponent component) throws IOException {
+  public static void encodeAjaxComponent(FacesContext facesContext, UIComponent component) throws IOException {
     if (facesContext == null) {
       throw new NullPointerException("facesContext");
     }
     if (!component.isRendered()) {
-      return CODE_SUCCESS;
+      return;
     }
     Object renderer = ComponentUtil.getRenderer(facesContext, component);
     if (renderer != null && renderer instanceof AjaxRenderer) {
-      return ((AjaxRenderer) renderer).encodeAjax(facesContext, component);
+      ((AjaxRenderer) renderer).encodeAjax(facesContext, component);
     }
-    return CODE_ERROR;
   }
 
   public static Map<String, UIComponent> parseAndStoreComponents(FacesContext facesContext) {

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIData.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIData.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIData.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIData.java Mon May 12 12:31:54 2008
@@ -19,10 +19,14 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_IMMEDIATE;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_FIRST;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SELECTED_LIST_STRING;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STATE;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_WIDTH_LIST_STRING;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_UPDATE;
+import static org.apache.myfaces.tobago.TobagoConstants.FACET_RELOAD;
+
 import org.apache.myfaces.tobago.ajax.api.AjaxComponent;
 import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
 import org.apache.myfaces.tobago.event.PageActionEvent;
@@ -36,6 +40,8 @@
 import org.apache.myfaces.tobago.compat.FacesUtils;
 import org.apache.myfaces.tobago.compat.InvokeOnComponent;
 import org.apache.myfaces.tobago.layout.LayoutTokens;
+import org.apache.myfaces.tobago.context.TobagoFacesContext;
+import org.apache.myfaces.tobago.util.ComponentUtil;
 
 import javax.faces.component.UIColumn;
 import javax.faces.component.UIComponent;
@@ -48,6 +54,7 @@
 import javax.faces.event.PhaseId;
 import javax.faces.render.Renderer;
 import javax.faces.FacesException;
+import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
@@ -281,7 +288,9 @@
         && (facesEvent instanceof SheetStateChangeEvent
         || facesEvent instanceof PageActionEvent)) {
       facesEvent.setPhaseId(PhaseId.INVOKE_APPLICATION);
-      LOG.info("queueEvent = \"" + facesEvent + "\"");
+      if (LOG.isInfoEnabled()) {
+        LOG.info("queueEvent = \"" + facesEvent + "\"");
+      }
       parent.queueEvent(facesEvent);
     } else {
       UIComponent source = facesEvent.getComponent();
@@ -352,7 +361,30 @@
     this.widthList = widthList;
   }
 
-  public int encodeAjax(FacesContext facesContext) throws IOException {
+  public void processDecodes(FacesContext context) {
+    if (context instanceof TobagoFacesContext && ((TobagoFacesContext) context).isAjax()) {
+      final String ajaxId = ((TobagoFacesContext) context).getAjaxComponentId();
+      UIComponent reload = getFacet(FACET_RELOAD);
+      if (ajaxId != null && ajaxId.equals(getClientId(context)) && reload != null && reload.isRendered()
+          && ajaxId.equals(ComponentUtil.findPage(context, this).getActionId())) {
+        Boolean immediate = (Boolean) reload.getAttributes().get(ATTR_IMMEDIATE);
+        if (immediate != null && immediate) {
+          Boolean update = (Boolean) reload.getAttributes().get(ATTR_UPDATE);
+          if (update != null && !update) {
+            if (context.getExternalContext().getResponse() instanceof HttpServletResponse) {
+              ((HttpServletResponse) context.getExternalContext().getResponse())
+                  .setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+            }
+            context.responseComplete();
+            return;
+          }
+        }
+      }
+    }
+    super.processDecodes(context);
+  }
+
+  public void encodeAjax(FacesContext facesContext) throws IOException {
     Renderer renderer = getRenderer(facesContext);
     if (renderer != null && renderer instanceof LayoutableRenderer) {
       ((LayoutableRenderer) renderer).layoutEnd(facesContext, this);
@@ -370,7 +402,17 @@
       setValue(getValue());
     }
     //}
-    return AjaxUtils.encodeAjaxComponent(facesContext, this);
+    UIComponent reload = getFacet(FACET_RELOAD);
+    if (reload != null && reload.isRendered()) {
+      Boolean immediate = (Boolean) reload.getAttributes().get(ATTR_IMMEDIATE);
+      if (immediate != null && !immediate) {
+        Boolean update = (Boolean) reload.getAttributes().get(ATTR_UPDATE);
+        if (update != null && !update) {
+          return;
+        }
+      }
+    }
+    AjaxUtils.encodeAjaxComponent(facesContext, this);
   }
 
   public Integer[] getScrollPosition() {
@@ -396,20 +438,28 @@
     try {
       String sheetId = getClientId(context);
       String idRemainder = clientId.substring(sheetId.length());
-      LOG.info("idRemainder = \"" + idRemainder + "\"");
+      if (LOG.isInfoEnabled()) {
+        LOG.info("idRemainder = \"" + idRemainder + "\"");
+      }
       if (idRemainder.matches("^:\\d+:.*")) {
         idRemainder = idRemainder.substring(1);
         int idx = idRemainder.indexOf(":");
         try {
           int rowIndex = Integer.parseInt(idRemainder.substring(0, idx));
-          LOG.info("set rowIndex = \"" + rowIndex + "\"");
+          if (LOG.isInfoEnabled()) {
+            LOG.info("set rowIndex = \"" + rowIndex + "\"");
+          }
           setRowIndex(rowIndex);
 
         } catch (NumberFormatException e) {
-          LOG.error("idRemainder = \"" + idRemainder + "\"", e);
+          if (LOG.isInfoEnabled()) {
+            LOG.error("idRemainder = \"" + idRemainder + "\"", e);
+          }
         }
       } else {
-        LOG.info("no match for \"^:\\d+:.*\"");
+        if (LOG.isInfoEnabled()) {
+          LOG.info("no match for \"^:\\d+:.*\"");
+        }
       }
 
       return FacesUtils.invokeOnComponent(context, this, clientId, callback);

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPopup.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPopup.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPopup.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPopup.java Mon May 12 12:31:54 2008
@@ -132,10 +132,9 @@
     activated = false;
   }
 
-  public int encodeAjax(FacesContext facesContext) throws IOException {
-    int responseCode = super.encodeAjax(facesContext);
+  public void encodeAjax(FacesContext facesContext) throws IOException {
+    super.encodeAjax(facesContext);
     activated = false;
-    return responseCode;
   }
 
   public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback)

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroup.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroup.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroup.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroup.java Mon May 12 12:31:54 2008
@@ -236,9 +236,9 @@
     return (TabChangeListener[]) getFacesListeners(TabChangeListener.class);
   }
 
-  public int encodeAjax(FacesContext facesContext) throws IOException {
+  public void encodeAjax(FacesContext facesContext) throws IOException {
     setRenderedIndex(getSelectedIndex());
-    return AjaxUtils.encodeAjaxComponent(facesContext, this);
+    AjaxUtils.encodeAjaxComponent(facesContext, this);
   }
 
   public abstract Integer getRenderedIndex();

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIInputBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIInputBase.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIInputBase.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIInputBase.java Mon May 12 12:31:54 2008
@@ -37,8 +37,8 @@
     }
   }
 
-  public int encodeAjax(FacesContext facesContext) throws IOException {
-    return AjaxUtils.encodeAjaxComponent(facesContext, this);
+  public void encodeAjax(FacesContext facesContext) throws IOException {
+    AjaxUtils.encodeAjaxComponent(facesContext, this);
   }
 
   public abstract Integer getTabIndex();

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPanelBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPanelBase.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPanelBase.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIPanelBase.java Mon May 12 12:31:54 2008
@@ -21,10 +21,17 @@
 import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
 import org.apache.myfaces.tobago.compat.FacesUtils;
 import org.apache.myfaces.tobago.compat.InvokeOnComponent;
+import org.apache.myfaces.tobago.context.TobagoFacesContext;
+import static org.apache.myfaces.tobago.TobagoConstants.FACET_RELOAD;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_IMMEDIATE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_UPDATE;
+import org.apache.myfaces.tobago.util.ComponentUtil;
 
 import javax.faces.context.FacesContext;
 import javax.faces.component.ContextCallback;
+import javax.faces.component.UIComponent;
 import javax.faces.FacesException;
+import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 
 /*
@@ -41,8 +48,42 @@
     }
   }
 
-  public int encodeAjax(FacesContext facesContext) throws IOException {
-    return AjaxUtils.encodeAjaxComponent(facesContext, this);
+  public void processDecodes(FacesContext context) {
+    if (context instanceof TobagoFacesContext && ((TobagoFacesContext) context).isAjax()) {
+
+      final String ajaxId = ((TobagoFacesContext) context).getAjaxComponentId();
+      UIComponent reload = getFacet(FACET_RELOAD);
+      if (ajaxId != null && ajaxId.equals(getClientId(context)) && reload != null && reload.isRendered()
+          && ajaxId.equals(ComponentUtil.findPage(context, this).getActionId())) {
+        Boolean immediate = (Boolean) reload.getAttributes().get(ATTR_IMMEDIATE);
+        if (immediate != null && immediate) {
+          Boolean update = (Boolean) reload.getAttributes().get(ATTR_UPDATE);
+          if (update != null && !update) {
+            if (context.getExternalContext().getResponse() instanceof HttpServletResponse) {
+              ((HttpServletResponse) context.getExternalContext().getResponse())
+                  .setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+            }
+            context.responseComplete();
+            return;
+          }
+        }
+      }
+    }
+    super.processDecodes(context);
+  }
+
+  public void encodeAjax(FacesContext facesContext) throws IOException {
+    UIComponent reload = getFacet(FACET_RELOAD);
+    if (reload != null && reload.isRendered()) {
+      Boolean immediate = (Boolean) reload.getAttributes().get(ATTR_IMMEDIATE);
+      if (immediate != null && !immediate) {
+        Boolean update = (Boolean) reload.getAttributes().get(ATTR_UPDATE);
+        if (update != null && !update) {
+          return;
+        }
+      }
+    }
+    AjaxUtils.encodeAjaxComponent(facesContext, this);
   }
 
   public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback)

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/TobagoFacesContext.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/TobagoFacesContext.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/TobagoFacesContext.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/TobagoFacesContext.java Mon May 12 12:31:54 2008
@@ -51,6 +51,8 @@
 
   private String enctype;
 
+  private String ajaxComponentId;
+
   private boolean ajax;
 
 
@@ -76,6 +78,14 @@
     this.ajax = ajax;
   }
 
+  public String getAjaxComponentId() {
+    return ajaxComponentId;
+  }
+
+  public void setAjaxComponentId(String ajaxComponentId) {
+    this.ajaxComponentId = ajaxComponentId;
+  }
+
   public String getEnctype() {
     return enctype;
   }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/ApplyRequestValuesExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/ApplyRequestValuesExecutor.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/ApplyRequestValuesExecutor.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/ApplyRequestValuesExecutor.java Mon May 12 12:31:54 2008
@@ -25,6 +25,7 @@
 import org.apache.myfaces.tobago.component.UIViewRoot;
 import org.apache.myfaces.tobago.util.ApplyRequestValuesCallback;
 import org.apache.myfaces.tobago.compat.FacesUtils;
+import org.apache.myfaces.tobago.context.TobagoFacesContext;
 
 import javax.faces.component.ContextCallback;
 
@@ -61,13 +62,18 @@
       AbstractUIPage page = ComponentUtil.findPage(facesContext);
       page.decode(facesContext);
       page.markSubmittedForm(facesContext);
-
+      if (facesContext instanceof TobagoFacesContext) {
+        ((TobagoFacesContext) facesContext).setAjax(true);
+      }
       // decode the action if actioncomponent not inside one of the ajaxcomponets
       // otherwise it is decoded there
       decodeActionComponent(facesContext, page, ajaxComponents);
 
       // and all ajax components
       for (Map.Entry<String, UIComponent> entry : ajaxComponents.entrySet()) {
+        if (facesContext instanceof TobagoFacesContext) {
+          ((TobagoFacesContext) facesContext).setAjaxComponentId(entry.getKey());
+        }
         FacesUtils.invokeOnComponent(facesContext, facesContext.getViewRoot(), entry.getKey(), contextCallback);
       }
 

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/ProcessValidationsExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/ProcessValidationsExecutor.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/ProcessValidationsExecutor.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/ProcessValidationsExecutor.java Mon May 12 12:31:54 2008
@@ -25,6 +25,7 @@
 import javax.faces.component.ContextCallback;
 import org.apache.myfaces.tobago.util.ProcessValidationsCallback;
 import org.apache.myfaces.tobago.compat.FacesUtils;
+import org.apache.myfaces.tobago.context.TobagoFacesContext;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
@@ -47,6 +48,9 @@
     Map<String, UIComponent> ajaxComponents = AjaxUtils.getAjaxComponents(facesContext);
     if (ajaxComponents != null) {
       for (Map.Entry<String, UIComponent> entry : ajaxComponents.entrySet()) {
+        if (facesContext instanceof TobagoFacesContext) {
+          ((TobagoFacesContext) facesContext).setAjaxComponentId(entry.getKey());
+        }
         FacesUtils.invokeOnComponent(facesContext, facesContext.getViewRoot(), entry.getKey(), contextCallback);
       }
       UIViewRoot viewRoot = ((UIViewRoot) facesContext.getViewRoot());

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/RenderResponseExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/RenderResponseExecutor.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/RenderResponseExecutor.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/RenderResponseExecutor.java Mon May 12 12:31:54 2008
@@ -45,9 +45,10 @@
   public boolean execute(FacesContext facesContext) {
     if (AjaxUtils.getAjaxComponents(facesContext) != null) {
       try {
-        TobagoFacesContext tobagoFacesContext = new TobagoFacesContext(facesContext);
-        tobagoFacesContext.setAjax(true);
-        ajaxResponseRenderer.renderResponse(tobagoFacesContext);
+        if (facesContext instanceof TobagoFacesContext) {
+          ((TobagoFacesContext) facesContext).setAjax(true);
+        }
+        ajaxResponseRenderer.renderResponse(facesContext);
       } catch (IOException e) {
         throw new FacesException(e.getMessage(), e);
       }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/TobagoLifecycle.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/TobagoLifecycle.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/TobagoLifecycle.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/TobagoLifecycle.java Mon May 12 12:31:54 2008
@@ -31,6 +31,7 @@
 
 import org.apache.myfaces.tobago.util.RequestUtils;
 import org.apache.myfaces.tobago.util.DebugUtils;
+import org.apache.myfaces.tobago.context.TobagoFacesContext;
 
 /**
  * Implements the lifecycle as described in Spec. 1.0 PFD Chapter 2
@@ -66,17 +67,22 @@
   }
 
   public void execute(FacesContext facesContext) throws FacesException {
-    PhaseListenerManager phaseListenerMgr
-        = new PhaseListenerManager(this, facesContext, getPhaseListeners());
+
+    TobagoFacesContext context = new TobagoFacesContext(facesContext);
+    PhaseListenerManager phaseListenerMgr = new PhaseListenerManager(this, context, getPhaseListeners());
+
+    // At very first ensure the requestEncoding, this MUST done before
+    // accessing request parameters, wich can occur in custom phaseListeners.
+    RequestUtils.ensureEncoding(context.getExternalContext());
+
     for (PhaseExecutor executor : lifecycleExecutors) {
-      if (executePhase(facesContext, executor, phaseListenerMgr)) {
+      if (executePhase(context, executor, phaseListenerMgr)) {
         return;
       }
     }
   }
 
-  private boolean executePhase(FacesContext facesContext, PhaseExecutor executor,
-      PhaseListenerManager phaseListenerMgr)
+  private boolean executePhase(FacesContext facesContext, PhaseExecutor executor, PhaseListenerManager phaseListenerMgr)
       throws FacesException {
 
     boolean skipFurtherProcessing = false;
@@ -84,9 +90,6 @@
       LOG.trace("entering " + executor.getPhase() + " in " + TobagoLifecycle.class.getName());
     }
 
-    // At very first ensure the requestEncoding, this MUST done before
-    // accessing request parameters, wich can occur in custom phaseListeners.
-    RequestUtils.ensureEncoding(facesContext.getExternalContext());
 
     try {
       phaseListenerMgr.informPhaseListenersBefore(executor.getPhase());
@@ -122,6 +125,10 @@
 
   public void render(FacesContext facesContext) throws FacesException {
     // if the response is complete we should not be invoking the phase listeners
+    if (!(facesContext instanceof TobagoFacesContext)) {
+      facesContext = new TobagoFacesContext(facesContext); 
+    }
+
     if (isResponseComplete(facesContext, renderExecutor.getPhase(), true)) {
       return;
     }
@@ -137,7 +144,6 @@
       if (isResponseComplete(facesContext, renderExecutor.getPhase(), true)) {
         return;
       }
-
       renderExecutor.execute(facesContext);
     } finally {
       phaseListenerMgr.informPhaseListenersAfter(renderExecutor.getPhase());

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/AbstractAjaxRendererBaseWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/AbstractAjaxRendererBaseWrapper.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/AbstractAjaxRendererBaseWrapper.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/AbstractAjaxRendererBaseWrapper.java Mon May 12 12:31:54 2008
@@ -26,8 +26,7 @@
 public abstract class AbstractAjaxRendererBaseWrapper extends AbstractLayoutableRendererBaseWrapper
     implements AjaxRenderer {
 
-  public int encodeAjax(FacesContext context, UIComponent component) throws IOException {
-    return ((AjaxRenderer) getRenderer(context)).encodeAjax(context, component);
+  public void encodeAjax(FacesContext context, UIComponent component) throws IOException {
+    ((AjaxRenderer) getRenderer(context)).encodeAjax(context, component);
   }
-
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/ReloadTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/ReloadTagDeclaration.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/ReloadTagDeclaration.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/ReloadTagDeclaration.java Mon May 12 12:31:54 2008
@@ -54,4 +54,14 @@
   @TagAttribute
   @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "true")
   void setUpdate(String update);
+
+  /**
+   * Flag indicating that
+   * the update check should be performed
+   * immediately (that is, during Apply Request Values phase) rather than
+   * waiting until Render Response phase.
+   */
+  @TagAttribute
+  @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "false")
+  void setImmediate(String immediate);
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/EncodeAjaxCallback.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/EncodeAjaxCallback.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/EncodeAjaxCallback.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/EncodeAjaxCallback.java Mon May 12 12:31:54 2008
@@ -27,18 +27,11 @@
 
 public class EncodeAjaxCallback implements javax.faces.component.ContextCallback {
 
-  private int responseCode;
-
   public void invokeContextCallback(FacesContext facesContext, UIComponent component) {
-    responseCode = 0;
     try {
-      responseCode = ((AjaxComponent) component).encodeAjax(facesContext);
+      ((AjaxComponent) component).encodeAjax(facesContext);
     } catch (IOException e) {
       throw new FacesException(e);
     }
   }
-
-  public int getResponseCode() {
-    return responseCode;
-  }
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseJsonWriterImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseJsonWriterImpl.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseJsonWriterImpl.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseJsonWriterImpl.java Mon May 12 12:31:54 2008
@@ -18,39 +18,127 @@
  */
 
 import org.apache.myfaces.tobago.util.FastStringWriter;
+import org.apache.myfaces.tobago.util.XmlUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
+import javax.faces.component.UIComponent;
 import java.io.Writer;
 import java.io.IOException;
+import java.util.EmptyStackException;
 
 public class TobagoResponseJsonWriterImpl extends TobagoResponseWriterImpl {
+  private static final Log LOG = LogFactory.getLog(TobagoResponseWriterImpl.class);
+
   private Writer javascriptWriter;
   private boolean javascriptMode;
+
   public TobagoResponseJsonWriterImpl(Writer writer, String contentType, String characterEncoding) {
     super(writer, contentType, characterEncoding);
     this.javascriptWriter = new FastStringWriter();
   }
 
   public void endJavascript() throws IOException {
-    super.endJavascript();
     javascriptMode = false;
   }
 
   public void startJavascript() throws IOException {
-    super.startJavascript();
     javascriptMode = true;
   }
 
   @Override
   public void write(String string) throws IOException {
-    writeInternal(javascriptMode?javascriptWriter:getWriter(), string);
+    writeInternal(javascriptMode ? javascriptWriter : getWriter(), string);
   }
 
   public void writeJavascript(String script) throws IOException {
     writeInternal(javascriptWriter, script);
-    writeInternal(javascriptWriter, "\n");
   }
 
   public String getJavascript() {
     return javascriptWriter.toString();
   }
+
+  protected void startElementInternal(Writer writer, String name, UIComponent currentComponent)
+      throws IOException {
+    this.component = currentComponent;
+    stack.push(name);
+    if (startStillOpen) {
+      writer.write(">");
+    }
+    writer.write("<");
+    writer.write(name);
+    startStillOpen = true;
+  }
+
+  protected void endElementInternal(Writer writer, String name) throws IOException {
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("end Element: " + name);
+    }
+    String top = "";
+    try {
+      top = stack.pop();
+    } catch (EmptyStackException e) {
+      LOG.error("Failed to close element \"" + name + "\"!");
+      throw e;
+    }
+    if (!top.equals(name)) {
+      final String trace = getCallingClassStackTraceElementString();
+      LOG.error("Element end with name='" + name + "' doesn't "
+          + "match with top element on the stack='" + top + "' "
+          + trace.substring(trace.indexOf('(')));
+    }
+
+    if (EMPTY_TAG.contains(name)) {
+      if (xml) {
+        writer.write("/>");
+      } else {
+        writer.write(">");
+      }
+    } else {
+      if (startStillOpen) {
+        writer.write(">");
+      }
+      writer.write("</");
+      writer.write(name);
+      writer.write(">");
+    }
+    startStillOpen = false;
+  }
+
+  protected void closeOpenTag() throws IOException {
+    if (startStillOpen) {
+      writer.write(">");
+      startStillOpen = false;
+    }
+  }
+
+  protected void writeAttributeInternal(Writer writer, String name, String value, boolean escape)
+      throws IOException {
+    if (!startStillOpen) {
+      String trace = getCallingClassStackTraceElementString();
+      String error = "Cannot write attribute when start-tag not open. "
+          + "name = '" + name + "' "
+          + "value = '" + value + "' "
+          + trace.substring(trace.indexOf('('));
+      LOG.error(error);
+      throw new IllegalStateException(error);
+    }
+
+    if (value != null) {
+      writer.write(' ');
+      writer.write(name);
+      writer.write("=\\\"");
+      if (xml) {
+        writer.write(XmlUtils.escape(value));
+      } else {
+        if (escape) {
+          helper.writeAttributeValue(value);
+        } else {
+          writer.write(value);
+        }
+      }
+      writer.write("\\\"");
+    }
+  }
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterImpl.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterImpl.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterImpl.java Mon May 12 12:31:54 2008
@@ -41,7 +41,7 @@
 
   private static final Log LOG = LogFactory.getLog(TobagoResponseWriterImpl.class);
 
-  private static final Set<String> EMPTY_TAG = new HashSet<String>(Arrays.asList(
+  protected static final Set<String> EMPTY_TAG = new HashSet<String>(Arrays.asList(
       HtmlConstants.BR,
       HtmlConstants.AREA,
       HtmlConstants.LINK,
@@ -53,24 +53,24 @@
       HtmlConstants.BASE,
       HtmlConstants.META));
 
-  private Writer writer;
+  protected Writer writer;
 
-  private UIComponent component;
+  protected UIComponent component;
 
-  private boolean startStillOpen;
+  protected boolean startStillOpen;
 
   private String contentType;
 
   private String characterEncoding;
 
-  private Stack<String> stack;
+  protected Stack<String> stack;
 
   /**
    * use XML instead HMTL
    */
-  private boolean xml;
+  protected boolean xml;
 
-  private HtmlWriterUtil helper;
+  protected HtmlWriterUtil helper;
 
   public TobagoResponseWriterImpl(final Writer writer, final String contentType,
       final String characterEncoding) {
@@ -187,7 +187,7 @@
     }
   }
 
-  private void closeOpenTag() throws IOException {
+  protected void closeOpenTag() throws IOException {
     if (startStillOpen) {
       writer.write("\n>");
       startStillOpen = false;
@@ -226,7 +226,7 @@
     startElementInternal(writer, name, currentComponent);
   }
 
-  protected final void startElementInternal(Writer writer, String name, UIComponent currentComponent)
+  protected void startElementInternal(Writer writer, String name, UIComponent currentComponent)
       throws IOException {
     this.component = currentComponent;
     stack.push(name);
@@ -243,7 +243,7 @@
     endElementInternal(writer, name);
   }
 
-  protected final void endElementInternal(Writer writer, String name) throws IOException {
+  protected void endElementInternal(Writer writer, String name) throws IOException {
     if (LOG.isDebugEnabled()) {
       LOG.debug("end Element: " + name);
     }
@@ -308,7 +308,7 @@
     writeAttribute(name, attribute, true);
   }
 
-  private String getCallingClassStackTraceElementString() {
+  protected final String getCallingClassStackTraceElementString() {
     final StackTraceElement[] stackTrace = new Exception().getStackTrace();
     int i = 1;
     while (stackTrace[i].getClassName().equals(this.getClass().getName())) {
@@ -329,7 +329,7 @@
     writeAttributeInternal(writer, name, value, escape);
   }
 
-  protected final void writeAttributeInternal(Writer writer, String name, String value, boolean escape)
+  protected void writeAttributeInternal(Writer writer, String name, String value, boolean escape)
       throws IOException {
     if (!startStillOpen) {
       String trace = getCallingClassStackTraceElementString();

Modified: myfaces/tobago/trunk/example/facelets/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/facelets/pom.xml?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/facelets/pom.xml (original)
+++ myfaces/tobago/trunk/example/facelets/pom.xml Mon May 12 12:31:54 2008
@@ -173,6 +173,42 @@
       </dependencies>
     </profile>
     <profile>
+      <id>sunjsf12</id>
+      <activation>
+        <property>
+          <name>jsf</name>
+          <value>ri12</value>
+        </property>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>javax.el</groupId>
+          <artifactId>el-api</artifactId>
+          <version>1.0</version>
+          <scope>provided</scope>
+        </dependency>        
+        <dependency>
+          <groupId>javax.faces</groupId>
+          <artifactId>jsf-api</artifactId>
+          <version>${sunjsf12.version}</version>
+        </dependency>
+        <dependency>
+          <groupId>javax.faces</groupId>
+          <artifactId>jsf-impl</artifactId>
+          <version>${sunjsf12.version}</version>
+        </dependency>
+      </dependencies>
+      <repositories>
+        <repository>
+          <id>java.net</id>
+          <name>java.net Maven 1 Repository</name>
+          <url>https://maven-repository.dev.java.net/nonav/repository</url>
+          <layout>legacy</layout>
+        </repository>
+      </repositories>
+    </profile>
+
+    <profile>
       <!--
        mvn package cargo:start -Ptomcat5x
       -->

Added: myfaces/tobago/trunk/example/facelets/src/main/webapp/layout.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/facelets/src/main/webapp/layout.xml?rev=655613&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/facelets/src/main/webapp/layout.xml (added)
+++ myfaces/tobago/trunk/example/facelets/src/main/webapp/layout.xml Mon May 12 12:31:54 2008
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<f:view xmlns:jsp="http://java.sun.com/JSP/Page"
+	xmlns:ui="http://java.sun.com/jsf/facelets"
+	xmlns:f="http://java.sun.com/jsf/core"
+	xmlns:tc="http://myfaces.apache.org/tobago/component"
+	xmlns:tx="http://myfaces.apache.org/tobago/extension"
+	xmlns:c="http://java.sun.com/jstl/core" version="2.0">
+
+	<tc:page>
+			<tc:panel>
+				<f:facet name="layout">
+					<tc:gridLayout rows="*;" columns="*" />
+				</f:facet>
+
+				<tc:tabGroup immediate="true">
+
+					<tc:tab label="Demo">
+						<f:facet name="layout">
+							<tc:gridLayout
+								rows="fixed;fixed;fixed;fixed;fixed;fixed;fixed;fixed;80px;*"
+								columns="*;*;*;*" border="1" />
+						</f:facet>
+
+						<tc:out value="Rat:" />
+						<tc:cell spanX="3">
+							<tc:out value="12 - Projekt" />
+						</tc:cell>
+
+						<tc:out value="LIVEST:" />
+						<tc:out value="Ralf Rudi" />
+						<tc:out value="BEVEST:" />
+						<tc:out value="Ralf Rudi" />
+
+						<tc:out value="Brutto:" />
+						<tc:cell spanX="3">
+							<tc:out value="2.000.000 €" />
+						</tc:cell>
+
+						<tc:out value="Inanspr:" />
+						<tc:cell spanX="3">
+							<tc:out value="1.800.000 €" />
+						</tc:cell>
+
+						<tc:out value="Mehl:" />
+						<tc:out value="2.000.000 €" />
+						<tc:out value="Matrix:" />
+						<tc:out value="31.12.2009" />
+
+						<tc:out value="Sicher:" />
+						<tc:out value="1.500.000 €" />
+						<tc:out value="Laufzeit:" />
+						<tc:out value="31.12.2009" />
+
+						<tc:out value="KUST:" />
+						<tc:cell spanX="3">
+							<tc:out value="1234" />
+						</tc:cell>
+
+						<tc:cell spanX="4">
+							<tc:out value="Kommentar" markup="header" />
+						</tc:cell>
+
+						<tc:cell spanX="4">
+							<tc:textarea value="" />
+						</tc:cell>
+
+						<tc:cell spanX="4" />
+
+					</tc:tab>
+					<tc:tab label="Tab 1">
+						<tc:out value="Hallo 1" />
+					</tc:tab>
+
+					<tc:tab label="Tab 2">
+						<tc:out value="Hallo 2" />
+					</tc:tab>
+
+				</tc:tabGroup>
+			</tc:panel>
+	</tc:page>
+</f:view>
\ No newline at end of file

Propchange: myfaces/tobago/trunk/example/facelets/src/main/webapp/layout.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tobago/trunk/example/facelets/src/main/webapp/layout.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: myfaces/tobago/trunk/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/pom.xml?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/pom.xml (original)
+++ myfaces/tobago/trunk/pom.xml Mon May 12 12:31:54 2008
@@ -1092,7 +1092,7 @@
 
   <properties>
     <myfaces.version>1.1.5</myfaces.version>
-    <myfaces12.version>1.2.2</myfaces12.version>
+    <myfaces12.version>1.2.3</myfaces12.version>
     <sunjsf.version>1.1_02</sunjsf.version>
     <sunjsf12.version>1.2_07</sunjsf12.version>
     <facelets.version>1.1.14</facelets.version>

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?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- 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 Mon May 12 12:31:54 2008
@@ -29,8 +29,6 @@
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_READONLY;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_REQUIRED;
 import org.apache.myfaces.tobago.ajax.api.AjaxRenderer;
-import static org.apache.myfaces.tobago.ajax.api.AjaxResponse.CODE_ERROR;
-import static org.apache.myfaces.tobago.ajax.api.AjaxResponse.CODE_SUCCESS;
 import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
 import org.apache.myfaces.tobago.util.ComponentUtil;
 import org.apache.myfaces.tobago.component.AbstractUIPage;
@@ -188,10 +186,10 @@
     }
   }
 
-  public int encodeAjax(FacesContext context, UIComponent component) throws IOException {
+  public void encodeAjax(FacesContext context, UIComponent component) throws IOException {
     if (!(component instanceof UIInputBase)) {
       LOG.error("Wrong type: Need " + UIInputBase.class.getName() + ", but was " + component.getClass().getName());
-      return CODE_ERROR;
+      return;
     }
 
     AjaxUtils.checkParamValidity(context, component, UIInput.class);
@@ -207,7 +205,7 @@
       mb = (MethodBinding) o;
     } else {
       // should never occur
-      return CODE_ERROR;
+      return;
     }
 
     TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(context);
@@ -217,9 +215,8 @@
 
     List suggesteds
         = (List) mb.invoke(context, new Object[]{(String) input.getSubmittedValue()});
-
-    StringBuilder sb = new StringBuilder(64);
-    sb.append("return  {items: [");
+    writer.startJavascript();
+    writer.write("return  {items: [");
 
     int suggestedCount = 0;
     for (Iterator i = suggesteds.iterator(); i.hasNext(); suggestedCount++) {
@@ -227,14 +224,13 @@
         break;
       }
       if (suggestedCount > 0) {
-        sb.append(", ");
+        writer.write(", ");
       }
-      sb.append("{label: \"");
-      sb.append(AjaxUtils.encodeJavascriptString(i.next().toString()));
-      sb.append("\"}");
-    }
-    sb.append("]};");
-    writer.writeJavascript(sb.toString());
-    return CODE_SUCCESS;
+      writer.write("{label: \"");
+      writer.write(AjaxUtils.encodeJavascriptString(i.next().toString()));
+      writer.write("\"}");
+    }
+    writer.write("]};");
+    writer.endJavascript();
   }
 }

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?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- 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 Mon May 12 12:31:54 2008
@@ -151,12 +151,11 @@
 
     writer.startElement(HtmlConstants.HTML, null);
     writer.startElement(HtmlConstants.HEAD, null);
-    final boolean debugMode =
-            ClientProperties.getInstance(facesContext.getViewRoot()).isDebugMode();
+    final boolean debugMode = ClientProperties.getInstance(facesContext.getViewRoot()).isDebugMode();
 
-    //if (debugMode) {
-    writer.writeJavascript("var TbgHeadStart = new Date();");
-    //}
+    if (debugMode) {
+      writer.writeJavascript("var TbgHeadStart = new Date();");
+    }
 
     // meta
     // this is needed, because websphere 6.0? ignores the setting of the content type on the response
@@ -220,12 +219,20 @@
 
     // script files
     List<String> scriptFiles = facesContext.getScriptFiles();
-    // prototype.js and tobago.js needs to be first!
-    addScripts(writer, facesContext, "script/dojo/dojo/dojo.js");
+    // dojo.js and tobago.js needs to be first!
+    if (debugMode) {
+      addScripts(writer, facesContext, "script/dojo/dojo/dojo.js.uncompressed.js");
+    } else {
+      addScripts(writer, facesContext, "script/dojo/dojo/dojo.js");
+    }
     addScripts(writer, facesContext, "script/tobago.js");
     addScripts(writer, facesContext, "script/theme-config.js");
-    // remove  prototype.js and tobago.js from list to prevent dublicated rendering of script tags
-    scriptFiles.remove("script/dojo/dojo/dojo.js");
+    // remove  dojo.js and tobago.js from list to prevent dublicated rendering of script tags
+    if (debugMode) {
+      scriptFiles.remove("script/dojo/dojo/dojo.js.uncompressed.js");
+    } else {
+      scriptFiles.remove("script/dojo/dojo/dojo.js");
+    }
     scriptFiles.remove("script/tobago.js");
     scriptFiles.remove("script/theme-config.js");
 
@@ -256,7 +263,11 @@
     // focus id
     String focusId = page.getFocusId();
     if (focusId != null) {
-      writer.writeJavascript("Tobago.focusId = '" + focusId + "';");
+      writer.startJavascript();
+      writer.write("Tobago.focusId = '");
+      writer.write(focusId);
+      writer.write("';");
+      writer.endJavascript();
     }
 
     if (component.getFacets().containsKey(FACET_ACTION)) {
@@ -334,10 +345,8 @@
       };
       final String[] jsCommand = new String[]{"new LOG.LogArea({hide: " + hideClientLogging + "});"};
       HtmlRendererUtil.writeScriptLoader(facesContext, jsFiles, jsCommand);
+       writer.writeJavascript("TbgTimer.startBody = new Date();");
     }
-    //if (debugMode)  {
-    writer.writeJavascript("TbgTimer.startBody = new Date();");
-    //}
 
     writer.startElement(HtmlConstants.FORM, page);
     writer.writeNameAttribute(
@@ -448,9 +457,9 @@
           logMessages.toArray(new String[logMessages.size()]));
     }
 
-    //if (debugMode) {
-    writer.writeJavascript("TbgTimer.endBody = new Date();");
-    //}
+    if (debugMode) {
+      writer.writeJavascript("TbgTimer.endBody = new Date();");
+    }
     writer.endElement(HtmlConstants.BODY);
     writer.endElement(HtmlConstants.HTML);
 

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?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- 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 Mon May 12 12:31:54 2008
@@ -28,8 +28,6 @@
 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.AjaxRenderer;
-import static org.apache.myfaces.tobago.ajax.api.AjaxResponse.CODE_NOT_MODIFIED;
-import static org.apache.myfaces.tobago.ajax.api.AjaxResponse.CODE_SUCCESS;
 import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
 import org.apache.myfaces.tobago.util.ComponentUtil;
 import org.apache.myfaces.tobago.component.UIPanel;
@@ -120,9 +118,7 @@
     return height;
   }
 
-  public void encodeChildren(FacesContext facesContext,
-      UIComponent uiComponent) throws IOException {
-
+  public void encodeChildren(FacesContext facesContext, UIComponent uiComponent) throws IOException {
     UIPanel component = (UIPanel) uiComponent;
     for (Object o : component.getChildren()) {
       UIComponent child = (UIComponent) o;
@@ -157,29 +153,14 @@
     }
   }
 
-  public void encodeEnd(FacesContext facesContext,
-      UIComponent uiComponent) throws IOException {
+  public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
     ResponseWriter writer = facesContext.getResponseWriter();
     writer.endElement(HtmlConstants.DIV);
   }
 
-  public int encodeAjax(FacesContext facesContext, UIComponent component)
-      throws IOException {
+  public void encodeAjax(FacesContext facesContext, UIComponent component) throws IOException {
     AjaxUtils.checkParamValidity(facesContext, component, UIPanel.class);
-    boolean update = true;
-    if (component.getFacet(FACET_RELOAD) != null
-        && component.getFacet(FACET_RELOAD) instanceof UIReload
-        && component.getFacet(FACET_RELOAD).isRendered()) {
-      UIReload reload = (UIReload) component.getFacet(FACET_RELOAD);
-      update = reload.isUpdate();
-    }
-    if (update) {
-      component.encodeChildren(facesContext);
-      return CODE_SUCCESS;
-    } else {
-      return CODE_NOT_MODIFIED;
-    }
+    component.encodeChildren(facesContext);
   }
-
 }
 

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?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- 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 Mon May 12 12:31:54 2008
@@ -26,7 +26,6 @@
 import org.apache.commons.logging.LogFactory;
 import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
 import org.apache.myfaces.tobago.ajax.api.AjaxRenderer;
-import static org.apache.myfaces.tobago.ajax.api.AjaxResponse.CODE_SUCCESS;
 import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
 import org.apache.myfaces.tobago.util.ComponentUtil;
 import org.apache.myfaces.tobago.component.UIPage;
@@ -155,17 +154,22 @@
 
     writer.endElement(HtmlConstants.DIV);
 
-    String setupScript = "Tobago.setupPopup('" + clientId + "', '"
-        + component.getLeft() + "', '" + component.getTop() + "', " + component.isModal() + ");";
-    writer.writeJavascript(setupScript);
+    writer.startJavascript();
+    writer.write("Tobago.setupPopup('");
+    writer.write(clientId);
+    writer.write("', '");
+    writer.write(String.valueOf(component.getLeft()));
+    writer.write("', '");
+    writer.write(String.valueOf(component.getTop()));
+    writer.write("', ");
+    writer.write(String.valueOf(component.isModal()));
+    writer.write(");");
+    writer.endJavascript();
   }
 
-  public int encodeAjax(FacesContext facesContext, UIComponent component) throws IOException {
+  public void encodeAjax(FacesContext facesContext, UIComponent component) throws IOException {
     AjaxUtils.checkParamValidity(facesContext, component, UIPopup.class);
-
     RenderUtil.encode(facesContext, component);
-
-    return CODE_SUCCESS;
   }
 }
 

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Mon May 12 12:31:54 2008
@@ -60,8 +60,6 @@
 import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_OUT;
 import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
 import org.apache.myfaces.tobago.ajax.api.AjaxRenderer;
-import static org.apache.myfaces.tobago.ajax.api.AjaxResponse.CODE_NOT_MODIFIED;
-import static org.apache.myfaces.tobago.ajax.api.AjaxResponse.CODE_SUCCESS;
 import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
 import org.apache.myfaces.tobago.util.ComponentUtil;
 import org.apache.myfaces.tobago.component.UIColumnEvent;
@@ -1112,40 +1110,28 @@
     return getConfiguredValue(facesContext, data, "contentBorder");
   }
 
-  public int encodeAjax(FacesContext facesContext, UIComponent component)
+  public void encodeAjax(FacesContext facesContext, UIComponent component)
       throws IOException {
     AjaxUtils.checkParamValidity(facesContext, component, UIData.class);
-    boolean update = true;
-    if (component.getFacet(FACET_RELOAD) != null
-        && component.getFacet(FACET_RELOAD) instanceof UIReload
-        && component.getFacet(FACET_RELOAD).isRendered()) {
-      UIReload reload = (UIReload) component.getFacet(FACET_RELOAD);
-        update = reload.isUpdate();
-      }
-    if (update) {
-      // TODO find a better way
-      UICommand clickAction = null;
-      UICommand dblClickAction = null;
-      for (UIComponent child : (List<UIComponent>) component.getChildren()) {
-        if (child instanceof UIColumnEvent) {
-          UIColumnEvent columnEvent = (UIColumnEvent) child;
-          UIComponent selectionChild = (UIComponent) child.getChildren().get(0);
-          if (selectionChild != null && selectionChild instanceof UICommand && selectionChild.isRendered()) {
-            UICommand action = (UICommand) selectionChild;
-            if ("click".equals(columnEvent.getEvent())) {
-              clickAction = action;
-            }
-            if ("dblclick".equals(columnEvent.getEvent())) {
-              dblClickAction = action;
-            }
+    // TODO find a better way
+    UICommand clickAction = null;
+    UICommand dblClickAction = null;
+    for (UIComponent child : (List<UIComponent>) component.getChildren()) {
+      if (child instanceof UIColumnEvent) {
+        UIColumnEvent columnEvent = (UIColumnEvent) child;
+        UIComponent selectionChild = (UIComponent) child.getChildren().get(0);
+        if (selectionChild != null && selectionChild instanceof UICommand && selectionChild.isRendered()) {
+          UICommand action = (UICommand) selectionChild;
+          if ("click".equals(columnEvent.getEvent())) {
+            clickAction = action;
+          }
+          if ("dblclick".equals(columnEvent.getEvent())) {
+            dblClickAction = action;
           }
         }
       }
-      renderSheet(facesContext, (UIData) component, (clickAction != null || dblClickAction != null));
-      return CODE_SUCCESS;
-    } else {
-      return CODE_NOT_MODIFIED;
     }
+    renderSheet(facesContext, (UIData) component, (clickAction != null || dblClickAction != null));
   }
 
   @Override
@@ -1167,7 +1153,9 @@
 
     int rows = data.getRows();
 
-    LOG.info(headerHeight + " " + footerHeight + " " + rowHeight + " " + rows);
+    if (LOG.isInfoEnabled()) {
+      LOG.info(headerHeight + " " + footerHeight + " " + rowHeight + " " + rows);
+    }
 
     return headerHeight + rows * rowHeight + footerHeight + 2; // XXX hotfix: + 1
   }

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js Mon May 12 12:31:54 2008
@@ -22,7 +22,7 @@
   initMenuComponents(divId, pageId, false);
 }
 function initMenuComponents(divId, pageId, popup) {
-  var menubar = document.getElementById(divId);
+  var menubar = dojo.byId(divId);
   if (menubar && menubar.menu) {
     if (! menubar.id) {
       menubar.id = Tobago.createHtmlId();
@@ -35,7 +35,7 @@
       menubar.menu.popup = popup;
       //LOG.debug("popupType = " + popup);
     }
-    var body = document.getElementById(pageId);
+    var body = dojo.byId(pageId);
     var className = "tobago-menuBar-container";
     if (popup) {
       className += " tobago-menuBar-container-" + popup;
@@ -76,7 +76,7 @@
 
 function createSubmenus(menu, body) {
   var id = menu.id + Tobago.SUB_COMPONENT_SEP + "submenuroot";
-  var htmlElement = Tobago.element(id);
+  var htmlElement = dojo.byId(id);
   if (!htmlElement) {
     htmlElement = document.createElement('div');
     htmlElement.className = "tobago-menuBar-submenuroot";
@@ -480,7 +480,7 @@
       i += offset;
     }
 
-    var j = Tobago.element(this.subItems[i].id).childNodes.length;
+    var j = dojo.byId(this.subItems[i].id).childNodes.length;
     var span = this.subItems[i].getLabelTag();
     if (span) {
       this.subItems[i].hover = true;
@@ -523,7 +523,7 @@
   };
   
 Tobago.Menu.Item.prototype.getLabelTag = function() {
-    var children = Tobago.element(this.id).childNodes;
+    var children = dojo.byId(this.id).childNodes;
     for (var k = 0; k < children.length; k++) {
       if (children[k].className.match(/tobago-menuBar-item-span/)) {
         return children[k];
@@ -546,7 +546,7 @@
   
 Tobago.Menu.Item.prototype.addSubitemArrowImage = function() {
     if (this.level > 1 && this.subItems && this.subItems.length > 0) {
-      var htmlElement = Tobago.element(this.id);
+      var htmlElement = dojo.byId(this.id);
       var html = htmlElement.innerHTML;
       html += '<img class="tobago-menu-subitem-arrow" src="';
       html += this.getSubitemArrowImage() + '" />';
@@ -555,7 +555,7 @@
   };
   
 Tobago.Menu.Item.prototype.setupIframe = function(subItemContainer) {
-    var subItemIframe = Tobago.element(this.subItemIframeId);
+    var subItemIframe = dojo.byId(this.subItemIframeId);
     if (subItemIframe) {
       subItemIframe.style.width = subItemContainer.scrollWidth;
       subItemIframe.style.height = subItemContainer.scrollHeight;
@@ -572,7 +572,7 @@
 
 function adjustPopupImage(menu) {
   if (menu.subItems && menu.subItems.length > 0) {
-    var img = Tobago.element(menu.subItems[0].id).childNodes[0];
+    var img = dojo.byId(menu.subItems[0].id).childNodes[0];
     if (img) {
       img.style.top = getPopupImageTop(menu.popup);
     }
@@ -585,7 +585,7 @@
 function setItemWidth(menu) {
 
   if (menu.level != 0) {
-    var htmlElement = Tobago.element(menu.id);
+    var htmlElement = dojo.byId(menu.id);
     if (htmlElement) {
 
       if (menu.level == 1) {
@@ -600,11 +600,11 @@
           var re = new RegExp("(.*" + Tobago.SUB_COMPONENT_SEP +")\\d$");
           var childIdPrefix = menu.id.match(re)[1];
           var i = 0;
-          var childElement = document.getElementById(childIdPrefix + i++);
+          var childElement = dojo.byId(childIdPrefix + i++);
           while (childElement) {
             //LOG.debug("item " + childElement.id + "  -->" + childElement.scrollWidth) ;//+ ":::" + childElement.innerHTML);
             width = Math.max(width, childElement.scrollWidth);
-            childElement = document.getElementById(childIdPrefix + i++);
+            childElement = dojo.byId(childIdPrefix + i++);
           }
           //LOG.debug("das waren " + (i-1) + " items  ---> width wird " + width);
           width += getMenuArrowWidth();
@@ -623,7 +623,7 @@
   for (var i = 0; i < menu.subItems.length; i++) {
     setItemWidth(menu.subItems[i]);
   }
-  var subItemContainer = Tobago.element(menu.subItemContainerId);
+  var subItemContainer = dojo.byId(menu.subItemContainerId);
   if (subItemContainer && menu.level != 0) {
     menu.subItemContainerStyleWidth
         = (menu.childWidth + getSubitemContainerBorderWidthSum()) + "px";
@@ -637,7 +637,7 @@
     subItemContainer.style.width = "0px";
     subItemContainer.style.height = "0px";
 
-    var subItemIframe = Tobago.element(menu.subItemIframeId);
+    var subItemIframe = dojo.byId(menu.subItemIframeId);
     if (subItemIframe) {
       subItemIframe.style.width = subItemContainer.style.width;
       subItemIframe.style.height = subItemContainer.style.height;
@@ -648,7 +648,7 @@
 function setItemPositions(menu) {
 
   if (menu.level != 0) {
-    var htmlElement = Tobago.element(menu.id);
+    var htmlElement = dojo.byId(menu.id);
     if (htmlElement) {
 
       if (menu.level == 1) {
@@ -659,15 +659,15 @@
         }
         htmlElement.style.top = top +"px";
         htmlElement.style.height = itemHeight + "px";
-        var subItemContainer = Tobago.element(menu.subItemContainerId);
+        var subItemContainer = dojo.byId(menu.subItemContainerId);
         if (subItemContainer) {
           subItemContainer.style.top = (itemHeight + top) + "px";
         }
         var left = 0;
         if (menu.index != 0) {
           var neighbour = menu.parent.subItems[menu.index -1];
-          var left = Tobago.element(neighbour.id).style.left.replace(/\D/g,"") - 0;
-          left += Tobago.element(neighbour.id).style.width.replace(/\D/g,"") - 0;
+          var left = dojo.byId(neighbour.id).style.left.replace(/\D/g,"") - 0;
+          left += dojo.byId(neighbour.id).style.width.replace(/\D/g,"") - 0;
         }
         htmlElement.style.left = left + "px";
         if (subItemContainer) {
@@ -685,10 +685,10 @@
         var left = 0;
         if (menu.level == 2 && menu.parent.parent.popup) {
           if (menu.parent.parent.popup == "ToolbarButton") {
-            var menubar = Tobago.element(menu.parent.parent.menubarId);
+            var menubar = dojo.byId(menu.parent.parent.menubarId);
             left = getPopupMenuWidth() - menubar.scrollWidth;
           }
-          var subItemContainer = Tobago.element(menu.parent.subItemContainerId);
+          var subItemContainer = dojo.byId(menu.parent.subItemContainerId);
           if (subItemContainer) {
             subItemContainer.style.left = left + "px";
 
@@ -698,7 +698,7 @@
             }
           }
         }
-        var subItemContainer = Tobago.element(menu.subItemContainerId);
+        var subItemContainer = dojo.byId(menu.subItemContainerId);
         if (subItemContainer) {
           //if (menu.level == 2) {
           //  top = getItemHeight();
@@ -726,28 +726,28 @@
 
 function setItemsVisible(menu) {
   for (var i = 0; i < menu.subItems.length; i++) {
-    Tobago.element(menu.subItems[i].id).style.visibility = 'visible';
+    dojo.byId(menu.subItems[i].id).style.visibility = 'visible';
   }
 }
 
 function initMenuItems(menu) {
-  var htmlElement = Tobago.element(menu.id);
+  var htmlElement = dojo.byId(menu.id);
   if (htmlElement) {
 
     htmlElement.menuItem = menu;
     if (menu.parent && menu.parent.menubarId
-        && Tobago.element(menu.parent.menubarId).className.match(/tobago-menuBar-page-facet/)) {
+        && dojo.byId(menu.parent.menubarId).className.match(/tobago-menuBar-page-facet/)) {
       Tobago.addCssClass(htmlElement, 'tobago-menuBar-item-page-facet');
     }
     var id = menu.id + Tobago.SUB_COMPONENT_SEP + 'items';
-    if (Tobago.element(id)) {
+    if (dojo.byId(id)) {
       menu.subItemContainerId = id;
     }
     id = menu.id + Tobago.SUB_COMPONENT_SEP + 'iframe';
-    if (Tobago.element(id)) {
+    if (dojo.byId(id)) {
       menu.subItemIframeId = id;
     }
-    var subItemIframe = Tobago.element(menu.subItemIframeId);
+    var subItemIframe = dojo.byId(menu.subItemIframeId);
     if (subItemIframe) {
       subItemIframe.style.visibility = "hidden";
       subItemIframe.style.position = "absolute";
@@ -764,10 +764,10 @@
 
 
 function tobagoMenuSetHover(id) {
-  document.getElementById(id).menuItem.setHover();
+  dojo.byId(id).menuItem.setHover();
 }
 function tobagoMenuRemoveHover(id, mouseOut) {
-  document.getElementById(id).menuItem.removeHover(mouseOut);
+  dojo.byId(id).menuItem.removeHover(mouseOut);
 }
 
 
@@ -798,7 +798,7 @@
       }
     }
 
-    if (Tobago.element(menu.parent.menubarId).className.match(/tobago-menuBar-page-facet/)) {
+    if (dojo.byId(menu.parent.menubarId).className.match(/tobago-menuBar-page-facet/)) {
       return 23;
     }
     else {

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?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- 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 Mon May 12 12:31:54 2008
@@ -86,7 +86,7 @@
     if (style != null) {
       writer.writeStyleAttribute(style);
     }
-    writer.writeJavascript("Tobago.addAjaxComponent(\"" + clientId + "\")");
+    writer.writeJavascript("Tobago.addAjaxComponent(\"" + clientId + "\");");
     
     encodeBeginInner(facesContext, writer, component);
   }
@@ -183,7 +183,7 @@
     writer.endElement(HtmlConstants.DIV);
   }
 
-  public int encodeAjax(FacesContext facesContext, UIComponent component) throws IOException {
+  public void encodeAjax(FacesContext facesContext, UIComponent component) throws IOException {
     AjaxUtils.checkParamValidity(facesContext, component, UIPanel.class);
     TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
 
@@ -191,7 +191,6 @@
     component.encodeChildren(facesContext);
     encodeEndInner(writer);
     facesContext.responseComplete();
-    return CODE_SUCCESS;
   }
 }
 

Modified: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java Mon May 12 12:31:54 2008
@@ -525,41 +525,53 @@
     if (scripts != null) {
       allScripts = ResourceManagerUtil.getScriptsAsJSArray(facesContext, scripts);
     }
-
-    StringBuilder script = new StringBuilder(128);
-    script.append("new Tobago.ScriptLoader(\n    ");
-    script.append(allScripts);
+    boolean ajax = false;
+    if (facesContext instanceof TobagoFacesContext) {
+      ajax = ((TobagoFacesContext) facesContext).isAjax();
+    }
+    writer.startJavascript();
+    writer.write("new Tobago.ScriptLoader(");
+    if (!ajax) {
+      writer.write("\n    ");
+    }
+    writer.write(allScripts);
 
     if (afterLoadCmds != null && afterLoadCmds.length > 0) {
-      script.append(", \n");
+      writer.write(", ");
+      if (!ajax) {
+        writer.write("\n");
+      }
       boolean first = true;
       for (String afterLoadCmd : afterLoadCmds) {
         String[] splittedStrings = StringUtils.split(afterLoadCmd, '\n'); // split on <CR> to have nicer JS
         for (String splitted : splittedStrings) {
+          writer.write(first ? "          " : "        + ");
+          writer.write("\"");
           String cmd = StringUtils.replace(splitted, "\\", "\\\\");
           cmd = StringUtils.replace(cmd, "\"", "\\\"");
-          script.append(first ? "          " : "        + ");
-          script.append("\"");
-          script.append(cmd);
-          script.append("\"\n");
+          writer.write(cmd);
+          writer.write("\"");
+          if (!ajax) {
+            writer.write("\n");
+          }
           first = false;
         }
       }
     }
-    script.append(");");
+    writer.write(");");
 
-    writer.writeJavascript(script.toString());
+    writer.endJavascript();
   }
 
   public static void writeStyleLoader(
       FacesContext facesContext, String[] styles) throws IOException {
     TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
 
-    StringBuilder builder = new StringBuilder(64);
-    builder.append("Tobago.ensureStyleFiles(\n    ");
-    builder.append(ResourceManagerUtil.getStylesAsJSArray(facesContext, styles));
-    builder.append(");");
-    writer.writeJavascript(builder.toString());
+    writer.startJavascript();
+    writer.write("Tobago.ensureStyleFiles(");
+    writer.write(ResourceManagerUtil.getStylesAsJSArray(facesContext, styles));
+    writer.write(");");
+    writer.endJavascript();
   }
 
   public static String getTitleFromTipAndMessages(FacesContext facesContext, UIComponent component) {

Modified: myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=655613&r1=655612&r2=655613&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Mon May 12 12:31:54 2008
@@ -243,7 +243,9 @@
   init: function(pageId) {
 //    new LOG.LogArea({hide: false});
 //    LOG.show();
-    TbgTimer.startOnload = new Date();
+    if (TbgTimer.endBody) {
+      TbgTimer.startOnload = new Date();
+    }
     this.page = this.element(pageId);
     this.form = this.element(this.page.id + this.SUB_COMPONENT_SEP + "form");
     this.addBindEventListener(this.form, "submit", this, "onSubmit");
@@ -254,33 +256,45 @@
 
     this.addBindEventListener(window, "unload", this, "onUnload");
 
-    TbgTimer.startAppOnload = new Date();
+    if (TbgTimer.endBody) {
+      TbgTimer.startAppOnload = new Date();
+    }
     if (this.applicationOnload) {
       this.applicationOnload();
     }
-    TbgTimer.endAppOnload = new Date();
-
+    if (TbgTimer.endBody) {
+      TbgTimer.endAppOnload = new Date();
+    }
     this.loadPngFix();
 
     this.addBindEventListener(document, "keypress", this.acceleratorKeys, "observe");
 
     window.setTimeout(Tobago.finishPageLoading, 1);
-    TbgTimer.endOnload = new Date();
+    if (TbgTimer.endBody) {
+      TbgTimer.endOnload = new Date();
+    }
   },
 
   finishPageLoading: function() {
     Tobago.registerCurrentScripts();
-    TbgTimer.startScriptLoaders = new Date();
+    if (TbgTimer.endBody) {
+      TbgTimer.startScriptLoaders = new Date();
+    }
     Tobago.startScriptLoaders();
-    TbgTimer.endScriptLoaders = new Date();
+    if (TbgTimer.endBody) {
+      TbgTimer.endScriptLoaders = new Date();
+    }
     Tobago.pageIsComplete = true;
     if (Tobago.initialPopupId != null) {
       Tobago.lockPopupPage(Tobago.initialPopupId);
     } else {
       Tobago.setFocus();
     }
-    TbgTimer.endTotal = new Date();
-    TbgTimer.log();
+    if (TbgTimer.endBody) {
+      TbgTimer.endTotal = new Date();
+      TbgTimer.log();
+    }
+
   },
 
   onSubmit: function() {
@@ -2124,7 +2138,11 @@
 
     load: function(data, ioArgs) {
 
-      if (!data.tobagoAjaxResponse) {
+      if (ioArgs.xhr.status == 304) {
+        LOG.debug("status 304");
+        //Tobago.Transport.requestComplete();
+        //return data;        
+      } else if (!data.tobagoAjaxResponse) {
         // unknown response do full page reload
         LOG.warn("initiating full reload");
         if (Tobago.Updater.WAIT_ON_ERROR) {
@@ -2171,26 +2189,46 @@
       var data;
       for (var i = 0; i < requestedIds.length; i++) {
         var id = requestedIds[i];
+        LOG.debug("handleMissingResponse id = " + id) ;
         if (! doneIds[id]) {
           if (!data) {
             data = {responseCode: Tobago.Updater.CODE_NOT_MODIFIED, html: "error", script: function() {}};
           }
           data.ajaxId = id;
-          this.updateComponent(data);
+          this.updateComponent(data, ioArgs);
         }
       }
     },
 
+    handle304Response: function(ids, ioArgs) {
+      for (var i = 0; i < ids.length; i++) {
+        var id = ids[i];
+        LOG.debug("handle304Response id = " + id) ;
+        var data = {
+          ajaxId: id,
+          responseCode: Tobago.Updater.CODE_NOT_MODIFIED,
+          html: "error",
+          script: function() {}
+        };
+        this.updateComponent(data, ioArgs);
+      }
+    },
+
+
     error: function(data, ioArgs) {
       LOG.error("Request failed : " + ioArgs.xhr.status);
-      Tobago.Updater.doErrorUpdate(Tobago.parsePartialIds(ioArgs.args.requestedIds));
+      if (ioArgs.xhr.status == 304) {
+        this.handle304Response(Tobago.parsePartialIds(ioArgs.args.requestedIds))
+      } else {
+        Tobago.Updater.doErrorUpdate(Tobago.parsePartialIds(ioArgs.args.requestedIds));
+      }
       Tobago.Transport.requestComplete();
       return data;
     },
 
-    updateComponent: function(componentData) {
+    updateComponent: function(componentData, ioArgs) {
       var ajaxId = componentData.ajaxId;
-
+      LOG.info("update Component = " + ajaxId) ;
       if (componentData.responseCode == Tobago.Updater.CODE_RELOAD_REQUIRED) {
         LOG.info("nop do reload = ") ;
         // nop
@@ -2204,7 +2242,7 @@
             container.doUpdate = Tobago.Updater.doUpdate;
           }
 
-          container.doUpdate(componentData);
+          container.doUpdate(componentData, ioArgs);
         } else {
           LOG.info("kein container = " + ajaxId) ;
 //          LOG.debugAjaxComponents();