You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by aw...@apache.org on 2007/08/08 00:18:42 UTC

svn commit: r563680 [7/42] - in /myfaces/trinidad/branches/1.2.2-branch: plugins/ plugins/maven-faces-plugin/ plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/ plugins/maven-faces-plugin/src/main/java/org/apache/my...

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/GlobalConfiguratorImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/GlobalConfiguratorImpl.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/GlobalConfiguratorImpl.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/GlobalConfiguratorImpl.java Tue Aug  7 15:18:22 2007
@@ -1,508 +1,722 @@
-/*
- *  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.
- */
-
-package org.apache.myfaces.trinidadinternal.config;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.context.ExternalContext;
-
-import org.apache.myfaces.trinidad.config.Configurator;
-import org.apache.myfaces.trinidad.context.RequestContext;
-import org.apache.myfaces.trinidad.context.RequestContextFactory;
-import org.apache.myfaces.trinidad.logging.TrinidadLogger;
-import org.apache.myfaces.trinidad.skin.SkinFactory;
-import org.apache.myfaces.trinidad.util.ClassLoaderUtils;
-import org.apache.myfaces.trinidadinternal.context.RequestContextFactoryImpl;
-import org.apache.myfaces.trinidadinternal.skin.SkinFactoryImpl;
-import org.apache.myfaces.trinidadinternal.skin.SkinUtils;
-import org.apache.myfaces.trinidadinternal.util.ExternalContextUtils;
-
-/**
- * This is the implementation of the Trinidad's Global configurator. It provides the entry point for
- * all other configurators. This class is responsible for enforcing the contract outlined by the
- * Configurator abstract class, but allows a more "relaxed" implementation of the APIs called for by
- * the Configurator class, making it more convenient to use ConfiguratorServices from within the
- * Trinidad renderkit. Where appropriate, these differences will be documented for the benifit of
- * the Trindad developer.
- *
- * @see org.apache.myfaces.trinidad.config.Configurator
- * @version $Revision$ $Date$
- */
-public class GlobalConfiguratorImpl extends Configurator
-{
-  /**
-   * Returns a GlobalConfigurator instance for the current context's class loader. The
-   * GlobalConfigurator is responsible for enforcing the contract on the other methods of this
-   * class. This means that if {@link #init(ExternalContext)} is called multiple times, the global
-   * configurator will call all subordinate configurators only once.
-   *
-   * Likewise, the GlobalConfigurator will return exceptions when the contract is expressly violated
-   * (like if {@link #getExternalContext(ExternalContext)} is called before a {{@link #beginRequest(ExternalContext)}.
-   *
-   * @return a GlobalConfigurator or <code>null</code> is one was unable to be obtained.
-   */
-  static public final GlobalConfiguratorImpl getInstance()
-  {
-    final ClassLoader loader = Thread.currentThread().getContextClassLoader();
-
-    if (loader == null)
-    {
-      _LOG.severe("CANNOT_FIND_CONTEXT_CLASS_LOADER");
-    }
-    else
-    {
-      synchronized (_CONFIGURATORS)
-      {
-        GlobalConfiguratorImpl config = _CONFIGURATORS.get(loader);
-        if (config == null)
-        {
-          try
-          {
-            config = new GlobalConfiguratorImpl();
-            _CONFIGURATORS.put(loader, config);
-          }
-          catch (final RuntimeException e)
-          {
-            // OC4J was not reporting these errors properly:
-            _LOG.severe(e);
-            throw e;
-          }
-          _LOG.fine("GlobalConfigurator has been created.");
-        }
-        return config;
-      }
-    }
-    return null;
-  }
-
-  /**
-   * Returns true if the request has not been stated for the current "virtual"
-   * request.  In the servlet environment this will be true after
-   * {@link #beginRequest(ExternalContext)} is executed and before
-   * {@link #endRequest(ExternalContext)} is executed.  This will generally
-   * happen once per request.  In the Portlet Environment, the request must be
-   * be started and ended at the beginning and end of both the actionRequest
-   * and the RenderRequest.
-   *
-   * @param ec
-   * @return
-   */
-  static public boolean isRequestStarted(final ExternalContext ec)
-  {
-    return (RequestType.getType(ec) != null);
-  }
-
-  /**
-   * Returns "true" if the services should be considered enabled or disabled.
-   *
-   * @param ec
-   * @return
-   */
-  static private final boolean _isDisabled(final ExternalContext ec)
-  {
-    final Boolean inRequest = (Boolean) ec.getRequestMap().get(_IN_REQUEST);
-
-    if (inRequest == null)
-    {
-      return isConfiguratorServiceDisabled(ec);
-    }
-    else
-    {
-      final boolean disabled = inRequest.booleanValue();
-      if (disabled != isConfiguratorServiceDisabled(ec))
-      {
-        _LOG
-            .warning("Configurator services were disabled after beginRequest was executed.  Cannot disable configurator services");
-      }
-
-      return disabled;
-    }
-  }
-
-  /**
-   * Private default constructor. Right now this class is not serializable. If serialization is
-   * required, we may wish to make this public. We really don't want people using this though.
-   */
-  private GlobalConfiguratorImpl()
-  {}
-
-  /**
-   * Executes the beginRequest methods of all of the configurator services. This method will also
-   * initizlize the configurator if it has not already been initialized, so there may be no need to
-   * call the {@link #init(ExternalContext)} method directly.
-   *
-   * This method also ensures that the requestContext is attached before the beginRequest methods
-   * are called, so there is no reason to initialize the request context before calling this method.
-   * In portal environments, it is important to execute this method once for each Portlet action and
-   * render request so that the requestContext may be properly initialized even though the
-   * underlying services will be called only once per physical request.
-   *
-   * @param externalContext
-   *          the externalContext to use to begin the request.
-   *
-   * @see org.apache.myfaces.trinidad.config.Configurator#beginRequest(javax.faces.context.ExternalContext)
-   */
-  @SuppressWarnings("unchecked") // TODO: remove this for Faces 1.2
-  @Override
-  public void beginRequest(final ExternalContext externalContext)
-  {
-    // asserts for debug which disappear in production
-    assert externalContext != null;
-
-    // Do per-virtual request stuff
-    if (RequestType.getType(externalContext) == null)
-    {
-      // RequestType may change in a portal environment. Make sure it's set up to enforce the
-      // contracts
-      RequestType.setType(externalContext);
-
-      // By contract, Configurators beginRequest is only called once per physical request.
-      // The globalConfigurator may be called multiple times, however, so we need to enforce
-      // the contract.
-      if (!_isDisabled(externalContext))
-      {
-        // If this hasn't been initialized then please initialize
-        if (!_initialized)
-        {
-          init(externalContext);
-        }
-
-        _attachRequestContext(externalContext);
-
-        if (externalContext.getRequestMap().get(_IN_REQUEST) == null)
-        {
-          _startConfiguratorServiceRequest(externalContext);
-        }
-      }
-      else
-      {
-        _LOG.fine("GlobalConfigurator: Configurators have been disabled for this request.");
-      }
-    }
-    else if (!RequestType.isCorrectType(externalContext))
-    {
-      // This will happen if the actionRequest was not ended before dispatching to the render
-      // request
-      throw new IllegalStateException("The previous action request was not ended.");
-    }
-    else
-    {
-      _LOG.fine("BeginRequest called multiple times for this request");
-    }
-  }
-
-  /**
-   * Cleans up the current configurator. This will execute the destroy method on all of the
-   * configurator services. Generally this will be called by Trinidad's context listener when the
-   * context is destroyed, but it may be used manually to allow the configurator to be
-   * re-initialized.
-   *
-   * Calling this method while the configurator is not initialized will not re-execute the destroy
-   * methods on the services.
-   *
-   * @see org.apache.myfaces.trinidad.config.Configurator#destroy()
-   */
-  @Override
-  public void destroy()
-  {
-    if (_initialized)
-    {
-      for (final Configurator config : _services)
-      {
-        try
-        {
-          config.destroy();
-        }
-        catch (final Throwable t)
-        {
-          // we always want to continue to destroy things, so log errors and continue
-          _LOG.severe(t);
-        }
-      }
-      _services = null;
-      _initialized = false;
-    }
-  }
-
-  /**
-   * Ends the currently begun request. It is important to note that this should be executed only
-   * once per physical request.
-   *
-   * @see org.apache.myfaces.trinidad.config.Configurator#endRequest(javax.faces.context.ExternalContext)
-   */
-  @Override
-  public void endRequest(final ExternalContext externalContext)
-  {
-    // do per virtual-request stuff
-    if (RequestType.getType(externalContext) != null)
-    {
-      if (!_isDisabled(externalContext))
-      {
-        final RequestType type = RequestType.getType(externalContext);
-
-        // Do not end services at the end of a portal action request
-        if (type != RequestType.PORTAL_ACTION)
-        {
-          _endConfiguratorServiceRequest(externalContext);
-        }
-        
-        _releaseRequestContext(externalContext);
-      }
-      RequestType.clearType(externalContext);
-    }
-  }
-
-  /**
-   * Returns an externalContext for this configurator and all of the configurator services. If this
-   * method is executed before {@link #beginRequest(ExternalContext)} then this method will call
-   * beginRequest(). It is important to note, however, that even though beginRequest does not need
-   * to be explicitly called, {{@link #endRequest(ExternalContext)} does need to be called when the
-   * request has completed or the contract to the configurators will be broken.
-   *
-   * @param externalContext
-   *          the ExternalContext object that should be wrapped.
-   *
-   * @return a decorated ExternalContext object
-   */
-  @Override
-  public ExternalContext getExternalContext(ExternalContext externalContext)
-  {
-    if (RequestType.getType(externalContext) == null)
-    {
-      beginRequest(externalContext);
-    }
-
-    if (!_isDisabled(externalContext))
-    {
-      // Wrap ExternalContexts
-      for (final Configurator config : _services)
-      {
-        externalContext = config.getExternalContext(externalContext);
-      }
-    }
-
-    return externalContext;
-  }
-
-  /**
-   * Initializes the global configurator and the configurator services. This method need not be
-   * called directly as it will be called from {@link #beginRequest(ExternalContext)} if needed. It
-   * is also possible to execute this method more then once, although if initialization has already
-   * happened then a call to this method will not do anything. To re-initialize this class, call
-   * {@link #destroy()} first and then call this method.
-   *
-   * @param externalContext
-   *          the externalContext needed to initialize this class
-   *
-   * @see org.apache.myfaces.trinidad.config.Configurator#init(javax.faces.context.ExternalContext)
-   */
-  @Override
-  public void init(final ExternalContext externalContext)
-  {
-    assert externalContext != null;
-
-    if (!_initialized)
-    {
-      _services = ClassLoaderUtils.getServices(Configurator.class.getName());
-
-      // Create a new RequestContextFactory is needed
-      if (RequestContextFactory.getFactory() == null)
-      {
-        RequestContextFactory.setFactory(new RequestContextFactoryImpl());
-      }
-
-      // Create a new SkinFactory if needed.
-      if (SkinFactory.getFactory() == null)
-      {
-        SkinFactory.setFactory(new SkinFactoryImpl());
-      }
-
-      // register the base skins
-      SkinUtils.registerBaseSkins();
-
-      for (final Configurator config : _services)
-      {
-        config.init(externalContext);
-      }
-
-      // after the 'services' filters are initialized, then register
-      // the skin extensions found in trinidad-skins.xml. This
-      // gives a chance to the 'services' filters to create more base
-      // skins that the skins in trinidad-skins.xml can extend.
-      SkinUtils.registerSkinExtensions(externalContext);
-
-      _initialized = true;
-    }
-    else
-    {
-      _LOG.warning("CONFIGURATOR_SERVICES_INITIALIZED");
-    }
-  }
-
-  /**
-   * @param externalContext
-   * @return
-   */
-  @SuppressWarnings("unchecked")
-  private void _attachRequestContext(final ExternalContext externalContext)
-  {
-    // If someone didn't release the RequestContext on an earlier request,
-    // then it'd still be around, and trying to create a new one
-    // would trigger an exception. We don't want to take down
-    // this thread for all eternity, so clean up after poorly-behaved code.
-    RequestContext context = RequestContext.getCurrentInstance();
-    if (context != null)
-    {
-      if (_LOG.isWarning())
-      {
-        _LOG.warning("REQUESTCONTEXT_NOT_PROPERLY_RELEASED");
-      }
-      context.release();
-    }
-
-    // See if we've got a cached RequestContext instance; if so,
-    // reattach it
-    final Object cachedRequestContext = externalContext.getRequestMap().get(
-        _REQUEST_CONTEXT);
-
-    // Catch both the null scenario and the
-    // RequestContext-from-a-different-classloader scenario
-    if (cachedRequestContext instanceof RequestContext)
-    {
-      context = (RequestContext) cachedRequestContext;
-      context.attach();
-    }
-    else
-    {
-      final RequestContextFactory factory = RequestContextFactory.getFactory();
-      assert factory != null;
-      context = factory.createContext(externalContext);
-      externalContext.getRequestMap().put(_REQUEST_CONTEXT, context);
-    }
-
-    assert RequestContext.getCurrentInstance() == context;
-  }
-  
-  private void _releaseRequestContext(final ExternalContext ec)
-  {
-    //If it's not a portal action, we should remove the cached request because
-    //well want to create a new one next request
-    if(RequestType.getType(ec) != RequestType.PORTAL_ACTION)
-    {
-      ec.getRequestMap().remove(_REQUEST_CONTEXT);
-    }
-    
-    final RequestContext context = RequestContext.getCurrentInstance();
-    if (context != null)
-    {
-      context.release();
-      assert RequestContext.getCurrentInstance() == null;
-    }    
-  }
-
-  private void _endConfiguratorServiceRequest(final ExternalContext ec)
-  {
-    // Physical request has now ended
-    // Clear the in-request flag
-    ec.getRequestMap().remove(_IN_REQUEST);
-    for (final Configurator config : _services)
-    {
-      config.endRequest(ec);
-    }
-  }
-
-  @SuppressWarnings("unchecked")
-  private void _startConfiguratorServiceRequest(final ExternalContext ec)
-  {
-    // Physical request has now begun
-    final boolean disabled = isConfiguratorServiceDisabled(ec);
-
-    // Tell whether the services were disabled when the requests had begun
-    ec.getRequestMap().put(_IN_REQUEST, disabled);
-
-    // If this hasn't been initialized then please initialize
-    for (final Configurator config : _services)
-    {
-      config.beginRequest(ec);
-    }
-  }
-
-  private boolean            _initialized;
-  private List<Configurator> _services;
-  static private final Map<ClassLoader, GlobalConfiguratorImpl> _CONFIGURATORS = new HashMap<ClassLoader, GlobalConfiguratorImpl>();
-  static private final String _IN_REQUEST    = GlobalConfiguratorImpl.class
-                                                         .getName()
-                                                         + ".IN_REQUEST";
-  static private final String _REQUEST_CONTEXT = GlobalConfiguratorImpl.class.getName()
-                                                         +".REQUEST_CONTEXT";
-  static private final TrinidadLogger _LOG  = TrinidadLogger.createTrinidadLogger(GlobalConfiguratorImpl.class);
-
-  private enum RequestType
-  {
-    PORTAL_ACTION,
-    PORTAL_RENDER,
-    SERVLET;
-
-    public static void clearType(final ExternalContext ec)
-    {
-      ec.getRequestMap().remove(_REQUEST_TYPE);
-    }
-
-    public static RequestType getType(final ExternalContext ec)
-    {
-      return (RequestType) ec.getRequestMap().get(_REQUEST_TYPE);
-    }
-
-    public static boolean isCorrectType(final ExternalContext ec)
-    {
-      return _findType(ec) == getType(ec);
-    }
-
-    @SuppressWarnings("unchecked")
-    public static void setType(final ExternalContext ec)
-    {
-      ec.getRequestMap().put(_REQUEST_TYPE, _findType(ec));
-    }
-
-    private static final RequestType _findType(final ExternalContext ec)
-    {
-      if (ExternalContextUtils.isPortlet(ec))
-      {
-        if (ExternalContextUtils.isAction(ec))
-        {
-          return PORTAL_ACTION;
-        }
-        else
-        {
-          return PORTAL_RENDER;
-        }
-      }
-      else
-      {
-        return SERVLET;
-      }
-    }
-
-    static private final String _REQUEST_TYPE = GlobalConfiguratorImpl.class.getName()
-                                                  + ".REQUEST_TYPE";
-  }
-}
+/*
+ *  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.
+ */
+
+package org.apache.myfaces.trinidadinternal.config;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.ExternalContext;
+
+import javax.servlet.ServletRequest;
+
+import javax.servlet.ServletRequestWrapper;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.myfaces.trinidad.config.Configurator;
+import org.apache.myfaces.trinidad.context.ExternalContextDecorator;
+import org.apache.myfaces.trinidad.context.RequestContext;
+import org.apache.myfaces.trinidad.context.RequestContextFactory;
+import org.apache.myfaces.trinidad.logging.TrinidadLogger;
+import org.apache.myfaces.trinidad.skin.SkinFactory;
+import org.apache.myfaces.trinidad.util.ClassLoaderUtils;
+import org.apache.myfaces.trinidadinternal.context.RequestContextFactoryImpl;
+import org.apache.myfaces.trinidadinternal.context.external.ServletCookieMap;
+import org.apache.myfaces.trinidadinternal.context.external.ServletRequestHeaderMap;
+import org.apache.myfaces.trinidadinternal.context.external.ServletRequestHeaderValuesMap;
+import org.apache.myfaces.trinidadinternal.context.external.ServletRequestMap;
+import org.apache.myfaces.trinidadinternal.context.external.ServletRequestParameterMap;
+import org.apache.myfaces.trinidadinternal.context.external.ServletRequestParameterValuesMap;
+import org.apache.myfaces.trinidadinternal.skin.SkinFactoryImpl;
+import org.apache.myfaces.trinidadinternal.skin.SkinUtils;
+import org.apache.myfaces.trinidadinternal.util.ExternalContextUtils;
+
+/**
+ * This is the implementation of the Trinidad's Global configurator. It provides the entry point for
+ * all other configurators. This class is responsible for enforcing the contract outlined by the
+ * Configurator abstract class, but allows a more "relaxed" implementation of the APIs called for by
+ * the Configurator class, making it more convenient to use ConfiguratorServices from within the
+ * Trinidad renderkit. Where appropriate, these differences will be documented for the benifit of
+ * the Trindad developer.
+ *
+ * @see org.apache.myfaces.trinidad.config.Configurator
+ * @version $Revision$ $Date$
+ */
+public class GlobalConfiguratorImpl extends Configurator
+{
+  /**
+   * Returns a GlobalConfigurator instance for the current context's class loader. The
+   * GlobalConfigurator is responsible for enforcing the contract on the other methods of this
+   * class. This means that if {@link #init(ExternalContext)} is called multiple times, the global
+   * configurator will call all subordinate configurators only once.
+   *
+   * Likewise, the GlobalConfigurator will return exceptions when the contract is expressly violated
+   * (like if {@link #getExternalContext(ExternalContext)} is called before a {{@link #beginRequest(ExternalContext)}.
+   *
+   * @return a GlobalConfigurator or <code>null</code> is one was unable to be obtained.
+   */
+  static public final GlobalConfiguratorImpl getInstance()
+  {
+    final ClassLoader loader = Thread.currentThread().getContextClassLoader();
+
+    if (loader == null)
+    {
+      _LOG.severe("CANNOT_FIND_CONTEXT_CLASS_LOADER");
+    }
+    else
+    {
+      synchronized (_CONFIGURATORS)
+      {
+        GlobalConfiguratorImpl config = _CONFIGURATORS.get(loader);
+        if (config == null)
+        {
+          try
+          {
+            config = new GlobalConfiguratorImpl();
+            _CONFIGURATORS.put(loader, config);
+          }
+          catch (final RuntimeException e)
+          {
+            // OC4J was not reporting these errors properly:
+            _LOG.severe(e);
+            throw e;
+          }
+          _LOG.fine("GlobalConfigurator has been created.");
+        }
+        return config;
+      }
+    }
+    return null;
+  }
+
+  /**
+   * Returns true if the request has not been stated for the current "virtual"
+   * request.  In the servlet environment this will be true after
+   * {@link #beginRequest(ExternalContext)} is executed and before
+   * {@link #endRequest(ExternalContext)} is executed.  This will generally
+   * happen once per request.  In the Portlet Environment, the request must be
+   * be started and ended at the beginning and end of both the actionRequest
+   * and the RenderRequest.
+   *
+   * @param ec
+   * @return
+   */
+  static public boolean isRequestStarted(final ExternalContext ec)
+  {
+    return (RequestType.getType(ec) != null);
+  }
+
+  /**
+   * Returns "true" if the services should be considered enabled or disabled.
+   *
+   * @param ec
+   * @return
+   */
+  static private final boolean _isDisabled(final ExternalContext ec)
+  {
+    final Boolean inRequest = (Boolean) ec.getRequestMap().get(_IN_REQUEST);
+
+    if (inRequest == null)
+    {
+      return isConfiguratorServiceDisabled(ec);
+    }
+    else
+    {
+      final boolean disabled = inRequest.booleanValue();
+      if (disabled != isConfiguratorServiceDisabled(ec))
+      {
+        _LOG
+            .warning("Configurator services were disabled after beginRequest was executed.  Cannot disable configurator services");
+      }
+
+      return disabled;
+    }
+  }
+
+  /**
+   * Private default constructor. Right now this class is not serializable. If serialization is
+   * required, we may wish to make this public. We really don't want people using this though.
+   */
+  private GlobalConfiguratorImpl()
+  {}
+
+  /**
+   * Executes the beginRequest methods of all of the configurator services. This method will also
+   * initizlize the configurator if it has not already been initialized, so there may be no need to
+   * call the {@link #init(ExternalContext)} method directly.
+   *
+   * This method also ensures that the requestContext is attached before the beginRequest methods
+   * are called, so there is no reason to initialize the request context before calling this method.
+   * In portal environments, it is important to execute this method once for each Portlet action and
+   * render request so that the requestContext may be properly initialized even though the
+   * underlying services will be called only once per physical request.
+   *
+   * @param externalContext
+   *          the externalContext to use to begin the request.
+   *
+   * @see org.apache.myfaces.trinidad.config.Configurator#beginRequest(javax.faces.context.ExternalContext)
+   */
+  @SuppressWarnings("unchecked") // TODO: remove this for Faces 1.2
+  @Override
+  public void beginRequest(final ExternalContext externalContext)
+  {
+    // asserts for debug which disappear in production
+    assert externalContext != null;
+
+    // Do per-virtual request stuff
+    if (RequestType.getType(externalContext) == null)
+    {
+      // RequestType may change in a portal environment. Make sure it's set up to enforce the
+      // contracts
+      RequestType.setType(externalContext);
+
+      // By contract, Configurators beginRequest is only called once per physical request.
+      // The globalConfigurator may be called multiple times, however, so we need to enforce
+      // the contract.
+      if (!_isDisabled(externalContext))
+      {
+        // If this hasn't been initialized then please initialize
+        if (!_initialized)
+        {
+          init(externalContext);
+        }
+
+        _attachRequestContext(externalContext);
+
+        if (externalContext.getRequestMap().get(_IN_REQUEST) == null)
+        {
+          _startConfiguratorServiceRequest(externalContext);
+        }
+      }
+      else
+      {
+        _LOG.fine("GlobalConfigurator: Configurators have been disabled for this request.");
+      }
+    }
+    else if (!RequestType.isCorrectType(externalContext))
+    {
+      // This will happen if the actionRequest was not ended before dispatching to the render
+      // request
+      throw new IllegalStateException("The previous action request was not ended.");
+    }
+    else
+    {
+      _LOG.fine("BeginRequest called multiple times for this request");
+    }
+  }
+
+  /**
+   * Cleans up the current configurator. This will execute the destroy method on all of the
+   * configurator services. Generally this will be called by Trinidad's context listener when the
+   * context is destroyed, but it may be used manually to allow the configurator to be
+   * re-initialized.
+   *
+   * Calling this method while the configurator is not initialized will not re-execute the destroy
+   * methods on the services.
+   *
+   * @see org.apache.myfaces.trinidad.config.Configurator#destroy()
+   */
+  @Override
+  public void destroy()
+  {
+    if (_initialized)
+    {
+      for (final Configurator config : _services)
+      {
+        try
+        {
+          config.destroy();
+        }
+        catch (final Throwable t)
+        {
+          // we always want to continue to destroy things, so log errors and continue
+          _LOG.severe(t);
+        }
+      }
+      _services = null;
+      _initialized = false;
+    }
+  }
+
+  /**
+   * Ends the currently begun request. It is important to note that this should be executed only
+   * once per physical request.
+   *
+   * @see org.apache.myfaces.trinidad.config.Configurator#endRequest(javax.faces.context.ExternalContext)
+   */
+  @Override
+  public void endRequest(final ExternalContext externalContext)
+  {
+    // do per virtual-request stuff
+    if (RequestType.getType(externalContext) != null)
+    {
+      if (!_isDisabled(externalContext))
+      {
+        final RequestType type = RequestType.getType(externalContext);
+
+        // Do not end services at the end of a portal action request
+        if (type != RequestType.PORTAL_ACTION)
+        {
+          _endConfiguratorServiceRequest(externalContext);
+        }
+        
+        _releaseRequestContext(externalContext);
+      }
+      RequestType.clearType(externalContext);
+    }
+  }
+
+  /**
+   * Returns an externalContext for this configurator and all of the configurator services. If this
+   * method is executed before {@link #beginRequest(ExternalContext)} then this method will call
+   * beginRequest(). It is important to note, however, that even though beginRequest does not need
+   * to be explicitly called, {{@link #endRequest(ExternalContext)} does need to be called when the
+   * request has completed or the contract to the configurators will be broken.
+   *
+   * @param externalContext
+   *          the ExternalContext object that should be wrapped.
+   *
+   * @return a decorated ExternalContext object
+   */
+  @Override
+  public ExternalContext getExternalContext(ExternalContext externalContext)
+  {
+    if (RequestType.getType(externalContext) == null)
+    {
+      beginRequest(externalContext);
+    }
+
+    if (!_isDisabled(externalContext))
+    {
+      if(!ExternalContextUtils.isPortlet(externalContext) && _isSetRequestBugPresent(externalContext))
+      {
+        //This handles bug 493 against the JSF-RI 1.2_03 and earlier.  If the bug
+        //is present in the current system, add a wrapper to fix it
+        
+        //TODO sobryan this is somewhat inefficient so should be removed when we
+        //are no longer dependant on JSF1.2_03 or earlier.  Still, we only wrap
+        //when we have to so it should be no biggy under normal circumstances.
+        externalContext = new ClearRequestExternalContext(externalContext);
+      }
+
+      // Wrap ExternalContexts
+      for (final Configurator config : _services)
+      {
+        externalContext = config.getExternalContext(externalContext);
+      }
+    }
+
+    return externalContext;
+  }
+
+  /**
+   * Initializes the global configurator and the configurator services. This method need not be
+   * called directly as it will be called from {@link #beginRequest(ExternalContext)} if needed. It
+   * is also possible to execute this method more then once, although if initialization has already
+   * happened then a call to this method will not do anything. To re-initialize this class, call
+   * {@link #destroy()} first and then call this method.
+   *
+   * @param externalContext
+   *          the externalContext needed to initialize this class
+   *
+   * @see org.apache.myfaces.trinidad.config.Configurator#init(javax.faces.context.ExternalContext)
+   */
+  @Override
+  public void init(final ExternalContext externalContext)
+  {
+    assert externalContext != null;
+
+    if (!_initialized)
+    {
+      _services = ClassLoaderUtils.getServices(Configurator.class.getName());
+
+      // Create a new RequestContextFactory is needed
+      if (RequestContextFactory.getFactory() == null)
+      {
+        RequestContextFactory.setFactory(new RequestContextFactoryImpl());
+      }
+
+      // Create a new SkinFactory if needed.
+      if (SkinFactory.getFactory() == null)
+      {
+        SkinFactory.setFactory(new SkinFactoryImpl());
+      }
+
+      // register the base skins
+      SkinUtils.registerBaseSkins();
+
+      for (final Configurator config : _services)
+      {
+        config.init(externalContext);
+      }
+
+      // after the 'services' filters are initialized, then register
+      // the skin extensions found in trinidad-skins.xml. This
+      // gives a chance to the 'services' filters to create more base
+      // skins that the skins in trinidad-skins.xml can extend.
+      SkinUtils.registerSkinExtensions(externalContext);
+
+      _initialized = true;
+    }
+    else
+    {
+      _LOG.warning("CONFIGURATOR_SERVICES_INITIALIZED");
+    }
+  }
+
+  /**
+   * @param externalContext
+   * @return
+   */
+  @SuppressWarnings("unchecked")
+  private void _attachRequestContext(final ExternalContext externalContext)
+  {
+    // If someone didn't release the RequestContext on an earlier request,
+    // then it'd still be around, and trying to create a new one
+    // would trigger an exception. We don't want to take down
+    // this thread for all eternity, so clean up after poorly-behaved code.
+    RequestContext context = RequestContext.getCurrentInstance();
+    if (context != null)
+    {
+      if (_LOG.isWarning())
+      {
+        _LOG.warning("REQUESTCONTEXT_NOT_PROPERLY_RELEASED");
+      }
+      context.release();
+    }
+
+    // See if we've got a cached RequestContext instance; if so,
+    // reattach it
+    final Object cachedRequestContext = externalContext.getRequestMap().get(
+        _REQUEST_CONTEXT);
+
+    // Catch both the null scenario and the
+    // RequestContext-from-a-different-classloader scenario
+    if (cachedRequestContext instanceof RequestContext)
+    {
+      context = (RequestContext) cachedRequestContext;
+      context.attach();
+    }
+    else
+    {
+      final RequestContextFactory factory = RequestContextFactory.getFactory();
+      assert factory != null;
+      context = factory.createContext(externalContext);
+      externalContext.getRequestMap().put(_REQUEST_CONTEXT, context);
+    }
+
+    assert RequestContext.getCurrentInstance() == context;
+  }
+  
+  private void _releaseRequestContext(final ExternalContext ec)
+  {
+    //If it's not a portal action, we should remove the cached request because
+    //well want to create a new one next request
+    if(RequestType.getType(ec) != RequestType.PORTAL_ACTION)
+    {
+      ec.getRequestMap().remove(_REQUEST_CONTEXT);
+    }
+    
+    final RequestContext context = RequestContext.getCurrentInstance();
+    if (context != null)
+    {
+      context.release();
+      assert RequestContext.getCurrentInstance() == null;
+    }    
+  }
+
+  private void _endConfiguratorServiceRequest(final ExternalContext ec)
+  {
+    // Physical request has now ended
+    // Clear the in-request flag
+    ec.getRequestMap().remove(_IN_REQUEST);
+    for (final Configurator config : _services)
+    {
+      config.endRequest(ec);
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  private void _startConfiguratorServiceRequest(final ExternalContext ec)
+  {
+    // Physical request has now begun
+    final boolean disabled = isConfiguratorServiceDisabled(ec);
+
+    // Tell whether the services were disabled when the requests had begun
+    ec.getRequestMap().put(_IN_REQUEST, disabled);
+
+    // If this hasn't been initialized then please initialize
+    for (final Configurator config : _services)
+    {
+      config.beginRequest(ec);
+    }
+  }
+  
+  static private boolean _isSetRequestBugPresent(ExternalContext ec)
+  {
+    // This first check is here in order to skip synchronization until 
+    // absolutely necessary.
+    if(!_sSetRequestBugTested)
+    {
+      synchronized(GlobalConfiguratorImpl.class)
+      {
+        //This second check is here in case a couple of things enter before the
+        //boolean is set.  This is only an exception case and will make it so
+        //the initialization code runs only once.
+        if(!_sSetRequestBugTested)
+        {
+          ServletRequest orig = (ServletRequest)ec.getRequest();
+          // Call getInitParameterMap() up front
+          ec.getInitParameterMap();
+          
+          ec.setRequest(new TestRequest(orig));
+          
+          _sHasSetRequestBug = !TestRequest.isTestParamPresent(ec);
+          _sSetRequestBugTested = true;
+          
+          ec.setRequest(orig);
+        }
+      }
+    }
+    
+    return _sHasSetRequestBug;
+  }
+  
+  // This handles an issue with the ExternalContext object prior to
+  // JSF1.2_04.
+  static private class ClearRequestExternalContext extends ExternalContextDecorator
+  {
+    private ExternalContext _ec;
+    private Map<String, Object>         _requestCookieMap;
+    private Map<String, String>         _requestHeaderMap;
+    private Map<String, String[]>       _requestHeaderValuesMap;
+    private Map<String, Object>         _requestMap;
+    private Map<String, String>         _requestParameterMap;
+    private Map<String, String[]>       _requestParameterValuesMap;
+    
+    public ClearRequestExternalContext(ExternalContext ec)
+    {
+      _ec = ec;
+    }
+    
+    @Override
+    protected ExternalContext getExternalContext()
+    {
+      return _ec;
+    }
+
+    @Override
+    public void setRequest(Object request)
+    {
+      super.setRequest(request);
+      
+      // And clear out any of the cached maps, since we should 
+      // go back and look in the map
+      _requestCookieMap = null;
+      _requestHeaderMap = null;
+      _requestHeaderValuesMap = null;
+      _requestMap = null;
+      _requestParameterMap = null;
+      _requestParameterValuesMap = null;
+    }
+    
+    @Override
+    public Map<String, Object> getRequestCookieMap()
+    {
+      _checkRequest();
+      if (_requestCookieMap == null)
+      {
+        
+        _requestCookieMap = new ServletCookieMap(_getHttpServletRequest());
+      }
+      return _requestCookieMap;
+    }
+
+    @Override
+    public Map<String, String> getRequestHeaderMap()
+    {
+      if (_requestHeaderMap == null)
+      {
+        _requestHeaderMap = new ServletRequestHeaderMap(_getHttpServletRequest());
+      }
+      return _requestHeaderMap;
+    }
+
+    @Override
+    public Map<String, String[]> getRequestHeaderValuesMap()
+    {
+      if (_requestHeaderValuesMap == null)
+      {
+        _requestHeaderValuesMap = new ServletRequestHeaderValuesMap(_getHttpServletRequest());
+      }
+      return _requestHeaderValuesMap;
+    }
+
+    @Override
+    public Map<String, Object> getRequestMap()
+    {
+      _checkRequest();
+      if (_requestMap == null)
+      {
+        _requestMap = new ServletRequestMap((ServletRequest)getRequest());
+      }
+      return _requestMap;
+    }
+
+    @Override
+    public Map<String, String> getRequestParameterMap()
+    {
+      _checkRequest();
+      if (_requestParameterMap == null)
+      {
+        _requestParameterMap = new ServletRequestParameterMap((ServletRequest)getRequest());
+      }
+      return _requestParameterMap;
+    }
+
+    @Override
+    public Map<String, String[]> getRequestParameterValuesMap()
+    {
+      _checkRequest();
+      if (_requestParameterValuesMap == null)
+      {
+        _requestParameterValuesMap = new ServletRequestParameterValuesMap((ServletRequest)getRequest());
+      }
+      return _requestParameterValuesMap;
+    }
+    
+    private void _checkRequest()
+    {
+      if(super.getRequest() == null)
+      {
+        throw new UnsupportedOperationException("Request is null on this context.");
+      }
+    }
+    
+    private HttpServletRequest _getHttpServletRequest()
+    {
+      _checkRequest();
+      if ( !(getRequest() instanceof HttpServletRequest))
+      {
+         throw new IllegalArgumentException("Only HttpServletRequest supported");
+      }
+      
+      return (HttpServletRequest)getRequest();
+    }
+  }
+  
+
+  private static volatile boolean _sSetRequestBugTested = false;
+  private static boolean _sHasSetRequestBug = false;
+
+  private boolean             _initialized;
+  private List<Configurator>  _services;
+  static private final Map<ClassLoader, GlobalConfiguratorImpl> _CONFIGURATORS =
+     new HashMap<ClassLoader, GlobalConfiguratorImpl>();
+  static private final String _IN_REQUEST    =
+     GlobalConfiguratorImpl.class.getName() 
+     + ".IN_REQUEST";
+  static private final String _REQUEST_CONTEXT =
+     GlobalConfiguratorImpl.class.getName()
+     + ".REQUEST_CONTEXT";
+
+    
+  private enum RequestType
+  {
+    PORTAL_ACTION,
+    PORTAL_RENDER,
+    SERVLET;
+
+    public static void clearType(final ExternalContext ec)
+    {
+      ec.getRequestMap().remove(_REQUEST_TYPE);
+    }
+
+    public static RequestType getType(final ExternalContext ec)
+    {
+      return (RequestType) ec.getRequestMap().get(_REQUEST_TYPE);
+    }
+
+    public static boolean isCorrectType(final ExternalContext ec)
+    {
+      return _findType(ec) == getType(ec);
+    }
+
+    @SuppressWarnings("unchecked")
+    public static void setType(final ExternalContext ec)
+    {
+      ec.getRequestMap().put(_REQUEST_TYPE, _findType(ec));
+    }
+
+    private static final RequestType _findType(final ExternalContext ec)
+    {
+      if (ExternalContextUtils.isPortlet(ec))
+      {
+        if (ExternalContextUtils.isAction(ec))
+        {
+          return PORTAL_ACTION;
+        }
+        else
+        {
+          return PORTAL_RENDER;
+        }
+      }
+      else
+      {
+        return SERVLET;
+      }
+    }
+
+    static private final String _REQUEST_TYPE = GlobalConfiguratorImpl.class.getName()
+                                                  + ".REQUEST_TYPE";
+  }
+  
+  static private class TestRequest extends ServletRequestWrapper
+  {
+    public TestRequest(ServletRequest request)
+    {
+      super(request);
+    }
+
+    @Override
+    public String getParameter(String string)
+    {
+      if(_TEST_PARAM.equals(string))
+      {
+        return "passed";
+      }
+      
+      return super.getParameter(string);
+    }
+    
+    static public final boolean isTestParamPresent(ExternalContext ec)
+    {
+      return ec.getRequestParameterMap().get(_TEST_PARAM) != null;
+    }
+    
+    static private String _TEST_PARAM = TestRequest.class.getName()+
+      ".TEST_PARAM";
+  }
+
+
+  static private final TrinidadLogger _LOG =
+    TrinidadLogger.createTrinidadLogger(GlobalConfiguratorImpl.class);
+}

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchResponseConfiguratorImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchResponseConfiguratorImpl.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchResponseConfiguratorImpl.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchResponseConfiguratorImpl.java Tue Aug  7 15:18:22 2007
@@ -29,7 +29,6 @@
 import javax.portlet.PortletRequestDispatcher;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
-import javax.servlet.ServletResponse;
 
 import org.apache.myfaces.trinidad.config.Configurator;
 import org.apache.myfaces.trinidad.context.ExternalContextDecorator;
@@ -48,28 +47,24 @@
   @Override
   public ExternalContext getExternalContext(ExternalContext externalContext)
   {
-    // TODO sobryan (dependency = JSF 1.2)
-    // For JSF 1.2, we can probably simply wrap the request objects and set them on
-    // the existing ExternalContext.
     if(!isApplied(externalContext))
     {
       if(ExternalContextUtils.isPortlet(externalContext))
       {
         if(!ExternalContextUtils.isAction(externalContext))
         {
-          apply(externalContext);
-          return new PortletExternalContext(externalContext);
+          externalContext.setResponse(new DispatchRenderResponse(externalContext));
         }
       }
       else
       {
-        apply(externalContext);
-        return new ServletExternalContext(externalContext);
+        externalContext.setResponse(new DispatchServletResponse(externalContext));
       }
-    }
 
+      apply(externalContext);
+    }
 
-    //return the origional
+    //return the original
     return externalContext;
   }
 
@@ -79,104 +74,6 @@
   {
     Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
     return (String) requestMap.get(__CONTENT_TYPE_KEY);
-  }
-
-  static private class ServletExternalContext extends ExternalContextDecorator
-  {
-    public ServletExternalContext(ExternalContext ec)
-    {
-      _ec = ec;
-    }
-
-    @Override
-    public Object getResponse()
-    {
-      if(_response == null)
-      {
-        _response = new DispatchServletResponse(_ec);
-      }
-
-      return _response;
-    }
-
-    @Override
-    protected ExternalContext getExternalContext()
-    {
-      return _ec;
-    }
-
-    private ServletResponse  _response;
-    private ExternalContext _ec;
-  }
-
-  static private class PortletExternalContext extends ExternalContextDecorator
-  {
-    public PortletExternalContext(ExternalContext ec)
-    {
-      _ec = ec;
-    }
-
-    @Override
-    public Object getContext()
-    {
-      return _getPortletContext();
-    }
-
-    @Override
-    public Object getResponse()
-    {
-      return _getRenderResponse();
-    }
-
-    @Override
-    public void dispatch(String path) throws IOException
-    {
-      final PortletRequestDispatcher requestDispatcher =
-        ((PortletContext)getContext()).getRequestDispatcher(path);
-      try
-      {
-        requestDispatcher.include((RenderRequest)getRequest(), (RenderResponse)getResponse());
-      }
-      catch (final PortletException e)
-      {
-        if (e.getMessage() != null)
-        {
-          throw new FacesException(e.getMessage(), e);
-        }
-        else
-        {
-          throw new FacesException(e);
-        }
-      }
-    }
-
-    @Override
-    protected ExternalContext getExternalContext()
-    {
-      return _ec;
-    }
-
-    private PortletContext _getPortletContext()
-    {
-      if(_context == null)
-      {
-        _context = new PortletContextWrapper((PortletContext)_ec.getContext());
-      }
-      return _context;
-    }
-
-    private RenderResponse _getRenderResponse()
-    {
-      if(_response == null)
-      {
-        _response = new DispatchRenderResponse(_ec);
-      }
-      return _response;
-    }
-
-    private ExternalContext _ec;
-    private RenderResponse _response;
-    private PortletContext _context;
   }
 
   /**

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/FileUploadConfiguratorImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/FileUploadConfiguratorImpl.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/FileUploadConfiguratorImpl.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/FileUploadConfiguratorImpl.java Tue Aug  7 15:18:22 2007
@@ -25,6 +25,10 @@
 import java.util.Map;
 
 import javax.faces.context.ExternalContext;
+
+import javax.portlet.ActionRequest;
+
+import javax.servlet.ServletRequest;
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.myfaces.trinidad.config.Configurator;
@@ -209,8 +213,10 @@
     if(!isApplied(externalContext))
     {
       if(!ExternalContextUtils.isPortlet(externalContext))
-      {
-        return new ServletUploadedExternalContext(externalContext, addedParams);
+      {  
+        externalContext.setRequest(new UploadRequestWrapper(
+            (HttpServletRequest)externalContext.getRequest(),
+            addedParams));        
       }
       else if(ExternalContextUtils.isAction(externalContext))
       {
@@ -220,8 +226,10 @@
          * RenderParameters.  This is a cool thing because subsequent
          * render requests will retain these parameters for us.
          */
-        return new PortletUploadedExternalContext(externalContext, addedParams);
+        externalContext.setRequest(new ActionUploadRequestWrapper(externalContext,
+           addedParams));
       }
