myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bom...@apache.org
Subject svn commit: r1178804 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/component/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ajax/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/lifecycle/ t...
Date Tue, 04 Oct 2011 14:12:01 GMT
Author: bommel
Date: Tue Oct  4 14:12:00 2011
New Revision: 1178804

URL: http://svn.apache.org/viewvc?rev=1178804&view=rev
Log:
(TOBAGO-1033) Replace usages of TobagoFacesContext with FacesContext.getAttributes or ExternalContext.getRequestMap (jsf < 2.0)

Added:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/FacesContextUtils.java
Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIViewRoot.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ajax/AjaxInternalUtils.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ajax/AjaxResponseRenderer.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/lifecycle/RestoreViewExecutor.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/lifecycle/TobagoLifecycle.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ApplyRequestValuesCallback.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/Secret.java
    myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java
    myfaces/tobago/trunk/tobago-jsf-compat/pom.xml
    myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/FileRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ScriptRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneRadioRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/StyleRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIViewRoot.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIViewRoot.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIViewRoot.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIViewRoot.java Tue Oct  4 14:12:00 2011
@@ -17,22 +17,22 @@ package org.apache.myfaces.tobago.compon
  * limitations under the License.
  */
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.myfaces.tobago.ajax.AjaxUtils;
 import org.apache.myfaces.tobago.compat.FacesUtils;
 import org.apache.myfaces.tobago.compat.InvokeOnComponent;
 import org.apache.myfaces.tobago.context.ClientProperties;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.internal.ajax.AjaxInternalUtils;
 import org.apache.myfaces.tobago.internal.ajax.AjaxResponseRenderer;
 import org.apache.myfaces.tobago.internal.component.AbstractUIPage;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.util.ApplyRequestValuesCallback;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.util.ProcessValidationsCallback;
 import org.apache.myfaces.tobago.util.TobagoCallback;
 import org.apache.myfaces.tobago.util.UpdateModelValuesCallback;
 import org.apache.myfaces.tobago.util.VariableResolverUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.faces.FacesException;
 import javax.faces.component.ContextCallback;
@@ -209,18 +209,15 @@ public class UIViewRoot extends javax.fa
       AbstractUIPage page = ComponentUtils.findPage(context);
       page.decode(context);
       page.markSubmittedForm(context);
