You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2005/12/31 01:13:53 UTC

svn commit: r360202 - in /incubator/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/ tobago-core/src/main/java/org/apache/myfaces/tobago/ajax/api/ tobago-core/src/main/java/org/apache/myfaces/tobago/component/ tobago-core/src/main/jav...

Author: weber
Date: Fri Dec 30 16:13:28 2005
New Revision: 360202

URL: http://svn.apache.org/viewcvs?rev=360202&view=rev
Log:
Working on ajax lifecycle,
Add ability to enable ajax to tobago-config

Modified:
    incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java
    incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxPhaseListener.java
    incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxUtils.java
    incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIInput.java
    incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UITabGroup.java
    incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java
    incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java
    incubator/tobago/trunk/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config_1_0.dtd
    incubator/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/tobago-config.xml
    incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.java
    incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
    incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java
    incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
    incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
    incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java
    incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java

Modified: incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java?rev=360202&r1=360201&r2=360202&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java (original)
+++ incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java Fri Dec 30 16:13:28 2005
@@ -21,9 +21,6 @@
 
 public final class TobagoConstants {
 
-  public static final boolean AJAX_ENABLED = false;
-//  public static final boolean AJAX_ENABLED = true;
-
   public static final String SUBCOMPONENT_SEP = "::";
 
   public static final String ATTR_ACCESS_KEY = "accessKey";

Modified: incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxPhaseListener.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxPhaseListener.java?rev=360202&r1=360201&r2=360202&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxPhaseListener.java (original)
+++ incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxPhaseListener.java Fri Dec 30 16:13:28 2005
@@ -18,21 +18,21 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import javax.faces.event.PhaseListener;
-import javax.faces.event.PhaseEvent;
-import javax.faces.event.PhaseId;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.context.ExternalContext;
+import javax.faces.FactoryFinder;
+import javax.faces.application.StateManager;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIViewRoot;
-import javax.faces.render.RenderKitFactory;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
 import javax.faces.render.RenderKit;
-import javax.faces.FactoryFinder;
-import javax.faces.application.StateManager;
+import javax.faces.render.RenderKitFactory;
 import javax.servlet.http.HttpServletResponse;
-import java.io.PrintWriter;
 import java.io.IOException;
+import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.Map;
 
@@ -86,16 +86,21 @@
 
   public void afterPhase(PhaseEvent event) {
 
-    FacesContext facesContext = event.getFacesContext();
+    if (event.getPhaseId().getOrdinal() != PhaseId.APPLY_REQUEST_VALUES.getOrdinal()) {
+      return;
+    }
 
-    log.info("AJAX");
+    FacesContext facesContext = event.getFacesContext();
 
     final ExternalContext externalContext = facesContext.getExternalContext();
     if(externalContext.getRequestParameterMap().containsKey(AJAX_COMPONENT_ID))
     {
       try {
-        log.info("AJAX: componentID gefunden :"
-            + externalContext.getRequestParameterMap().get(AJAX_COMPONENT_ID));
+        if (log.isDebugEnabled()) {
+          log.debug("AJAX: componentID gefunden :"
+              + externalContext.getRequestParameterMap().get(AJAX_COMPONENT_ID));
+        }
+
 
         final UIViewRoot viewRoot = facesContext.getViewRoot();
         StringWriter content = new StringWriter();
@@ -141,85 +146,99 @@
     }
   }
 
-  public void afterPhaseOld(PhaseEvent event)
-  {
-    FacesContext facesContext = event.getFacesContext();
-
-    final ExternalContext externalContext = facesContext.getExternalContext();
-    final Map requestParameterMap = externalContext.getRequestParameterMap();
-    if(requestParameterMap.containsKey(AJAX_COMPONENT_ID))
-    {
-      UIViewRoot root = facesContext.getViewRoot();
-
-      UIComponent ajaxComponent = root.findComponent(
-          (String)requestParameterMap.get(AJAX_COMPONENT_ID));
+//  public void afterPhaseOld(PhaseEvent event)
+//  {
+//    FacesContext facesContext = event.getFacesContext();
+//
+//    final ExternalContext externalContext = facesContext.getExternalContext();
+//    final Map requestParameterMap = externalContext.getRequestParameterMap();
+//    if(requestParameterMap.containsKey(AJAX_COMPONENT_ID))
+//    {
+//      UIViewRoot root = facesContext.getViewRoot();
+//
+//      UIComponent ajaxComponent = root.findComponent(
+//          (String)requestParameterMap.get(AJAX_COMPONENT_ID));
+//
+//      if(ajaxComponent instanceof AjaxComponent)
+//      {
+//
+//        try
+//        {
+//          StringWriter content = new StringWriter();
+//          RenderKitFactory renderFactory = (RenderKitFactory)
+//              FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+//          RenderKit renderKit = renderFactory.getRenderKit(
+//              facesContext, facesContext.getViewRoot().getRenderKitId());
+//
+//          ResponseWriter contentWriter
+//              = renderKit.createResponseWriter(content, null , null);
+//
+//          facesContext.setResponseWriter(contentWriter);
+//
+//          ((AjaxComponent) ajaxComponent).encodeAjax(facesContext);
+//
+//          StringBuffer buf = new StringBuffer(content.toString());
+//
+//          buf.insert(0,Integer.toHexString(buf.length())+"\r\n");
+//          buf.append("\r\n"+0+"\r\n\r\n");
+//
+//          //todo: fix this to work in PortletRequest as well
+//          if(externalContext.getResponse() instanceof HttpServletResponse)
+//          {
+//            final HttpServletResponse httpServletResponse
+//                = (HttpServletResponse) externalContext.getResponse();
+//            httpServletResponse.addHeader("Transfer-Encoding", "chunked");
+//            PrintWriter responseWriter = httpServletResponse.getWriter();
+//            // buf.delete(buf.indexOf("<"), buf.indexOf(">")+1);
+//            responseWriter.print(buf.toString());
+//            //System.out.println("PhaseListener: buf = " + buf.toString());
+//            responseWriter.flush();
+//            responseWriter.close();
+//          }
+//        }
+//        catch (IOException e)
+//        {
+//          log.error("Exception while rendering ajax-response",e);
+//        }
+//      }
+//      else
+//      {
+//        log.error("Found component is no ajaxComponent : "
+//            + ajaxComponent.getClass().getName()
+//            + "  ID =" + ajaxComponent.getClientId(facesContext));
+//      }
+//
+//      final StateManager stateManager
+//          = facesContext.getApplication().getStateManager();
+//      if (!stateManager.isSavingStateInClient(facesContext)){
+//        stateManager.saveSerializedView(facesContext);
+//      }
+//      facesContext.responseComplete();
+//    }
+//  }
 
-      if(ajaxComponent instanceof AjaxComponent)
-      {
+  public void beforePhase(PhaseEvent event) {
 
-        try
-        {
-          StringWriter content = new StringWriter();
-          RenderKitFactory renderFactory = (RenderKitFactory)
-              FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
-          RenderKit renderKit = renderFactory.getRenderKit(
-              facesContext, facesContext.getViewRoot().getRenderKitId());
-
-          ResponseWriter contentWriter
-              = renderKit.createResponseWriter(content, null , null);
-
-          facesContext.setResponseWriter(contentWriter);
-
-          ((AjaxComponent) ajaxComponent).encodeAjax(facesContext);
-
-          StringBuffer buf = new StringBuffer(content.toString());
-
-          buf.insert(0,Integer.toHexString(buf.length())+"\r\n");
-          buf.append("\r\n"+0+"\r\n\r\n");
-
-          //todo: fix this to work in PortletRequest as well
-          if(externalContext.getResponse() instanceof HttpServletResponse)
-          {
-            final HttpServletResponse httpServletResponse
-                = (HttpServletResponse) externalContext.getResponse();
-            httpServletResponse.addHeader("Transfer-Encoding", "chunked");
-            PrintWriter responseWriter = httpServletResponse.getWriter();
-            // buf.delete(buf.indexOf("<"), buf.indexOf(">")+1);
-            responseWriter.print(buf.toString());
-            //System.out.println("PhaseListener: buf = " + buf.toString());
-            responseWriter.flush();
-            responseWriter.close();
-          }
-        }
-        catch (IOException e)
-        {
-          log.error("Exception while rendering ajax-response",e);
-        }
-      }
-      else
-      {
-        log.error("Found component is no ajaxComponent : "
-            + ajaxComponent.getClass().getName()
-            + "  ID =" + ajaxComponent.getClientId(facesContext));
-      }
+    if (event.getPhaseId().getOrdinal() != PhaseId.RENDER_RESPONSE.getOrdinal()) {
+      return;
+    }
 
-      final StateManager stateManager
-          = facesContext.getApplication().getStateManager();
-      if (!stateManager.isSavingStateInClient(facesContext)){
-        stateManager.saveSerializedView(facesContext);
-      }
+    FacesContext facesContext = event.getFacesContext();
+    final ExternalContext externalContext = facesContext.getExternalContext();
+    final Map requestParameterMap = externalContext.getRequestParameterMap();
+    if(requestParameterMap.containsKey(AJAX_COMPONENT_ID)) {
+      // TODO: error handling when ajax request came after session has expired
+      log.error("Ignoring AjaxRequest without valid component tree!");
       facesContext.responseComplete();
     }
   }
 
-  public void beforePhase(PhaseEvent event) {/* nothing to do here */ }
-
   public PhaseId getPhaseId()
   {
-    //return PhaseId.ANY_PHASE;
+    return PhaseId.ANY_PHASE;
     //return PhaseId.RESTORE_VIEW;
 //        return PhaseId.INVOKE_APPLICATION;
-    return PhaseId.APPLY_REQUEST_VALUES;
+//    return PhaseId.APPLY_REQUEST_VALUES;
   }
 
 }

Modified: incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxUtils.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxUtils.java?rev=360202&r1=360201&r2=360202&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxUtils.java (original)
+++ incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxUtils.java Fri Dec 30 16:13:28 2005
@@ -1,5 +1,7 @@
 package org.apache.myfaces.tobago.ajax.api;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.tobago.component.ComponentUtil;
 
 import javax.faces.application.ViewHandler;
@@ -18,36 +20,36 @@
  */
 public class AjaxUtils {
 
+  private static final Log LOG = LogFactory.getLog(AjaxUtils.class);
 
-
-  public static void processAjax(FacesContext facesContext, UIComponent component) throws IOException {
-
-    component.processValidators(facesContext);
-
-    if (! facesContext.getRenderResponse()) {
-      component.processUpdates(facesContext);
-    }
-
-    // invokeApplication here ??
-
-    renderAjax(facesContext, component);
-  }
-
-  private static void renderAjax(FacesContext facesContext, UIComponent component) throws IOException {
-    final Iterator facetsAndChildren = component.getFacetsAndChildren();
-    while (facetsAndChildren.hasNext()) {
-      UIComponent child = (UIComponent) facetsAndChildren.next();
-      if (child instanceof AjaxComponent) {
-        ((AjaxComponent)child).processAjax(facesContext);
-      }
-      else {
-        renderAjax(facesContext, child);
-      }
-      if (facesContext.getResponseComplete()) {
-        return;
-      }
-    }
-  }
+//  public static void processAjax(FacesContext facesContext, UIComponent component) throws IOException {
+//
+//    component.processValidators(facesContext);
+//
+//    if (! facesContext.getRenderResponse()) {
+//      component.processUpdates(facesContext);
+//    }
+//
+//    // invokeApplication here ??
+//
+//    renderAjax(facesContext, component);
+//  }
+//
+//  private static void renderAjax(FacesContext facesContext, UIComponent component) throws IOException {
+//    final Iterator facetsAndChildren = component.getFacetsAndChildren();
+//    while (facetsAndChildren.hasNext()) {
+//      UIComponent child = (UIComponent) facetsAndChildren.next();
+//      if (child instanceof AjaxComponent) {
+//        ((AjaxComponent)child).processAjax(facesContext);
+//      }
+//      else {
+//        renderAjax(facesContext, child);
+//      }
+//      if (facesContext.getResponseComplete()) {
+//        return;
+//      }
+//    }
+//  }
 
   public static void checkParamValidity(FacesContext facesContext, UIComponent uiComponent, Class compClass)
   {
@@ -86,5 +88,48 @@
     final String actionURL = viewHandler.getActionURL(facesContext, viewId);
     return facesContext.getExternalContext().encodeActionURL(
         actionURL+"?affectedAjaxComponent=" + clientId);
+  }
+
+  public static void processAjax(FacesContext facesContext, UIComponent component)
+      throws IOException {
+    if (component instanceof AjaxComponent) {
+      ((AjaxComponent) component).processAjax(facesContext);
+    } else {
+      processAjaxOnChildren(facesContext, component);
+    }
+  }
+
+  public static void processActiveAjaxComponent(FacesContext facesContext,
+                                                UIComponent component)
+      throws IOException {
+
+    if (component instanceof AjaxComponent) {
+
+      component.processValidators(facesContext);
+
+      if (! facesContext.getRenderResponse()) {
+        component.processUpdates(facesContext);
+      }
+
+/*      if (! facesContext.getRenderResponse()) {
+  // TODO: what about invokeApplication ??
+}*/
+
+      ((AjaxComponent)component).encodeAjax(facesContext);
+    } else {
+      LOG.error("Can't process non AjaxComponent : \""
+          + component.getClientId(facesContext) + "\" = "
+          + component.getClass().getName());
+    }
+  }
+
+  public static void processAjaxOnChildren(FacesContext facesContext,
+                                           UIComponent component)
+      throws IOException {
+
+      final Iterator<UIComponent> facetsAndChildren = component.getFacetsAndChildren();
+      while (facetsAndChildren.hasNext() && !facesContext.getResponseComplete()) {
+        AjaxUtils.processAjax(facesContext, facetsAndChildren.next());
+      }
   }
 }

Modified: incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIInput.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIInput.java?rev=360202&r1=360201&r2=360202&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIInput.java (original)
+++ incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIInput.java Fri Dec 30 16:13:28 2005
@@ -22,13 +22,11 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.tobago.ajax.api.AjaxComponent;
-import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
 import org.apache.myfaces.tobago.ajax.api.AjaxPhaseListener;
+import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
 
 import javax.faces.context.FacesContext;
-import javax.faces.component.UIComponent;
 import java.io.IOException;
-import java.util.Iterator;
 
 public class UIInput extends javax.faces.component.UIInput implements AjaxComponent {
 
@@ -57,19 +55,8 @@
         getRequestParameterMap().get(AjaxPhaseListener.AJAX_COMPONENT_ID);
     if (ajaxId.equals(getClientId(facesContext))) {
       encodeAjax(facesContext);
-    } else {final Iterator facetsAndChildren = getFacetsAndChildren();
-      while (facetsAndChildren.hasNext()) {
-        UIComponent child = (UIComponent) facetsAndChildren.next();
-        if (child instanceof AjaxComponent) {
-          ((AjaxComponent)child).processAjax(facesContext);
-        }
-        else {
-          AjaxUtils.processAjax(facesContext, child);
-        }
-        if (facesContext.getResponseComplete()) {
-          return;
-        }
-      }
+    } else {
+      AjaxUtils.processAjaxOnChildren(facesContext, this);
     }
   }
 }

Modified: incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UITabGroup.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UITabGroup.java?rev=360202&r1=360201&r2=360202&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UITabGroup.java (original)
+++ incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UITabGroup.java Fri Dec 30 16:13:28 2005
@@ -23,23 +23,22 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import static org.apache.myfaces.tobago.TobagoConstants.*;
-import org.apache.myfaces.tobago.event.TabChangeListener;
-import org.apache.myfaces.tobago.event.TabChangeSource;
 import org.apache.myfaces.tobago.ajax.api.AjaxComponent;
-import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
 import org.apache.myfaces.tobago.ajax.api.AjaxPhaseListener;
+import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
+import org.apache.myfaces.tobago.event.TabChangeListener;
+import org.apache.myfaces.tobago.event.TabChangeSource;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import javax.faces.el.MethodBinding;
 import javax.faces.el.EvaluationException;
-import javax.faces.event.FacesEvent;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.ValueBinding;
 import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Iterator;
 
 public class UITabGroup extends UIPanel implements TabChangeSource, AjaxComponent {
 
@@ -241,7 +240,7 @@
 
   public void encodeAjax(FacesContext facesContext) throws IOException {
     if (activeIndex < 0 || !(activeIndex < getTabs().length)) {
-      LOG.info("This should never occur! Problem in decoding?");
+      LOG.error("This should never occur! Problem in decoding?");
       ValueBinding stateBinding = getValueBinding(ATTR_STATE);
       Object state
           = stateBinding != null ? stateBinding.getValue(facesContext) : null;
@@ -257,24 +256,13 @@
   }
 
   public void processAjax(FacesContext facesContext) throws IOException {
-    final String ajaxId = (String) facesContext.getExternalContext().
-        getRequestParameterMap().get(AjaxPhaseListener.AJAX_COMPONENT_ID);
+    final String ajaxId = (String) facesContext.getExternalContext()
+        .getRequestParameterMap().get(AjaxPhaseListener.AJAX_COMPONENT_ID);
+
     if (ajaxId.equals(getClientId(facesContext))) {
-      // TODO what about invoking TabChangeListener ?
-      
-      encodeAjax(facesContext);
-    } else {final Iterator facetsAndChildren = getFacetsAndChildren();
-      while (facetsAndChildren.hasNext()) {
-        UIComponent child = (UIComponent) facetsAndChildren.next();
-        if (child instanceof AjaxComponent) {
-          ((AjaxComponent)child).processAjax(facesContext);
-        } else {
-          AjaxUtils.processAjax(facesContext, child);
-        }
-        if (facesContext.getResponseComplete()) {
-          return;
-        }
-      }
+      AjaxUtils.processActiveAjaxComponent(facesContext, this);
+    } else {
+      AjaxUtils.processAjaxOnChildren(facesContext, this);
     }
   }
 

Modified: incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java?rev=360202&r1=360201&r2=360202&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java (original)
+++ incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java Fri Dec 30 16:13:28 2005
@@ -43,6 +43,7 @@
   private Theme defaultTheme;
   private List<String> resourceDirs;
   private List<MappingRule> mappingRules;
+  private boolean ajaxEnabled;
 
 // ----------------------------------------------------------- business methods
 
@@ -145,6 +146,13 @@
     return resourceDirs;
   }
 
+  public boolean isAjaxEnabled() {
+    return ajaxEnabled;
+  }
+
+  public void setAjaxEnabled(String value) {
+    this.ajaxEnabled = Boolean.valueOf(value);
+  }
 // ------------------------------------------------------------ getter + setter
 
   public Theme getDefaultTheme() {

Modified: incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java?rev=360202&r1=360201&r2=360202&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java (original)
+++ incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java Fri Dec 30 16:13:28 2005
@@ -71,6 +71,9 @@
     // resource dirs
     digester.addCallMethod("tobago-config/resource-dir", "addResourceDir", 0);
 
+    // enable ajax
+    digester.addCallMethod("tobago-config/enable-ajax", "setAjaxEnabled", 0);
+
     return digester;
   }
 

Modified: incubator/tobago/trunk/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config_1_0.dtd
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config_1_0.dtd?rev=360202&r1=360201&r2=360202&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config_1_0.dtd (original)
+++ incubator/tobago/trunk/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config_1_0.dtd Fri Dec 30 16:13:28 2005
@@ -18,7 +18,7 @@
 
 <!ENTITY % Boolean "(true|false|yes|no)">
 
-<!ELEMENT tobago-config (theme-config, resource-dir+, mapping-rule*)>
+<!ELEMENT tobago-config (theme-config, resource-dir+, mapping-rule*, ajax-enabled)>
 
 <!ELEMENT theme-config (default-theme, supported-theme*)>
 <!ELEMENT default-theme (#PCDATA)>
@@ -37,3 +37,5 @@
 <!ELEMENT attribute (key, value)>
 <!ELEMENT key (#PCDATA)>
 <!ELEMENT value (#PCDATA)>
+
+<!ELEMENT ajax-enabled (#PCDATA)>

Modified: incubator/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/tobago-config.xml
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/tobago-config.xml?rev=360202&r1=360201&r2=360202&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/tobago-config.xml (original)
+++ incubator/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/tobago-config.xml Fri Dec 30 16:13:28 2005
@@ -30,4 +30,5 @@
   <resource-dir>tobago-resource</resource-dir>
   <resource-dir>tobago</resource-dir>
 
+  <enable-ajax>false</enable-ajax>
 </tobago-config>

Modified: incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.java?rev=360202&r1=360201&r2=360202&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.java (original)
+++ incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.java Fri Dec 30 16:13:28 2005
@@ -25,6 +25,7 @@
 import org.apache.myfaces.tobago.component.*;
 import org.apache.myfaces.tobago.component.UIPanel;
 import org.apache.myfaces.tobago.config.ThemeConfig;
+import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.event.DatePickerController;
 import org.apache.myfaces.tobago.renderkit.RenderUtil;
 import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
@@ -64,7 +65,7 @@
       scriptFiles.add(script);
     }
 
-    if (AJAX_ENABLED) {
+    if (TobagoConfig.getInstance(facesContext).isAjaxEnabled()) {
       HtmlRendererUtil.writeScriptLoader(facesContext, scripts, null);
     }
 

Modified: incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java?rev=360202&r1=360201&r2=360202&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java (original)
+++ incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/InRenderer.java Fri Dec 30 16:13:28 2005
@@ -226,6 +226,7 @@
     buf.append("</ul>");
 
     context.getResponseWriter().write(buf.toString());
+    context.responseComplete();
   }
 
 }

Modified: incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java?rev=360202&r1=360201&r2=360202&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java (original)
+++ incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java Fri Dec 30 16:13:28 2005
@@ -24,35 +24,24 @@
 import static org.apache.myfaces.tobago.TobagoConstants.*;
 import org.apache.myfaces.tobago.component.ComponentUtil;
 import org.apache.myfaces.tobago.component.UIPage;
+import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
-import org.apache.myfaces.tobago.renderkit.CommandRendererBase;
-import org.apache.myfaces.tobago.renderkit.HtmlUtils;
-import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
-import org.apache.myfaces.tobago.renderkit.RenderUtil;
-import org.apache.myfaces.tobago.renderkit.RendererBase;
+import org.apache.myfaces.tobago.renderkit.*;
 import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
-import org.apache.myfaces.tobago.taglib.component.MenuCommandTag;
-import org.apache.myfaces.tobago.taglib.component.MenuSeparatorTag;
-import org.apache.myfaces.tobago.taglib.component.MenuTag;
-import org.apache.myfaces.tobago.taglib.component.SelectBooleanCommandTag;
-import org.apache.myfaces.tobago.taglib.component.SelectOneCommandTag;
+import org.apache.myfaces.tobago.taglib.component.*;
 import org.apache.myfaces.tobago.util.AccessKeyMap;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
-import javax.faces.component.UICommand;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIPanel;
-import javax.faces.component.UISelectOne;
-import javax.faces.component.ValueHolder;
+import javax.faces.component.*;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 import javax.faces.model.SelectItem;
 import java.io.IOException;
 import java.io.StringWriter;
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.StringTokenizer;
-import java.util.ArrayList;
 
 public class MenuBarRenderer extends RendererBase {
 // ------------------------------------------------------------------ constants
@@ -105,7 +94,7 @@
     String function = setupFunction + "('" + clientId + "', '"
         + page.getClientId(facesContext) + "');";
 
-    if (AJAX_ENABLED) {
+    if (TobagoConfig.getInstance(facesContext).isAjaxEnabled()) {
       HtmlRendererUtil.writeStyleLoader(
           facesContext, new String[] {"style/tobago-menu.css"});
       StringTokenizer st = new StringTokenizer(scriptBlock, "\n");

Modified: incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java?rev=360202&r1=360201&r2=360202&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Fri Dec 30 16:13:28 2005
@@ -23,6 +23,8 @@
 import org.apache.commons.logging.LogFactory;
 import static org.apache.myfaces.tobago.TobagoConstants.*;
 import org.apache.myfaces.tobago.component.*;
+import org.apache.myfaces.tobago.component.UIData;
+import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.context.ResourceManager;
 import org.apache.myfaces.tobago.context.ResourceManagerFactory;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
@@ -36,9 +38,8 @@
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
 import javax.faces.application.Application;
-import javax.faces.component.UIColumn;
+import javax.faces.component.*;
 import javax.faces.component.UICommand;
-import javax.faces.component.UIComponent;
 import javax.faces.component.UIPanel;
 import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
@@ -46,12 +47,7 @@
 import javax.faces.el.MethodBinding;
 import java.io.IOException;
 import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
+import java.util.*;
 
 public class SheetRenderer extends RendererBase
   implements SheetRendererWorkaround {
@@ -97,7 +93,7 @@
     String checked = contextPath + resourceManager
         .getImage(viewRoot, "image/sheetChecked.gif");
 
-    if (!AJAX_ENABLED) {
+    if (!TobagoConfig.getInstance(facesContext).isAjaxEnabled()) {
       UIPage uiPage = ComponentUtil.findPage(data);
       uiPage.getScriptFiles().add("script/tobago-sheet.js");
       uiPage.getOnloadScripts().add("initSheet(\"" + sheetId + "\");");

Modified: incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java?rev=360202&r1=360201&r2=360202&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java (original)
+++ incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java Fri Dec 30 16:13:28 2005
@@ -22,10 +22,13 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import static org.apache.myfaces.tobago.TobagoConstants.*;
+import org.apache.myfaces.tobago.ajax.api.AjaxRenderer;
+import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
 import org.apache.myfaces.tobago.component.ComponentUtil;
+import org.apache.myfaces.tobago.component.UIPage;
 import org.apache.myfaces.tobago.component.UIPanel;
 import org.apache.myfaces.tobago.component.UITabGroup;
-import org.apache.myfaces.tobago.component.UIPage;
+import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
 import org.apache.myfaces.tobago.event.TabChangeEvent;
 import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
@@ -35,8 +38,6 @@
 import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
 import org.apache.myfaces.tobago.util.AccessKeyMap;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
-import org.apache.myfaces.tobago.ajax.api.AjaxRenderer;
-import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
 
 import javax.faces.component.UICommand;
 import javax.faces.component.UIComponent;
@@ -112,7 +113,7 @@
 
     UIPage page = ComponentUtil.findPage(component);
     page.getScriptFiles().add("script/tab.js");
-    if (AJAX_ENABLED && ! serverSideTab) {
+    if (TobagoConfig.getInstance(facesContext).isAjaxEnabled() && ! serverSideTab) {
       HtmlRendererUtil.writeScriptLoader(facesContext, "script/tab.js");
 
     }
@@ -149,7 +150,7 @@
             serverSideTab, image1x1);
         writer.endElement("div");
 
-        if (AJAX_ENABLED && serverSideTab) {
+        if (TobagoConfig.getInstance(facesContext).isAjaxEnabled() && serverSideTab) {
           final String formId
               = ComponentUtil.findPage(component).getFormId(facesContext);
           final String[] scripts = new String[]{"script/tabgroup.js"};
@@ -202,7 +203,7 @@
 
       String url;
 
-      if (AJAX_ENABLED && serverSideTab) {
+      if (TobagoConfig.getInstance(facesContext).isAjaxEnabled() && serverSideTab) {
         url = "#";
       }  else if (serverSideTab) {
         url = "javascript:tobago_requestTab('"
@@ -311,6 +312,7 @@
         new StyleAttribute((String) component.getAttributes().get(ATTR_STYLE)),
         ComponentUtil.getBooleanAttribute(component, ATTR_SERVER_SIDE_TABS),
         ResourceManagerUtil.getImageWithPath(context, "image/1x1.gif"));
+    context.responseComplete();
   }
 
   public int getFixedHeight(FacesContext facesContext, UIComponent uiComponent) {

Modified: incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java?rev=360202&r1=360201&r2=360202&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java (original)
+++ incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java Fri Dec 30 16:13:28 2005
@@ -21,12 +21,12 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import static org.apache.myfaces.tobago.TobagoConstants.AJAX_ENABLED;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE;
 import org.apache.myfaces.tobago.component.ComponentUtil;
 import org.apache.myfaces.tobago.component.UIPage;
 import org.apache.myfaces.tobago.component.UITreeListbox;
 import org.apache.myfaces.tobago.component.UITreeNode;
+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.webapp.TobagoResponseWriter;
@@ -105,7 +105,7 @@
     final String[] scripts = {"script/tree.js"};
     ComponentUtil.findPage(tree).getScriptFiles().add(scripts[0]);
 
-    if (! AJAX_ENABLED) {
+    if (! TobagoConfig.getInstance(facesContext).isAjaxEnabled()) {
       HtmlRendererUtil.startJavascript(writer);
       writer.writeText(script, null);
       HtmlRendererUtil.endJavascript(writer);

Modified: incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java?rev=360202&r1=360201&r2=360202&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java (original)
+++ incubator/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java Fri Dec 30 16:13:28 2005
@@ -21,10 +21,12 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import static org.apache.myfaces.tobago.TobagoConstants.*;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MUTABLE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE;
 import org.apache.myfaces.tobago.component.ComponentUtil;
 import org.apache.myfaces.tobago.component.UITree;
 import org.apache.myfaces.tobago.component.UITreeNode;
+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;
@@ -176,7 +178,7 @@
     final String[] scripts = {"script/tree.js"};
     ComponentUtil.findPage(tree).getScriptFiles().add(scripts[0]);
 
-    if (! AJAX_ENABLED) {
+    if (! TobagoConfig.getInstance(facesContext).isAjaxEnabled()) {
       HtmlRendererUtil.startJavascript(writer);
       writer.writeText(script, null);
       HtmlRendererUtil.endJavascript(writer);