+      apply(externalContext);        
     }
 
     //If we don't have any wrapped params or we have a render portal request,

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/DialogServiceImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/DialogServiceImpl.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/DialogServiceImpl.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/DialogServiceImpl.java Tue Aug  7 15:18:22 2007
@@ -24,10 +24,11 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.el.ValueExpression;
+
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
 import javax.faces.render.RenderKit;
 
 import org.apache.myfaces.trinidad.context.RequestContext;
@@ -213,8 +214,9 @@
     FacesContext context = _getFacesContext();
     if (TrinidadFilterImpl.isExecutingDialogReturn(context))
     {
-      Map<String, Object> parameterMap = context.getExternalContext().getRequestParameterMap();
-      Object returnParam = parameterMap.get(_RETURN_PARAM);
+      Map<String, String> parameterMap =
+        context.getExternalContext().getRequestParameterMap();
+      String returnParam = parameterMap.get(_RETURN_PARAM);
       if (returnParam == null)
         return null;
 
@@ -464,9 +466,9 @@
   @SuppressWarnings("unchecked")
   private void _executeBindings(FacesContext context, UIComponent component)
   {
-    ValueBinding binding = component.getValueBinding("binding");
-    if (binding != null)
-      binding.setValue(context, component);
+    ValueExpression expression = component.getValueExpression("binding");
+    if (expression != null)
+      expression.setValue(context.getELContext(), component);
 
     Iterator<UIComponent> kids = component.getFacetsAndChildren();
     while (kids.hasNext())

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/FacesContextFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/FacesContextFactoryImpl.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/FacesContextFactoryImpl.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/FacesContextFactoryImpl.java Tue Aug  7 15:18:22 2007
@@ -22,6 +22,8 @@
 import java.util.Iterator;
 import java.util.Map;
 
+import javax.el.ELContext;
+
 import javax.faces.application.Application;
 import javax.faces.application.FacesMessage;
 import javax.faces.component.UIViewRoot;
@@ -231,6 +233,11 @@
       _base.release();
     }
     
+    public ELContext getELContext()
+    {
+      return _base.getELContext();
+    }
+
     private final FacesContext    _base;
     private final ExternalContext _external;
     // An Object, not a String, so that FindBugs won't complain

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java Tue Aug  7 15:18:22 2007
@@ -505,6 +505,17 @@
     }
   }
 