-      if (context instanceof TobagoFacesContext) {
-        ((TobagoFacesContext) context).setAjax(true);
-      }
+      FacesContextUtils.setAjax(context, true);
+
       // decode the action if actionComponent not inside one of the ajaxComponents
       // otherwise it is decoded there
       decodeActionComponent(context, page, ajaxComponents);
 
       // and all ajax components
       for (Map.Entry<String, UIComponent> entry : ajaxComponents.entrySet()) {
-        if (context instanceof TobagoFacesContext) {
-          ((TobagoFacesContext) context).setAjaxComponentId(entry.getKey());
-        }
+        FacesContextUtils.setAjaxComponentId(context, entry.getKey());
         invokeOnComponent(context, entry.getKey(), APPLY_REQUEST_VALUES_CALLBACK);
       }
     } else {
@@ -264,9 +261,7 @@ public class UIViewRoot extends javax.fa
     Map<String, UIComponent> ajaxComponents = AjaxInternalUtils.getAjaxComponents(context);
     if (ajaxComponents != null) {
       for (Map.Entry<String, UIComponent> entry : ajaxComponents.entrySet()) {
-        if (context instanceof TobagoFacesContext) {
-          ((TobagoFacesContext) context).setAjaxComponentId(entry.getKey());
-        }
+        FacesContextUtils.setAjaxComponentId(context, entry.getKey());
         invokeOnComponent(context, entry.getKey(), PROCESS_VALIDATION_CALLBACK);
       }
     } else {

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ajax/AjaxInternalUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ajax/AjaxInternalUtils.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ajax/AjaxInternalUtils.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ajax/AjaxInternalUtils.java Tue Oct  4 14:12:00 2011
@@ -20,7 +20,7 @@ package org.apache.myfaces.tobago.intern
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.myfaces.tobago.ajax.AjaxUtils;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
+import org.apache.myfaces.tobago.compat.FacesUtils;
 import org.apache.myfaces.tobago.internal.component.AbstractUIMessages;
 import org.apache.myfaces.tobago.renderkit.RendererBase;
 import org.apache.myfaces.tobago.util.ComponentUtils;
@@ -83,8 +83,8 @@ public class AjaxInternalUtils {
     ajaxComponents.put(page.getClientId(facesContext), page);
   }
 
-  public static void storeMessagesClientIds(TobagoFacesContext facesContext, AbstractUIMessages messages) {
-    Map<Object, Object> attributes = facesContext.getAttributes();
+  public static void storeMessagesClientIds(FacesContext facesContext, AbstractUIMessages messages) {
+    Map attributes = FacesUtils.getFacesContextAttributes(facesContext);
     List<String> messageClientIds;
     if (attributes.containsKey(TOBAGO_MESSAGES_CLIENT_IDS)) {
       messageClientIds = (List<String>) attributes.get(TOBAGO_MESSAGES_CLIENT_IDS);
@@ -95,8 +95,8 @@ public class AjaxInternalUtils {
     messageClientIds.add(messages.getClientId(facesContext));
   }
 
-  public static List<String> getMessagesClientIds(TobagoFacesContext facesContext) {
-     return (List<String>) facesContext.getAttributes().get(TOBAGO_MESSAGES_CLIENT_IDS);
+  public static List<String> getMessagesClientIds(FacesContext facesContext) {
+     return (List<String>) FacesUtils.getFacesContextAttributes(facesContext).get(TOBAGO_MESSAGES_CLIENT_IDS);
   }
 
   public static List<String> getMessagesComponentIds(FacesContext facesContext) {

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ajax/AjaxResponseRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ajax/AjaxResponseRenderer.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ajax/AjaxResponseRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ajax/AjaxResponseRenderer.java Tue Oct  4 14:12:00 2011
@@ -19,8 +19,8 @@ package org.apache.myfaces.tobago.intern
 
 import org.apache.myfaces.tobago.compat.FacesUtils;
 import org.apache.myfaces.tobago.component.Attributes;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.internal.lifecycle.TobagoLifecycle;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.internal.util.ResponseUtils;
 import org.apache.myfaces.tobago.internal.webapp.JsonResponseWriter;
 import org.apache.myfaces.tobago.util.ComponentUtils;
@@ -178,9 +178,7 @@ public class AjaxResponseRenderer {
         writer.write("\": ");
 
         UIComponent component = entry.getValue();
-        if (facesContext instanceof TobagoFacesContext) {
-          ((TobagoFacesContext) facesContext).setAjaxComponentId(entry.getKey());
-        }
+        FacesContextUtils.setAjaxComponentId(facesContext, entry.getKey());
         renderComponent(facesContext, renderKit, entry.getKey(), component);
       }
     }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/lifecycle/RestoreViewExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/lifecycle/RestoreViewExecutor.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/lifecycle/RestoreViewExecutor.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/lifecycle/RestoreViewExecutor.java Tue Oct  4 14:12:00 2011
@@ -134,8 +134,7 @@ class RestoreViewExecutor implements Pha
 
   private boolean isPostBack(FacesContext facesContext) {
     Map requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
-    return requestParameterMap.containsKey(TobagoResponseStateManager.TREE_PARAM)
-        || requestParameterMap.containsKey("javax.faces.ViewState");
+    return requestParameterMap.containsKey(TobagoResponseStateManager.VIEW_STATE_PARAM);
   }
 
   private boolean isSessionSecretValid(FacesContext facesContext) {

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/lifecycle/TobagoLifecycle.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/lifecycle/TobagoLifecycle.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/lifecycle/TobagoLifecycle.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/lifecycle/TobagoLifecycle.java Tue Oct  4 14:12:00 2011
@@ -17,11 +17,10 @@ package org.apache.myfaces.tobago.intern
  * limitations under the License.
  */
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.util.DebugUtils;
 import org.apache.myfaces.tobago.util.RequestUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.faces.FacesException;
 import javax.faces.context.FacesContext;
@@ -64,9 +63,8 @@ public class TobagoLifecycle extends Lif
     renderExecutor = new RenderResponseExecutor();
   }
 
-  public void execute(FacesContext facesContext) throws FacesException {
+  public void execute(FacesContext context) throws FacesException {
 
-    TobagoFacesContext context = new TobagoFacesContext(facesContext);
     PhaseListenerManager phaseListenerMgr = new PhaseListenerManager(this, context, getPhaseListeners());
 
     // At very first ensure the requestEncoding, this MUST done before
@@ -121,9 +119,6 @@ public class TobagoLifecycle extends Lif
   }
 
   public void render(FacesContext facesContext) throws FacesException {
-    if (!(facesContext instanceof TobagoFacesContext)) {
-      facesContext = new TobagoFacesContext(facesContext);
-    }
     // if the response is complete we should not be invoking the phase listeners
     if (isResponseComplete(facesContext, renderExecutor.getPhase(), true)) {
       return;

Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/FacesContextUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/FacesContextUtils.java?rev=1178804&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/FacesContextUtils.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/FacesContextUtils.java Tue Oct  4 14:12:00 2011
@@ -0,0 +1,235 @@
+package org.apache.myfaces.tobago.internal.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.commons.collections.list.SetUniqueList;
+import org.apache.commons.collections.set.ListOrderedSet;
+import org.apache.myfaces.tobago.compat.FacesUtils;
+import org.apache.myfaces.tobago.internal.component.AbstractUIPopup;
+
+import javax.faces.context.FacesContext;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+public final class FacesContextUtils {
+  private static String TOBAGO_AJAX = "org.apache.myfaces.tobago.ajax";
+  private static String TOBAGO_AJAX_COMPONENT_ID = "org.apache.myfaces.tobago.ajaxComponentId";
+  private static String TOBAGO_ENCTYPE = "org.apache.myfaces.tobago.enctype";
+  private static String TOBAGO_SCRIPT_FILES = "org.apache.myfaces.tobago.scriptFiles";
+  private static String TOBAGO_SCRIPT_BLOCKS = "org.apache.myfaces.tobago.scriptBlocks";
+  private static String TOBAGO_STYLE_FILES = "org.apache.myfaces.tobago.styleFiles";
+  private static String TOBAGO_STYLE_BLOCKS = "org.apache.myfaces.tobago.styleBlocks";
+  private static String TOBAGO_ONLOAD_SCRIPTS = "org.apache.myfaces.tobago.onloadScripts";
+  private static String TOBAGO_ONUNLOAD_SCRIPTS = "org.apache.myfaces.tobago.onunloadScripts";
+  private static String TOBAGO_ONEXIT_SCRIPTS = "org.apache.myfaces.tobago.onexitScripts";
+  private static String TOBAGO_ONSUBMIT_SCRIPTS = "org.apache.myfaces.tobago.onsubmitScripts";
+  private static String TOBAGO_POPUPS = "org.apache.myfaces.tobago.popups";
+          
+  
+  public static boolean isAjax(FacesContext context) {
+    return FacesUtils.getFacesContextAttributes(context).containsKey(TOBAGO_AJAX);
+  }
+
+  public static void setAjax(FacesContext context, boolean ajax) {
+    FacesUtils.getFacesContextAttributes(context).put(TOBAGO_AJAX, ajax);
+  }
+
+  public static String getAjaxComponentId(FacesContext context) {
+    return (String) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_AJAX_COMPONENT_ID);
+  }
+
+  public static void setAjaxComponentId(FacesContext context, String ajaxComponentId) {
+    FacesUtils.getFacesContextAttributes(context).put(TOBAGO_AJAX_COMPONENT_ID, ajaxComponentId);
+  }
+
+  public static String getEnctype(FacesContext context) {
+    return (String) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_ENCTYPE);
+  }
+
+  public static void setEnctype(FacesContext context, String enctype) {
+    FacesUtils.getFacesContextAttributes(context).put(TOBAGO_ENCTYPE, enctype);
+  }
+
+  @SuppressWarnings("unchecked")
+  public static List<String> getScriptFiles(FacesContext context) {
+    List<String> list = (List<String>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_SCRIPT_FILES);
+    if (list == null) {
+      return Collections.EMPTY_LIST;
+    }
+    return list;
+  }
+  
+  public static void addScriptFile(FacesContext context, String file) {
+    List<String> list = (List<String>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_SCRIPT_FILES);
+    if (list == null) {
+      list = SetUniqueList.decorate(new ArrayList());
+      FacesUtils.getFacesContextAttributes(context).put(TOBAGO_SCRIPT_FILES, list);
+    }
+    list.add(file);
+
+  }
+
+  public static Set<String> getScriptBlocks(FacesContext context) {
+     Set<String> set = (Set<String>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_SCRIPT_BLOCKS);
+     if (set == null) {
+      return Collections.EMPTY_SET;
+    }
+    return set;
+  }
+
+  public static void addScriptBlock(FacesContext context, String script) {
+    Set<String> set = (Set<String>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_SCRIPT_BLOCKS);
+    if (set == null) {
+      set = new ListOrderedSet();
+      FacesUtils.getFacesContextAttributes(context).put(TOBAGO_SCRIPT_BLOCKS, set);
+    }
+    set.add(script);
+  }
+
+
+  public static Set<String> getStyleFiles(FacesContext context) {
+    Set<String> set = (Set<String>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_STYLE_FILES);
+    if (set == null) {
+      return Collections.EMPTY_SET;
+    }
+    return set;
+  }
+
+  public static void addStyleFile(FacesContext context, String script) {
+    Set<String> set = (Set<String>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_STYLE_FILES);
+    if (set == null) {
+      set = new ListOrderedSet();
+      FacesUtils.getFacesContextAttributes(context).put(TOBAGO_STYLE_FILES, set);
+    }
+    set.add(script);
+  }
+
+  public static Set<String> getStyleBlocks(FacesContext context) {
+    Set<String> set = (Set<String>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_STYLE_BLOCKS);
+    if (set == null) {
+      return Collections.EMPTY_SET;
+    }
+    return set;
+  }
+
+  public static void addStyleBlock(FacesContext context, String script) {
+    Set<String> set = (Set<String>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_STYLE_BLOCKS);
+    if (set == null) {
+      set = new ListOrderedSet();
+      FacesUtils.getFacesContextAttributes(context).put(TOBAGO_STYLE_BLOCKS, set);
+    }
+    set.add(script);
+  }
+
+  public static List<String> getOnloadScripts(FacesContext context) {
+    List<String> list = (List<String>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_ONLOAD_SCRIPTS);
+    if (list == null) {
+      return Collections.EMPTY_LIST;
+    }
+    return list;
+  }
+
+
+  public static void addOnloadScript(FacesContext context, String file) {
+    List<String> list = (List<String>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_ONLOAD_SCRIPTS);
+    if (list == null) {
+      list = SetUniqueList.decorate(new ArrayList());
+      FacesUtils.getFacesContextAttributes(context).put(TOBAGO_ONLOAD_SCRIPTS, list);
+    }
+    list.add(file);
+  }
+
+  public static void addOnloadScript(FacesContext context, int position, String file) {
+    List<String> list = (List<String>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_ONLOAD_SCRIPTS);
+    if (list == null) {
+      list = SetUniqueList.decorate(new ArrayList());
+      FacesUtils.getFacesContextAttributes(context).put(TOBAGO_ONLOAD_SCRIPTS, list);
+    }
+    list.add(position, file);
+  }
+
+  public static Set<String> getOnunloadScripts(FacesContext context) {
+    Set<String> set = (Set<String>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_ONUNLOAD_SCRIPTS);
+    if (set == null) {
+      return Collections.EMPTY_SET;
+    }
+    return set;
+  }
+
+  public static void addOnunloadScript(FacesContext context, String script) {
+    Set<String> set = (Set<String>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_ONUNLOAD_SCRIPTS);
+    if (set == null) {
+      set = new ListOrderedSet();
+      FacesUtils.getFacesContextAttributes(context).put(TOBAGO_ONUNLOAD_SCRIPTS, set);
+    }
+    set.add(script);
+  }
+
+  public static Set<String> getOnexitScripts(FacesContext context) {
+    Set<String> set = (Set<String>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_ONEXIT_SCRIPTS);
+    if (set == null) {
+      return Collections.EMPTY_SET;
+    }
+    return set;
+  }
+
+  public static void addOnexitScript(FacesContext context, String script) {
+    Set<String> set = (Set<String>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_ONEXIT_SCRIPTS);
+    if (set == null) {
+      set = new ListOrderedSet();
+      FacesUtils.getFacesContextAttributes(context).put(TOBAGO_ONEXIT_SCRIPTS, set);
+    }
+    set.add(script);
+  }
+
+  public static Set<String> getOnsubmitScripts(FacesContext context) {
+    Set<String> set = (Set<String>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_ONSUBMIT_SCRIPTS);
+    if (set == null) {
+      return Collections.EMPTY_SET;
+    }
+    return set;
+  }
+
+  public static void addOnsubmitScript(FacesContext context, String script) {
+    Set<String> set = (Set<String>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_ONSUBMIT_SCRIPTS);
+    if (set == null) {
+      set = new ListOrderedSet();
+      FacesUtils.getFacesContextAttributes(context).put(TOBAGO_ONSUBMIT_SCRIPTS, set);
+    }
+    set.add(script);
+  }
+
+  public static Set<AbstractUIPopup> getPopups(FacesContext context) {
+    Set<AbstractUIPopup> set = (Set<AbstractUIPopup>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_POPUPS);
+    if (set == null) {
+      return Collections.EMPTY_SET;
+    }
+    return set;
+  }
+
+  public static void addPopup(FacesContext context, AbstractUIPopup popup) {
+    Set<AbstractUIPopup> set = (Set<AbstractUIPopup>) FacesUtils.getFacesContextAttributes(context).get(TOBAGO_POPUPS);
+    if (set == null) {
+      set = new ListOrderedSet();
+      FacesUtils.getFacesContextAttributes(context).put(TOBAGO_POPUPS, set);
+    }
+    set.add(popup);
+  }
+}

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ApplyRequestValuesCallback.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ApplyRequestValuesCallback.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ApplyRequestValuesCallback.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ApplyRequestValuesCallback.java Tue Oct  4 14:12:00 2011
@@ -18,11 +18,11 @@ package org.apache.myfaces.tobago.util;
  */
 
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.myfaces.tobago.component.Attributes;
 import org.apache.myfaces.tobago.component.Facets;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
@@ -35,8 +35,8 @@ public class ApplyRequestValuesCallback 
   private static final Logger LOG = LoggerFactory.getLogger(ApplyRequestValuesCallback.class);
 
   public void invokeContextCallback(FacesContext context, UIComponent component) {
-    if (context instanceof TobagoFacesContext && ((TobagoFacesContext) context).isAjax()) {
-      final String ajaxId = ((TobagoFacesContext) context).getAjaxComponentId();
+    if (FacesContextUtils.isAjax(context)) {
+      final String ajaxId = FacesContextUtils.getAjaxComponentId(context);
       UIComponent reload = component.getFacet(Facets.RELOAD);
       if (ajaxId != null && ajaxId.equals(component.getClientId(context)) && reload != null && reload.isRendered()
           && ajaxId.equals(ComponentUtils.findPage(context, component).getActionId())) {

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/Secret.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/Secret.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/Secret.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/Secret.java Tue Oct  4 14:12:00 2011
@@ -18,7 +18,6 @@ package org.apache.myfaces.tobago.webapp
  */
 
 import org.apache.commons.codec.binary.Base64;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
 
@@ -85,7 +84,7 @@ public class Secret implements Serializa
   /**
    * Encode a hidden field with the secret value from the session.
    */
-  public static void encode(TobagoFacesContext facesContext, TobagoResponseWriter writer) throws IOException {
+  public static void encode(FacesContext facesContext, TobagoResponseWriter writer) throws IOException {
     writer.startElement(HtmlElements.INPUT, null);
     writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
     writer.writeAttribute(HtmlAttributes.NAME, Secret.KEY, false);

Modified: myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java (original)
+++ myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java Tue Oct  4 14:12:00 2011
@@ -22,8 +22,8 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.component.UICommand;
 import org.apache.myfaces.tobago.component.UIPage;
 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.internal.util.Deprecation;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.internal.webapp.TobagoResponseWriterWrapper;
 import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
 import org.apache.myfaces.tobago.renderkit.css.Style;
@@ -450,9 +450,9 @@ public final class HtmlRendererUtil {
       allScripts = ResourceManagerUtils.getScriptsAsJSArray(facesContext, scripts);
     }
     boolean ajax = false;
-    if (facesContext instanceof TobagoFacesContext) {
-      ajax = ((TobagoFacesContext) facesContext).isAjax();
-    }
+
+    ajax = FacesContextUtils.isAjax(facesContext);
+
     writer.startJavascript();
     writer.write("new Tobago.ScriptLoader(");
     if (!ajax) {
@@ -680,10 +680,8 @@ public final class HtmlRendererUtil {
       throws IOException {
     Object objDojoType = component.getAttributes().get("dojoType");
     if (null != objDojoType && (objDojoType.equals("dojo.dnd.Source") || objDojoType.equals("dojo.dnd.Target"))) {
-      if (context instanceof TobagoFacesContext) {
-        ((TobagoFacesContext) context).getOnloadScripts().add(createDojoDndType(component,
-            component.getClientId(context), String.valueOf(objDojoType)));
-      }
+      FacesContextUtils.addOnloadScript(context, createDojoDndType(component,
+          component.getClientId(context), String.valueOf(objDojoType)));
     }
   }
 

Modified: myfaces/tobago/trunk/tobago-jsf-compat/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/pom.xml?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-jsf-compat/pom.xml Tue Oct  4 14:12:00 2011
@@ -47,7 +47,7 @@
     <dependency>
       <groupId>org.apache.myfaces.core</groupId>
       <artifactId>myfaces-api</artifactId>
-      <version>${myfaces12.version}</version>
+      <version>${myfaces20.version}</version>
       <optional>true</optional>
     </dependency>
     <dependency>

Modified: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java (original)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java Tue Oct  4 14:12:00 2011
@@ -40,6 +40,7 @@ import javax.faces.event.AbortProcessing
 import javax.faces.event.FacesEvent;
 import javax.faces.webapp.UIComponentTag;
 import java.util.Comparator;
+import java.util.Map;
 
 @SuppressWarnings("deprecation")
 public class FacesUtils {
@@ -273,6 +274,14 @@ public class FacesUtils {
     }
   }
 
+  public static Map getFacesContextAttributes(FacesContext context) {
+    if (FacesVersion.supports20()) {
+      return context.getAttributes();
+    } else {
+      return context.getExternalContext().getRequestMap();
+    }
+  }
+
   public static boolean supportsEL() {
     return !USE_BINDING;
   }

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java Tue Oct  4 14:12:00 2011
@@ -32,9 +32,9 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.component.UIPopup;
 import org.apache.myfaces.tobago.component.UITime;
 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.event.PopupActionListener;
 import org.apache.myfaces.tobago.internal.util.DateFormatUtils;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.layout.Measure;
 import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
 import org.apache.myfaces.tobago.util.ComponentUtils;
@@ -168,7 +168,7 @@ public class DatePickerRenderer extends 
         Attributes.LAYOUT_WIDTH,
         getResourceManager().getThemeMeasure(facesContext, picker, "pickerWidth").getPixel());
 
-    ((TobagoFacesContext) facesContext).getPopups().add((UIPopup) picker.getFacets().get(Facets.PICKER_POPUP));
+    FacesContextUtils.addPopup(facesContext, (UIPopup) picker.getFacets().get(Facets.PICKER_POPUP));
 
     super.prepareRender(facesContext, picker);
   }

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/FileRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/FileRenderer.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/FileRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/FileRenderer.java Tue Oct  4 14:12:00 2011
@@ -26,7 +26,7 @@ import org.apache.commons.fileupload.Fil
 import org.apache.myfaces.tobago.component.Attributes;
 import org.apache.myfaces.tobago.component.UIFileInput;
 import org.apache.myfaces.tobago.context.ClientProperties;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.internal.webapp.TobagoMultipartFormdataRequest;
 import org.apache.myfaces.tobago.renderkit.InputRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
@@ -52,9 +52,7 @@ public class FileRenderer extends InputR
 
   public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
     super.prepareRender(facesContext, component);
-    if (facesContext instanceof TobagoFacesContext) {
-      ((TobagoFacesContext) facesContext).setEnctype("multipart/form-data");
-    }
+    FacesContextUtils.setEnctype(facesContext, "multipart/form-data");
   }
 
   public boolean getRendersChildren() {

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java Tue Oct  4 14:12:00 2011
@@ -19,8 +19,6 @@ package org.apache.myfaces.tobago.render
 
 import org.apache.myfaces.tobago.ajax.AjaxUtils;
 import org.apache.myfaces.tobago.component.Attributes;
-import org.apache.myfaces.tobago.internal.ajax.AjaxInternalUtils;
-import org.apache.myfaces.tobago.util.CreateComponentUtils;
 import org.apache.myfaces.tobago.component.Facets;
 import org.apache.myfaces.tobago.component.RendererTypes;
 import org.apache.myfaces.tobago.component.UIBox;
@@ -34,8 +32,9 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.config.Configurable;
 import org.apache.myfaces.tobago.context.Markup;
 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
+import org.apache.myfaces.tobago.internal.ajax.AjaxInternalUtils;
 import org.apache.myfaces.tobago.internal.component.AbstractUIPage;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.layout.Measure;
 import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
@@ -44,6 +43,7 @@ import org.apache.myfaces.tobago.renderk
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
 import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.apache.myfaces.tobago.util.CreateComponentUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -124,8 +124,8 @@ public class MessagesRenderer extends La
       }
     }
     if (messages.getFor() == null
-        && !AjaxUtils.isAjaxRequest(facesContext) && facesContext instanceof TobagoFacesContext) {
-      AjaxInternalUtils.storeMessagesClientIds((TobagoFacesContext) facesContext, messages);
+        && !AjaxUtils.isAjaxRequest(facesContext)) {
+      AjaxInternalUtils.storeMessagesClientIds(facesContext, messages);
     }
   }
 
@@ -146,7 +146,7 @@ public class MessagesRenderer extends La
     popup.setTop(Measure.valueOf(100));
     popup.setRendered(true);
     popup.setActivated(true);
-    ((TobagoFacesContext) facesContext).getPopups().add(popup);
+    FacesContextUtils.addPopup(facesContext, popup);
 
     Map<String, Object> okButtonAttributes = popup.getAttributes();
     okButtonAttributes.put(Attributes.POPUP_RESET, Boolean.TRUE);

Modified: myfaces/tobago/trunk/tobago-theme/tobago-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/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java Tue Oct  4 14:12:00 2011
@@ -31,13 +31,13 @@ import org.apache.myfaces.tobago.context
 import org.apache.myfaces.tobago.context.Markup;
 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
 import org.apache.myfaces.tobago.context.Theme;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.internal.ajax.AjaxInternalUtils;
 import org.apache.myfaces.tobago.internal.component.AbstractUICommandBase;
 import org.apache.myfaces.tobago.internal.component.AbstractUIPage;
 import org.apache.myfaces.tobago.internal.layout.LayoutContext;
 import org.apache.myfaces.tobago.internal.util.AccessKeyMap;
 import org.apache.myfaces.tobago.internal.util.Deprecation;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.internal.util.FastStringWriter;
 import org.apache.myfaces.tobago.internal.util.MimeTypeUtils;
 import org.apache.myfaces.tobago.internal.util.ResponseUtils;
@@ -128,18 +128,11 @@ public class PageRenderer extends PageRe
   }
 
   @Override
-  public void encodeBegin(FacesContext facesContextOrg, UIComponent component) throws IOException {
+  public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
 
     UIPage page = (UIPage) component;
 
     // invoke prepareRender
-    TobagoFacesContext facesContext;
-    if (facesContextOrg instanceof TobagoFacesContext) {
-      facesContext = (TobagoFacesContext) facesContextOrg;
-    } else {
-      facesContext = new TobagoFacesContext(facesContextOrg);
-    }
-
     RenderUtils.prepareRendererAll(facesContext, page);
 
     LayoutContext layoutContext = new LayoutContext(page);
@@ -188,7 +181,7 @@ public class PageRenderer extends PageRe
       }
     }
 
-    if (!facesContext.isAjax()) {
+    if (!FacesContextUtils.isAjax(facesContext)) {
       HtmlRendererUtils.renderDojoDndSource(facesContext, component);
 
       String title = (String) page.getAttributes().get(Attributes.LABEL);
@@ -217,7 +210,7 @@ public class PageRenderer extends PageRe
         writeStyle(facesContext, writer, styleFile);
       }
 
-      for (String styleFile : facesContext.getStyleFiles()) {
+      for (String styleFile : FacesContextUtils.getStyleFiles(facesContext)) {
         writeStyle(facesContext, writer, styleFile);
       }
 
@@ -244,7 +237,7 @@ public class PageRenderer extends PageRe
       }
 
       // style sniplets
-      Set<String> styleBlocks = facesContext.getStyleBlocks();
+      Set<String> styleBlocks = FacesContextUtils.getStyleBlocks(facesContext);
       if (styleBlocks.size() > 0) {
         writer.startElement(HtmlElements.STYLE, null);
         for (String cssBlock : styleBlocks) {
@@ -268,7 +261,7 @@ public class PageRenderer extends PageRe
           hideClientLogging = !severity.contains("show");
         }
         // the jquery ui is used in moment only for the logging area...
-        facesContext.getOnloadScripts().add(0, "new LOG.LogArea({hide: " + hideClientLogging + "});");
+        FacesContextUtils.addOnloadScript(facesContext, 0, "new LOG.LogArea({hide: " + hideClientLogging + "});");
       }
 
       // render remaining script tags
@@ -276,7 +269,7 @@ public class PageRenderer extends PageRe
         encodeScript(facesContext, writer, scriptFile);
       }
 
-      for (String scriptFile : facesContext.getScriptFiles()) {
+      for (String scriptFile : FacesContextUtils.getScriptFiles(facesContext)) {
         encodeScript(facesContext, writer, scriptFile);
       }
 
@@ -298,7 +291,7 @@ public class PageRenderer extends PageRe
           String target = ComponentUtils.getStringAttribute(command, Attributes.TARGET);
           String action
               = HtmlRendererUtils.createSubmitAction(command.getClientId(facesContext), transition, target, null);
-          facesContext.getOnloadScripts().add("setTimeout(\"" + action  + "\", " + duration + ");\n");
+          FacesContextUtils.addOnloadScript(facesContext, "setTimeout(\"" + action  + "\", " + duration + ");\n");
         }
       }
 
@@ -306,13 +299,13 @@ public class PageRenderer extends PageRe
       calculateScrollbarWeight
           = client.getVerticalScrollbarWeight() == null || client.getHorizontalScrollbarWeight() == null;
       if (calculateScrollbarWeight) {
-        facesContext.getOnloadScripts().add(
+        FacesContextUtils.addOnloadScript(facesContext,
             "Tobago.calculateScrollbarWeights('" + clientId + ComponentUtils.SUB_SEPARATOR + "scrollbarWeight" + "');");
       } else {
-        facesContext.getOnloadScripts().add(
+        FacesContextUtils.addOnloadScript(facesContext,
             "Tobago.Config.set('Tobago', 'verticalScrollbarWeight', '"
                 + client.getVerticalScrollbarWeight().getPixel() + "');");
-        facesContext.getOnloadScripts().add(
+        FacesContextUtils.addOnloadScript(facesContext,
             "Tobago.Config.set('Tobago', 'horizontalScrollbarWeight', '"
                 + client.getHorizontalScrollbarWeight().getPixel() + "');");
       }
@@ -347,18 +340,18 @@ public class PageRenderer extends PageRe
 
       writer.startJavascript();
       // onload script
-      writeEventFunction(writer, facesContext.getOnloadScripts(), "load", false);
+      writeEventFunction(writer, FacesContextUtils.getOnloadScripts(facesContext), "load", false);
 
       // onunload script
-      writeEventFunction(writer, facesContext.getOnunloadScripts(), "unload", false);
+      writeEventFunction(writer, FacesContextUtils.getOnunloadScripts(facesContext), "unload", false);
 
       // onexit script
-      writeEventFunction(writer, facesContext.getOnexitScripts(), "exit", false);
+      writeEventFunction(writer, FacesContextUtils.getOnexitScripts(facesContext), "exit", false);
 
-      writeEventFunction(writer, facesContext.getOnsubmitScripts(), "submit", true);
+      writeEventFunction(writer, FacesContextUtils.getOnsubmitScripts(facesContext), "submit", true);
 
       int debugCounter = 0;
-      for (String scriptBlock : facesContext.getScriptBlocks()) {
+      for (String scriptBlock : FacesContextUtils.getScriptBlocks(facesContext)) {
 
         if (LOG.isDebugEnabled()) {
           LOG.debug("write scriptblock " + ++debugCounter + " :\n" + scriptBlock);
@@ -406,7 +399,7 @@ public class PageRenderer extends PageRe
     writer.writeAttribute(HtmlAttributes.ACTION, formAction, true);
     writer.writeIdAttribute(page.getFormId(facesContext));
     writer.writeAttribute(HtmlAttributes.METHOD, getMethod(page), false);
-    String enctype = facesContext.getEnctype();
+    String enctype = FacesContextUtils.getEnctype(facesContext);
     if (enctype != null) {
       writer.writeAttribute(HtmlAttributes.ENCTYPE, enctype, false);
     }
@@ -512,7 +505,7 @@ public class PageRenderer extends PageRe
     writer.writeStyleAttribute(style);
   }
 
-  private void writeStyle(TobagoFacesContext facesContext, TobagoResponseWriter writer, String styleFile)
+  private void writeStyle(FacesContext facesContext, TobagoResponseWriter writer, String styleFile)
       throws IOException {
     List<String> styles = ResourceManagerUtils.getStyles(facesContext, styleFile);
     for (String styleString : styles) {
@@ -534,14 +527,8 @@ public class PageRenderer extends PageRe
 //  }
 
   @Override
-  public void encodeEnd(FacesContext facesContextOrg, UIComponent component) throws IOException {
+  public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
 
-    TobagoFacesContext facesContext;
-    if (facesContextOrg instanceof TobagoFacesContext) {
-      facesContext = (TobagoFacesContext) facesContextOrg;
-    } else {
-      facesContext = new TobagoFacesContext(facesContextOrg);
-    }
 
     UIPage page = (UIPage) component;
     TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
@@ -551,7 +538,9 @@ public class PageRenderer extends PageRe
     // write popup components
     // beware of ConcurrentModificationException in cascading popups!
     // no foreach
-    UIPopup[] popupArray = facesContext.getPopups().toArray(new UIPopup[facesContext.getPopups().size()]);
+
+    UIPopup[] popupArray = FacesContextUtils.getPopups(facesContext).toArray(
+        new UIPopup[FacesContextUtils.getPopups(facesContext).size()]);
     for (UIPopup popup : popupArray) {
       RenderUtils.encode(facesContext, popup);
     }
@@ -559,13 +548,39 @@ public class PageRenderer extends PageRe
     String clientId = page.getClientId(facesContext);
     final boolean debugMode = VariableResolverUtils.resolveClientProperties(facesContext).isDebugMode();
 
+
+    // avoid submit page in ie if the form contains only one input and you press the enter key in the input
+    if (VariableResolverUtils.resolveClientProperties(facesContext).getUserAgent().isMsie()) {
+      writer.startElement(HtmlElements.INPUT, null);
+      writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.TEXT, false);
+      writer.writeAttribute(HtmlAttributes.NAME, "tobago.dummy", false);
+      writer.writeAttribute(HtmlAttributes.TABINDEX, "-1", false);
+      writer.writeAttribute(HtmlAttributes.STYLE, "visibility:hidden;display:none;", false);
+      writer.endElement(HtmlElements.INPUT);
+    }
+
+    List<String> messageClientIds = AjaxInternalUtils.getMessagesClientIds(facesContext);
+    if (messageClientIds != null) {
+      writer.startElement(HtmlElements.INPUT, null);
+      writer.writeAttribute(HtmlAttributes.VALUE, StringUtils.join(messageClientIds, ','), true);
+      writer.writeAttribute(HtmlAttributes.ID, clientId + ComponentUtils.SUB_SEPARATOR + "messagesClientIds", false);
+      writer.writeAttribute(HtmlAttributes.NAME, clientId + ComponentUtils.SUB_SEPARATOR + "messagesClientIds", false);
+      writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
+      writer.endElement(HtmlElements.INPUT);
+    }
+
+    // placeholder for menus
+    writer.startElement(HtmlElements.DIV, page);
+    writer.writeClassAttribute(Classes.create(page, "menuStore"));
+    writer.endElement(HtmlElements.DIV);
+
     Application application = facesContext.getApplication();
     ViewHandler viewHandler = application.getViewHandler();
 
     writer.startElement(HtmlElements.SPAN, null);
     writer.writeIdAttribute(clientId + ComponentUtils.SUB_SEPARATOR + "jsf-state-container");
     writer.flush();
-    if (!facesContext.isAjax()) {
+    if (!FacesContextUtils.isAjax(facesContext)) {
       if (FacesVersion.supports12()) {
         viewHandler.writeState(facesContext);
       } else {
@@ -585,8 +600,8 @@ public class PageRenderer extends PageRe
           }
           writer.startElement(HtmlElements.INPUT, null);
           writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
-          writer.writeAttribute(HtmlAttributes.NAME, TobagoResponseStateManager.TREE_PARAM, false);
-          writer.writeAttribute(HtmlAttributes.ID, TobagoResponseStateManager.TREE_PARAM, false);
+          writer.writeAttribute(HtmlAttributes.NAME, TobagoResponseStateManager.VIEW_STATE_PARAM, false);
+          writer.writeAttribute(HtmlAttributes.ID, TobagoResponseStateManager.VIEW_STATE_PARAM, false);
           writer.writeAttribute(HtmlAttributes.VALUE, "workaround", false);
           writer.endElement(HtmlElements.INPUT);
         } else {
@@ -596,31 +611,7 @@ public class PageRenderer extends PageRe
     }
     writer.endElement(HtmlElements.SPAN);
 
-    // avoid submit page in ie if the form contains only one input and you press the enter key in the input
-    if (VariableResolverUtils.resolveClientProperties(facesContext).getUserAgent().isMsie()) {
-      writer.startElement(HtmlElements.INPUT, null);
-      writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.TEXT, false);
-      writer.writeAttribute(HtmlAttributes.NAME, "tobago.dummy", false);
-      writer.writeAttribute(HtmlAttributes.TABINDEX, "-1", false);
-      writer.writeAttribute(HtmlAttributes.STYLE, "visibility:hidden;display:none;", false);
-      writer.endElement(HtmlElements.INPUT);
-    }
-
-    List<String> messageClientIds = AjaxInternalUtils.getMessagesClientIds(facesContext);
-    if (messageClientIds != null) {
-      writer.startElement(HtmlElements.INPUT, null);
-      writer.writeAttribute(HtmlAttributes.VALUE, StringUtils.join(messageClientIds, ','), true);
-      writer.writeAttribute(HtmlAttributes.ID, clientId + ComponentUtils.SUB_SEPARATOR + "messagesClientIds", false);
-      writer.writeAttribute(HtmlAttributes.NAME, clientId + ComponentUtils.SUB_SEPARATOR + "messagesClientIds", false);
-      writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
-      writer.endElement(HtmlElements.INPUT);
-    }
 
-    // placeholder for menus
-    writer.startElement(HtmlElements.DIV, page);
-    writer.writeClassAttribute(Classes.create(page, "menuStore"));
-    writer.endElement(HtmlElements.DIV);
-    
     writer.endElement(HtmlElements.FORM);
 
     // debugging...

Modified: myfaces/tobago/trunk/tobago-theme/tobago-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/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java Tue Oct  4 14:12:00 2011
@@ -20,8 +20,8 @@ package org.apache.myfaces.tobago.render
 import org.apache.myfaces.tobago.component.Facets;
 import org.apache.myfaces.tobago.component.UIPanel;
 import org.apache.myfaces.tobago.component.UIReload;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.internal.component.AbstractUIPanel;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.layout.Measure;
 import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
@@ -89,7 +89,7 @@ public class PanelRenderer extends Layou
     HtmlRendererUtils.encodeContextMenu(facesContext, writer, panel);
 
     // TODO check ajax id
-    if (facesContext instanceof TobagoFacesContext && !((TobagoFacesContext) facesContext).isAjax()) {
+    if (FacesContextUtils.isAjax(facesContext)) {
       Integer frequency = null;
       UIComponent facetReload = panel.getFacet(Facets.RELOAD);
       if (facetReload != null && facetReload instanceof UIReload && facetReload.isRendered()) {

Modified: myfaces/tobago/trunk/tobago-theme/tobago-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/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java Tue Oct  4 14:12:00 2011
@@ -19,9 +19,9 @@ package org.apache.myfaces.tobago.render
 
 import org.apache.myfaces.tobago.component.UIPopup;
 import org.apache.myfaces.tobago.context.Markup;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.internal.component.AbstractUIPage;
 import org.apache.myfaces.tobago.internal.layout.LayoutContext;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
 import org.apache.myfaces.tobago.renderkit.css.Style;
@@ -51,13 +51,10 @@ public class PopupRenderer extends Layou
 
     UIPopup popup = (UIPopup) component;
 
-    if (facesContext instanceof TobagoFacesContext) {
-      ((TobagoFacesContext) facesContext).getPopups().add(popup);
-    }
+    FacesContextUtils.addPopup(facesContext, popup);
+
 
-    // TODO: where to put this code, it is good here?
-    TobagoFacesContext tobagoContext = (TobagoFacesContext) facesContext;
-    tobagoContext.getScriptBlocks().add("jQuery(document).ready(function() {Tobago.setupPopup();});");
+    FacesContextUtils.addScriptBlock(facesContext, "jQuery(document).ready(function() {Tobago.setupPopup();});");
 
     super.prepareRender(facesContext, popup);
 
@@ -70,7 +67,7 @@ public class PopupRenderer extends Layou
   public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
     TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
     // TODO check ajaxId
-    if (facesContext instanceof TobagoFacesContext && ((TobagoFacesContext) facesContext).isAjax()) {
+    if (FacesContextUtils.isAjax(facesContext)) {
       writer.startJavascript();
       writer.write("Tobago.setupPopup();");
       writer.endJavascript();

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ScriptRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ScriptRenderer.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ScriptRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ScriptRenderer.java Tue Oct  4 14:12:00 2011
@@ -17,45 +17,42 @@ package org.apache.myfaces.tobago.render
  * limitations under the License.
  */
 
-import org.apache.myfaces.tobago.renderkit.RendererBase;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.component.UIScript;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
+import org.apache.myfaces.tobago.renderkit.RendererBase;
 
-import javax.faces.context.FacesContext;
 import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
 import java.io.IOException;
 
 public class ScriptRenderer extends RendererBase {
 
   public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
     super.prepareRender(facesContext, component);
-    if (facesContext instanceof TobagoFacesContext) {
-      TobagoFacesContext pageFacesContext = (TobagoFacesContext) facesContext;
-      UIScript scriptComponent = (UIScript) component;
-      String exit = scriptComponent.getOnexit();
-      if (exit != null) {
-        pageFacesContext.getOnexitScripts().add(exit);
-      }
-      String submit = scriptComponent.getOnsubmit();
-      if (submit != null) {
-        pageFacesContext.getOnsubmitScripts().add(submit);
-      }
-      String load = scriptComponent.getOnload();
-      if (load != null) {
-        pageFacesContext.getOnloadScripts().add(load);
-      }
-      String unload = scriptComponent.getOnunload();
-      if (unload != null) {
-        pageFacesContext.getOnunloadScripts().add(unload);
-      }
-      String script = scriptComponent.getScript();
-      if (script != null) {
-        pageFacesContext.getScriptBlocks().add(script);
-      }
-      String file = scriptComponent.getFile();
-      if (file != null) {
-        pageFacesContext.getScriptFiles().add(file);
-      }
+    UIScript scriptComponent = (UIScript) component;
+    String exit = scriptComponent.getOnexit();
+    if (exit != null) {
+      FacesContextUtils.addOnexitScript(facesContext, exit);
+    }
+    String submit = scriptComponent.getOnsubmit();
+    if (submit != null) {
+      FacesContextUtils.addOnsubmitScript(facesContext, submit);
+    }
+    String load = scriptComponent.getOnload();
+    if (load != null) {
+      FacesContextUtils.addOnloadScript(facesContext, load);
+    }
+    String unload = scriptComponent.getOnunload();
+    if (unload != null) {
+      FacesContextUtils.addOnunloadScript(facesContext, unload);
+    }
+    String script = scriptComponent.getScript();
+    if (script != null) {
+      FacesContextUtils.addScriptBlock(facesContext, script);
+    }
+    String file = scriptComponent.getFile();
+    if (file != null) {
+      FacesContextUtils.addScriptFile(facesContext, file);
     }
   }
 }

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneRadioRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneRadioRenderer.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneRadioRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneRadioRenderer.java Tue Oct  4 14:12:00 2011
@@ -20,7 +20,7 @@ package org.apache.myfaces.tobago.render
 import org.apache.myfaces.tobago.component.UISelectOneRadio;
 import org.apache.myfaces.tobago.config.Configurable;
 import org.apache.myfaces.tobago.context.Markup;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.layout.Measure;
 import org.apache.myfaces.tobago.renderkit.SelectOneRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
@@ -46,10 +46,8 @@ public class SelectOneRadioRenderer exte
   public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
     UISelectOneRadio select = (UISelectOneRadio) component;
     super.prepareRender(facesContext, select);
-    if (facesContext instanceof TobagoFacesContext) {
-      ((TobagoFacesContext) facesContext).getOnloadScripts().add("Tobago.selectOneRadioInit('"
+      FacesContextUtils.addOnloadScript(facesContext, "Tobago.selectOneRadioInit('"
           + select.getClientId(facesContext) + "')");
-    }
     if (select.isInline()) {
       select.setCurrentMarkup(Markup.INLINE.add(select.getCurrentMarkup()));
     }

Modified: myfaces/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/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Tue Oct  4 14:12:00 2011
@@ -35,9 +35,9 @@ import org.apache.myfaces.tobago.context
 import org.apache.myfaces.tobago.context.Markup;
 import org.apache.myfaces.tobago.context.ResourceManager;
 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.event.PageAction;
 import org.apache.myfaces.tobago.internal.context.ResourceManagerFactory;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.internal.util.StringUtils;
 import org.apache.myfaces.tobago.layout.LayoutBase;
 import org.apache.myfaces.tobago.layout.Measure;
@@ -128,9 +128,7 @@ public class SheetRenderer extends Layou
 
     writer.endElement(HtmlElements.DIV);
     // TODO check ajax id
-    if (facesContext instanceof TobagoFacesContext
-        && !(((TobagoFacesContext) facesContext).isAjax()
-        && sheetId.equals(((TobagoFacesContext) facesContext).getAjaxComponentId()))) {
+    if (!(FacesContextUtils.isAjax(facesContext) && sheetId.equals(FacesContextUtils.getAjaxComponentId(facesContext)))) {
 
       Integer frequency = null;
       UIComponent facetReload = sheet.getFacet(Facets.RELOAD);

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/StyleRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/StyleRenderer.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/StyleRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/StyleRenderer.java Tue Oct  4 14:12:00 2011
@@ -17,12 +17,12 @@ package org.apache.myfaces.tobago.render
  * limitations under the License.
  */
 
-import org.apache.myfaces.tobago.renderkit.RendererBase;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.component.UIStyle;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
+import org.apache.myfaces.tobago.renderkit.RendererBase;
 
-import javax.faces.context.FacesContext;
 import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
 import java.io.IOException;
 
 
@@ -30,17 +30,14 @@ public class StyleRenderer extends Rende
 
   public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
     super.prepareRender(facesContext, component);
-    if (facesContext instanceof TobagoFacesContext) {
-      TobagoFacesContext pageFacesContext = (TobagoFacesContext) facesContext;
-      UIStyle styleComponent = (UIStyle) component;
-      String file = styleComponent.getFile();
-      if (file != null) {
-        pageFacesContext.getStyleFiles().add(file);
-      }
-      String style = styleComponent.getStyle();
-      if (style != null) {
-        pageFacesContext.getStyleBlocks().add(style);
-      }
+    UIStyle styleComponent = (UIStyle) component;
+    String file = styleComponent.getFile();
+    if (file != null) {
+      FacesContextUtils.addStyleFile(facesContext, file);
+    }
+    String style = styleComponent.getStyle();
+    if (style != null) {
+      FacesContextUtils.addStyleBlock(facesContext, style);
     }
   }
 }

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java?rev=1178804&r1=1178803&r2=1178804&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java Tue Oct  4 14:12:00 2011
@@ -26,8 +26,8 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.component.UISheet;
 import org.apache.myfaces.tobago.context.Markup;
 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.internal.util.Deprecation;
+import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.internal.webapp.TobagoResponseWriterWrapper;
 import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
@@ -237,9 +237,7 @@ public final class HtmlRendererUtils {
       allScripts = ResourceManagerUtils.getScriptsAsJSArray(facesContext, scripts);
     }
     boolean ajax = false;
-    if (facesContext instanceof TobagoFacesContext) {
-      ajax = ((TobagoFacesContext) facesContext).isAjax();
-    }
+    ajax = FacesContextUtils.isAjax(facesContext);
     writer.startJavascript();
     writer.write("new Tobago.ScriptLoader(");
     if (!ajax) {
@@ -487,10 +485,8 @@ public final class HtmlRendererUtils {
       throws IOException {
     Object objDojoType = component.getAttributes().get("dojoType");
     if (null != objDojoType && (objDojoType.equals("dojo.dnd.Source") || objDojoType.equals("dojo.dnd.Target"))) {
-      if (context instanceof TobagoFacesContext) {
-        ((TobagoFacesContext) context).getOnloadScripts().add(createDojoDndType(component,
-            component.getClientId(context), String.valueOf(objDojoType)));
-      }
+      FacesContextUtils.addOnloadScript(context, createDojoDndType(component,
+          component.getClientId(context), String.valueOf(objDojoType)));
     }
   }
 



Mime
View raw message