+  /**
+   * Returns the set of partial targets related to a given UIComponent.
+   */
+  @Override
+  public Set<UIComponent> getPartialTargets(UIComponent source)
+  {
+    HashSet<UIComponent> set = new HashSet<UIComponent>();
+    _addPartialTargets(set, source);
+    return set;    
+  }
+  
   @Override
   public void addPartialTriggerListeners
     (UIComponent listener,
@@ -754,6 +765,33 @@
 
     return _partialListeners;
   }
+
+  //
+  // Recursively builds up the set of partial targets of
+  // a given component
+  //
+  private void _addPartialTargets(
+    Set<UIComponent> sofar, UIComponent from)
+  {
+    Map<UIComponent, Set<UIComponent>> pl = _getPartialListeners();
+    Set<UIComponent> listeners = pl.get(from);
+    if (listeners == null)
+      return;
+    
+    for (UIComponent target : listeners)
+    {
+      // If we haven't encountered this target yet, add
+      // it, and continue recursively.
+      if (!sofar.contains(target))
+      {
+        sofar.add(target);
+        _addPartialTargets(sofar, target);
+      }
+    }
+  }
+
+
+
 
   static private UIComponent _findRelativeComponent(
     UIComponent from,

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletCookieMap.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletCookieMap.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletCookieMap.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletCookieMap.java Tue Aug  7 15:18:22 2007
@@ -28,9 +28,9 @@
  *
  * @version $Revision: 278654 $ $Date: 2005-09-04 18:32:35 -0600 (Sun, 04 Sep 2005) $
  */
-class ServletCookieMap extends AbstractAttributeMap<String, Object>
+public class ServletCookieMap extends AbstractAttributeMap<String, Object>
 {
-  ServletCookieMap(final HttpServletRequest httpServletRequest)
+  public ServletCookieMap(final HttpServletRequest httpServletRequest)
   {
     _httpServletRequest = httpServletRequest;
   }

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletExternalContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletExternalContext.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletExternalContext.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletExternalContext.java Tue Aug  7 15:18:22 2007
@@ -20,7 +20,8 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.lang.reflect.Method;
+import java.io.UnsupportedEncodingException;
+
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.security.Principal;
@@ -73,52 +74,8 @@
     }
 
     if (_httpServletRequest != null)
-    {
-      // HACK: MultipartWrapper scrambles the servletPath for some reason in Tomcat 4.1.29 embedded
-      // in JBoss 3.2.3!?
-      // (this was reported by frederic.auge [frederic.auge@laposte.net])
-      _requestServletPath = _httpServletRequest.getServletPath();
-      _requestPathInfo = _httpServletRequest.getPathInfo();
-
-      // try to set character encoding as described in section 2.5.2.2 of JSF 1.1 spec
-      // we have to use reflection as method setCharacterEncoding is not supported Servlet API <=
-      // 2.3
-      try
-      {
-        if (_setCharacterEncodingMethod != null &&
-            !Boolean.TRUE.equals(_httpServletRequest.getAttribute(_CHAR_ENCODING_CALLED)))
-        {
-          // Only invoke this once, no matter how many times we create
-          // the ServletExternalContext
-          _httpServletRequest.setAttribute(_CHAR_ENCODING_CALLED, Boolean.TRUE);
-          final String contentType = _httpServletRequest.getHeader("Content-Type");
-
-          String characterEncoding = _lookupCharacterEncoding(contentType);
-
-          if (characterEncoding == null)
-          {
-            final HttpSession session = _httpServletRequest.getSession(false);
-
-            if (session != null)
-            {
-              characterEncoding = (String) session.getAttribute(ViewHandler.CHARACTER_ENCODING_KEY);
-            }
-
-            if (characterEncoding != null)
-            {
-              _setCharacterEncodingMethod
-                  .invoke(servletRequest, new Object[] { characterEncoding });
-            }
-          }
-        }
-      }
-      catch (final Exception e)
-      {
-        if (_LOG.isWarning())
-        {
-          _LOG.warning("FAIL_SET_CHARACTER_ENCODING", e);
-        }
-      }
+    {      
+      _initHttpServletRequest();
     }
   }
 
@@ -514,6 +471,83 @@
     }
   }
 
+  @Override
+  public String getRequestCharacterEncoding()
+  {
+    _checkRequest();
+    return _servletRequest.getCharacterEncoding();
+  }
+
+  @Override
+  public String getRequestContentType()
+  {
+    _checkRequest();
+    return _servletRequest.getContentType();
+  }
+
+  @Override
+  public String getResponseCharacterEncoding()
+  {
+    _checkResponse();
+    return _servletResponse.getCharacterEncoding();
+  }
+
+  @Override
+  public String getResponseContentType()
+  {
+    _checkResponse();
+    return _servletResponse.getContentType();
+  }
+
+  @Override
+  public void setRequest(Object object)
+  {
+    _servletRequest = (ServletRequest) object;
+    if (object instanceof HttpServletRequest)
+    {
+      _httpServletRequest = (HttpServletRequest) object;
+      _initHttpServletRequest();
+    }
+    else
+    {
+      _httpServletRequest = null;
+    }
+    
+    // And clear out any of the cached maps, since we should 
+    // go back and look in the map
+    _requestCookieMap = null;
+    _requestHeaderMap = null;
+    _requestHeaderValuesMap = null;
+    _requestMap = null;
+    _requestParameterMap = null;
+    _requestParameterValuesMap = null;
+  }
+
+  @Override
+  public void setRequestCharacterEncoding(String string) throws UnsupportedEncodingException
+  {
+    _checkRequest();
+    _servletRequest.setCharacterEncoding(string);
+  }
+
+  @Override
+  public void setResponse(Object object)
+  {
+    _servletResponse = (ServletResponse) object;
+    if (_servletResponse instanceof HttpServletResponse)
+      _httpServletResponse = (HttpServletResponse) object;
+    else
+      _httpServletResponse = null;
+  }
+
+  @Override
+  public void setResponseCharacterEncoding(String string)
+  {
+    _checkResponse();
+    _servletResponse.setCharacterEncoding(string);
+  }
+
+  
   public void release()
   {
     _servletContext = null;
@@ -598,6 +632,16 @@
     return characterEncoding;
   }
 
+  private void _initHttpServletRequest()
+  {
+    // TODO: is this necessary still?
+    // HACK: MultipartWrapper scrambles the servletPath for some reason in Tomcat 4.1.29 embedded
+    // in JBoss 3.2.3!?
+    // (this was reported by frederic.auge [frederic.auge@laposte.net])
+    _requestServletPath = _httpServletRequest.getServletPath();
+    _requestPathInfo = _httpServletRequest.getPathInfo();
+  }
+
   private Map<String, Object>         _applicationMap;
   private HttpServletRequest          _httpServletRequest;
   private HttpServletResponse         _httpServletResponse;
@@ -614,24 +658,10 @@
   private ServletRequest              _servletRequest;
   private ServletResponse             _servletResponse;
   private Map<String, Object>         _sessionMap;
-  private static final String         _INIT_PARAMETER_MAP_ATTRIBUTE = ServletInitParameterMap.class
-                                                                       .getName();
+  private static final String         _INIT_PARAMETER_MAP_ATTRIBUTE =
+      ServletInitParameterMap.class.getName();
   private static final String         _CHAR_ENCODING_CALLED = 
     ServletExternalContext.class.getName() + ".CHAR_ENCODING_CALLED";
-  private static final TrinidadLogger _LOG                          = TrinidadLogger
-                                                                       .createTrinidadLogger(ServletExternalContext.class);
-  private static Method               _setCharacterEncodingMethod   = null;
-  static
-  {
-    try
-    {
-      _setCharacterEncodingMethod = ServletRequest.class.getMethod("setCharacterEncoding",
-          new Class[] { String.class });
-    }
-    catch (final Exception e)
-    {
-      _LOG.warning("REQUEST_CHARACTER_ENCODING_DIABLED");
-      _LOG.warning("FAIL_OBTAIN_SERVLETREQUEST_METHOD", e);
-    }
-  }
+  private static final TrinidadLogger _LOG
+      = TrinidadLogger.createTrinidadLogger(ServletExternalContext.class);
 }

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestHeaderMap.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestHeaderMap.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestHeaderMap.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestHeaderMap.java Tue Aug  7 15:18:22 2007
@@ -27,9 +27,9 @@
  *
  * @version $Revision: 278654 $ $Date: 2005-09-04 18:32:35 -0600 (Sun, 04 Sep 2005) $
  */
-class ServletRequestHeaderMap extends AbstractAttributeMap<String, String>
+public class ServletRequestHeaderMap extends AbstractAttributeMap<String, String>
 {
-  ServletRequestHeaderMap(final HttpServletRequest httpServletRequest)
+  public ServletRequestHeaderMap(final HttpServletRequest httpServletRequest)
   {
     _httpServletRequest = httpServletRequest;
   }

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestHeaderValuesMap.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestHeaderValuesMap.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestHeaderValuesMap.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletRequestHeaderValuesMap.java Tue Aug  7 15:18:22 2007
@@ -32,9 +32,9 @@
  *
  * @version $Revision: 167257 $ $Date: 2004-10-13 05:51:02 -0600 (Wed, 13 Oct 2004) $
  */
-class ServletRequestHeaderValuesMap extends AbstractAttributeMap<String, String[]>
+public class ServletRequestHeaderValuesMap extends AbstractAttributeMap<String, String[]>
 {
-  ServletRequestHeaderValuesMap(final HttpServletRequest httpServletRequest)
+  public ServletRequestHeaderValuesMap(final HttpServletRequest httpServletRequest)
   {
     _httpServletRequest = httpServletRequest;
   }

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java Tue Aug  7 15:18:22 2007
@@ -35,7 +35,7 @@
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
-import javax.faces.el.ValueBinding;
+import javax.el.ValueExpression;
 
 import org.apache.myfaces.trinidad.context.RenderingContext;
 import org.apache.myfaces.trinidad.convert.ClientConverter;
@@ -112,10 +112,10 @@
       UIComponent component, String strValue, Object value)
   {
     assert value != null;
-    ValueBinding binding = component.getValueBinding("value");
-    if (binding != null)
+    ValueExpression expression = component.getValueExpression("value");
+    if (expression != null)
     {
-      Class<?> expectedType = binding.getType(context);
+      Class<?> expectedType = expression.getType(context.getELContext());
       // Sometimes the type might be null, if it cannot be determined:
       if ((expectedType != null)
           && (!expectedType.isAssignableFrom(value.getClass())))
@@ -162,10 +162,8 @@
     if (clientId != null)
     {
       // =-=AEW Only if Javascript...
-      // -= Simon Lessard =-
-      // FIXME: JSF 1.2 specifies <String, Object>
-      Map<Object, Object> requestMap = context.getExternalContext()
-          .getRequestMap();
+      Map<String, Object> requestMap =
+        context.getExternalContext().getRequestMap();
 
       // this fetch could be at the place where we append, but has been
       // moved ahead to optimize use of StringBuilder
@@ -546,7 +544,7 @@
 
   // RenderingContext key indicating the _dateFormat object
   // has been created
-  private static final Object _PATTERN_WRITTEN_KEY = "org.apache.myfaces.trinidadinternal.convert.DateTimeConverter._PATTERN_WRITTEN";
+  private static final String _PATTERN_WRITTEN_KEY = "org.apache.myfaces.trinidadinternal.convert.DateTimeConverter._PATTERN_WRITTEN";
 
   // String indicating that NO_JS_PATTERN is available
   private static final String _NO_JS_PATTERN = new String();

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/AccessKeyPropertyTagRule.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/AccessKeyPropertyTagRule.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/AccessKeyPropertyTagRule.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/AccessKeyPropertyTagRule.java Tue Aug  7 15:18:22 2007
@@ -22,7 +22,6 @@
 import java.lang.reflect.Method;
 
 import com.sun.facelets.FaceletContext;
-import com.sun.facelets.el.LegacyValueBinding;
 import com.sun.facelets.tag.Metadata;
 import com.sun.facelets.tag.MetadataTarget;
 import com.sun.facelets.tag.MetaRule;
@@ -31,8 +30,6 @@
 
 import javax.el.ValueExpression;
 
-import javax.faces.el.ValueBinding;
-
 import org.apache.myfaces.trinidad.bean.FacesBean;
 import org.apache.myfaces.trinidad.bean.PropertyKey;
 import org.apache.myfaces.trinidad.component.UIXComponent;
@@ -65,7 +62,6 @@
     public void applyMetadata(FaceletContext ctx, Object instance)
     {
       ValueExpression expr = _attribute.getValueExpression(ctx, String.class);
-      ValueBinding vb = new LegacyValueBinding(expr);
       UIXComponent uixcomp = (UIXComponent) instance;
       FacesBean bean = uixcomp.getFacesBean();
       PropertyKey mainKey = bean.getType().findKey(_mainMethodName);
@@ -77,7 +73,7 @@
       if (accessKeyKey == null)
         throw new TagAttributeException(_attribute,
                                         "No support for 'accessKey' attribute on " + instance);
-      VirtualAttributeUtils.setAccessKeyAttribute(bean, vb, mainKey, accessKeyKey);
+      VirtualAttributeUtils.setAccessKeyAttribute(bean, expr, mainKey, accessKeyKey);
     }
 
     private final String       _mainMethodName;

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/FileDownloadActionListenerTag.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/FileDownloadActionListenerTag.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/FileDownloadActionListenerTag.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/FileDownloadActionListenerTag.java Tue Aug  7 15:18:22 2007
@@ -33,8 +33,6 @@
 
 import com.sun.facelets.FaceletContext;
 import com.sun.facelets.FaceletException;
-import com.sun.facelets.el.LegacyMethodBinding;
-import com.sun.facelets.el.LegacyValueBinding;
 import com.sun.facelets.tag.TagAttribute;
 import com.sun.facelets.tag.TagConfig;
 import com.sun.facelets.tag.TagHandler;
@@ -54,7 +52,6 @@
     _method = getRequiredAttribute("method");
   }
 
-  @SuppressWarnings("deprecation")
   public void apply(FaceletContext faceletContext,
           UIComponent parent) throws IOException, FacesException, FaceletException, ELException
   {
@@ -69,8 +66,8 @@
         {
           ValueExpression valueExp = _filename.getValueExpression(faceletContext,
                                                                   Object.class);
-          listener.setValueBinding(FileDownloadActionListener.FILENAME_KEY,
-                                   new LegacyValueBinding(valueExp));
+          listener.setValueExpression(FileDownloadActionListener.FILENAME_KEY,
+                                     valueExp);
         }
       }
 
@@ -82,15 +79,15 @@
         {
           ValueExpression valueExp = _contentType.getValueExpression(faceletContext,
                                                                   Object.class);
-          listener.setValueBinding(FileDownloadActionListener.CONTENT_TYPE_KEY,
-                                   new LegacyValueBinding(valueExp));
+          listener.setValueExpression(FileDownloadActionListener.CONTENT_TYPE_KEY,
+                                      valueExp);
         }
       }
       
       MethodExpression me = _method.getMethodExpression(faceletContext,
                                                         Object.class,
                                                         _METHOD_PARAMS);
-      listener.setMethod(new LegacyMethodBinding(me));
+      listener.setMethod(me);
 
       ActionSource actionSource = (ActionSource)parent;
       actionSource.addActionListener(listener);

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/ReturnActionListenerTag.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/ReturnActionListenerTag.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/ReturnActionListenerTag.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/ReturnActionListenerTag.java Tue Aug  7 15:18:22 2007
@@ -59,9 +59,8 @@
       if (_value != null)
       {
         ValueExpression valueExp = _value.getValueExpression(faceletContext, Object.class);
-        listener.setValueBinding(ReturnActionListener.VALUE_KEY, new LegacyValueBinding(valueExp));
+        listener.setValueExpression(ReturnActionListener.VALUE_KEY,valueExp);
       }
-
 
       actionSource.addActionListener(listener);
     }

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/SetActionListenerTag.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/SetActionListenerTag.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/SetActionListenerTag.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/SetActionListenerTag.java Tue Aug  7 15:18:22 2007
@@ -27,14 +27,12 @@
 
 import com.sun.facelets.FaceletContext;
 import com.sun.facelets.FaceletException;
-import com.sun.facelets.el.LegacyValueBinding;
 import com.sun.facelets.tag.TagAttribute;
 import com.sun.facelets.tag.TagConfig;
 import com.sun.facelets.tag.TagHandler;
 import com.sun.facelets.tag.jsf.ComponentSupport;
 
 /**
- * @todo it should be removed after we consume JSF1.2.
  */
 public class SetActionListenerTag extends TagHandler
 {
@@ -46,7 +44,6 @@
     _to   = getRequiredAttribute("to");
   }
   
-  @SuppressWarnings("deprecation")
   public void apply(FaceletContext faceletContext,
                     UIComponent parent) throws FaceletException, ELException
   {
@@ -59,10 +56,8 @@
                                                             Object.class);
       ActionSource actionSource= (ActionSource) parent;
       SetActionListener listener = new SetActionListener();
-      listener.setValueBinding("from",
-                               new LegacyValueBinding(fromExpression));
-      listener.setValueBinding("to",
-                               new LegacyValueBinding(toExpression));
+      listener.setValueExpression("from", fromExpression);
+      listener.setValueExpression("to", toExpression);
       actionSource.addActionListener(listener);
     }
   }

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/TrinidadListenersTagRule.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/TrinidadListenersTagRule.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/TrinidadListenersTagRule.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/TrinidadListenersTagRule.java Tue Aug  7 15:18:22 2007
@@ -41,9 +41,9 @@
 {
   public static final MetaRule Instance = new TrinidadListenersTagRule();
 
-  private static class ListenerPropertyMetadata extends Metadata
+  private static class ListenerMBPropertyMetadata extends Metadata
   {
-    public ListenerPropertyMetadata(Method method, TagAttribute attribute, Class[] paramList)
+    public ListenerMBPropertyMetadata(Method method, TagAttribute attribute, Class[] paramList)
     {
       _method = method;
       _attribute = attribute;
@@ -76,6 +76,42 @@
     private final TagAttribute _attribute;
     private       Class[]      _paramList;
   }
+
+  private static class ListenerMEPropertyMetadata extends Metadata
+  {
+    public ListenerMEPropertyMetadata(Method method, TagAttribute attribute, Class[] paramList)
+    {
+      _method = method;
+      _attribute = attribute;
+      _paramList = paramList;
+    }
+    
+    @Override
+    @SuppressWarnings("deprecation")
+    public void applyMetadata(FaceletContext ctx, Object instance)
+    {
+      MethodExpression expr =
+        _attribute.getMethodExpression(ctx, null, _paramList);
+      
+      try
+      {
+        _method.invoke(instance,
+                       new Object[]{expr});
+      }
+      catch (InvocationTargetException e)
+      {
+        throw new TagAttributeException(_attribute, e.getCause());
+      }
+      catch (Exception e)
+      {
+        throw new TagAttributeException(_attribute, e);
+      }
+    }
+
+    private final Method       _method;
+    private final TagAttribute _attribute;
+    private       Class[]      _paramList;
+  }
    
 
   @Override
@@ -84,7 +120,11 @@
      TagAttribute attribute,
      MetadataTarget meta)
   {
-    if ((meta.getPropertyType(name) == MethodBinding.class) &&
+    Class metaType = meta.getPropertyType(name);
+    boolean isMethodBinding = (metaType == MethodBinding.class);
+    boolean isMethodExpression = (metaType == MethodExpression.class);
+
+    if ((isMethodBinding || isMethodExpression) &&
         name.endsWith("Listener"))
     {
       // OK, we're trying to call setFooListener()
@@ -112,8 +152,12 @@
           return null;
 
         // And go
-        return new ListenerPropertyMetadata(m, attribute,
-                                            new Class[]{eventClass});
+        if (isMethodBinding)
+          return new ListenerMBPropertyMetadata(m, attribute,
+                                                new Class[]{eventClass});
+        else
+          return new ListenerMEPropertyMetadata(m, attribute,
+                                                new Class[]{eventClass});
       }
     }
     return null;

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/HtmlResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/HtmlResponseWriter.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/HtmlResponseWriter.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/HtmlResponseWriter.java Tue Aug  7 15:18:22 2007
@@ -81,6 +81,7 @@
   public void flush() throws IOException
   {
     _closeStartIfNecessary();
+    _out.flush();
   }
 
 

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/IndentingResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/IndentingResponseWriter.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/IndentingResponseWriter.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/IndentingResponseWriter.java Tue Aug  7 15:18:22 2007
@@ -112,6 +112,16 @@
    * Writes a String, escaped properly for this method.
    */
   @Override
+  public void writeText(Object text, UIComponent component, String componentPropertyName) throws IOException
+  {
+    _seeIfJustEndedElement();
+    super.writeText(text, component, componentPropertyName);
+  }
+
+  /**
+   * Writes a String, escaped properly for this method.
+   */
+  @Override
   public void writeText(Object text, String componentPropertyName) throws IOException
   {
     _seeIfJustEndedElement();

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/ResponseWriterDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/ResponseWriterDecorator.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/ResponseWriterDecorator.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/ResponseWriterDecorator.java Tue Aug  7 15:18:22 2007
@@ -126,6 +126,15 @@
     getResponseWriter().writeComment(comment);
   }
 
+
+
+  @Override
+  public void writeText(Object text, UIComponent component, 
+                        String propertyName)
+    throws IOException
+  {
+    getResponseWriter().writeText(text, component, propertyName);
+  }
   
   @Override
   public void writeText(Object text, String componentPropertyName) throws IOException

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/XhtmlResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/XhtmlResponseWriter.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/XhtmlResponseWriter.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/XhtmlResponseWriter.java Tue Aug  7 15:18:22 2007
@@ -84,6 +84,7 @@
   public void flush() throws IOException
   {
     _closeStartIfNecessary();
+   _out.flush();
   }
 
 

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/ItemNode.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/ItemNode.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/ItemNode.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/ItemNode.java Tue Aug  7 15:18:22 2007
@@ -73,7 +73,7 @@
     {
       // Value of action is EL method binding, so we 
       // need to evaluate it
-      value = (String)MenuUtils.getBoundValue(value);
+      value = MenuUtils.getBoundValue(value, String.class);
     }
 
     // Post me as the selected Node for the request
@@ -112,7 +112,7 @@
     {
       // Value of action is EL method binding, so we 
       // need to evaluate it
-      value = (String)MenuUtils.getBoundValue(value);
+      value = MenuUtils.getBoundValue(value, String.class);
       setActionListener(value);
     }
 
@@ -149,7 +149,7 @@
     {
       // Value of action is EL method binding, so we 
       // need to evaluate it
-      value = (String)MenuUtils.getBoundValue(value);
+      value = MenuUtils.getBoundValue(value, String.class);
       setLaunchListener(value);
     }
 
@@ -186,7 +186,7 @@
     {
       // Value of action is EL method binding, so we 
       // need to evaluate it
-      value = (String)MenuUtils.getBoundValue(value);
+      value = MenuUtils.getBoundValue(value, String.class);
       setReturnListener(value);
     }
 
@@ -372,7 +372,7 @@
     {
       // Value of action is EL method binding, so we 
       // need to evaluate it
-      value = (String)MenuUtils.getBoundValue(value);
+      value = MenuUtils.getBoundValue(value, String.class);
     }
 
     // Appending nodeId to URL so that we can identify the node
@@ -408,7 +408,7 @@
     {
       // Value of destination is EL value binding, so we 
       // need to evaluate it
-      value = (String)MenuUtils.getBoundValue(value);
+      value = MenuUtils.getBoundValue(value, String.class);
       setTargetFrame(value);
     }
      

Modified: myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java?view=diff&rev=563680&r1=563679&r2=563680
==============================================================================
--- myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java (original)
+++ myfaces/trinidad/branches/1.2.2-branch/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java Tue Aug  7 15:18:22 2007
@@ -252,7 +252,8 @@
         // into another menu model.
         _saveModelData();        
 
-        XMLMenuModel menuModel = (XMLMenuModel)MenuUtils.getBoundValue(expr);
+        XMLMenuModel menuModel = (XMLMenuModel)MenuUtils.getBoundValue(expr,
+                                                              Object.class);
         
         // Now must pop the values cause we are back to the parent
         // model.