You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-commits@incubator.apache.org by aw...@apache.org on 2006/05/26 18:15:14 UTC

svn commit: r409710 - in /incubator/adffaces/trunk/adf-faces/adf-faces-impl/src: main/java/org/apache/myfaces/adfinternal/skin/ main/java/org/apache/myfaces/adfinternal/webapp/ test/java/org/apache/myfaces/adfinternal/renderkit/

Author: awiner
Date: Fri May 26 11:15:13 2006
New Revision: 409710

URL: http://svn.apache.org/viewvc?rev=409710&view=rev
Log:
Apply patch for ADFFACES-10: in adf-faces-skins.xml you can't extend skins defined in AdfFacesFilterImpl 'service' filters.

Modified:
    incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/skin/SkinUtils.java
    incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/webapp/AdfFacesFilterImpl.java
    incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/test/java/org/apache/myfaces/adfinternal/renderkit/RenderKitBootstrap.java

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/skin/SkinUtils.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/skin/SkinUtils.java?rev=409710&r1=409709&r2=409710&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/skin/SkinUtils.java (original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/skin/SkinUtils.java Fri May 26 11:15:13 2006
@@ -63,13 +63,36 @@
 {
 
   /**
-   * Register the base skins and any skin extensions found in the
+   * Register the base skins with the SkinFactory.
+   * Make sure the SkinFactory.getFactory() does not return null before
+   * calling this method.
+   */
+  static public void registerBaseSkins()
+  {
+
+    SkinFactory skinFactory = SkinFactory.getFactory();
+
+    // skinFactory should be non-null when this is called since it is
+    // initiated in the AdfFacesFilterImpl, but in case it isn't do this
+    if (skinFactory == null)
+    {
+      SkinFactory.setFactory(new SkinFactoryImpl());
+      skinFactory = SkinFactory.getFactory();
+    }
+
+    _registerAdfFacesSkins(skinFactory);
+  }
+  
+  /**
+   * Register any custom skin extensions found in the
    * adf-faces-skins.xml file with the SkinFactory.
+   * 
    * Make sure the SkinFactory.getFactory() does not return null before
    * calling this method.
+   * You should call registerBaseSkins() before calling this method.
    * @param context ServletContext, used to get the adf-faces-skins.xml file.
    */
-  static public void registerSkins(
+  static public void registerSkinExtensions(
     ServletContext context)
   {
 
@@ -82,8 +105,6 @@
       SkinFactory.setFactory(new SkinFactoryImpl());
       skinFactory = SkinFactory.getFactory();
     }
-
-    _registerAdfFacesSkins(skinFactory);
 
     _registerSkinExtensions(context, skinFactory);
 

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/webapp/AdfFacesFilterImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/webapp/AdfFacesFilterImpl.java?rev=409710&r1=409709&r2=409710&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/webapp/AdfFacesFilterImpl.java (original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/webapp/AdfFacesFilterImpl.java Fri May 26 11:15:13 2006
@@ -128,14 +128,21 @@
     if (SkinFactory.getFactory() == null)
       SkinFactory.setFactory(new SkinFactoryImpl());
 
-    // register the skins
-    SkinUtils.registerSkins(_servletContext);
+    // register the base skins
+    SkinUtils.registerBaseSkins();
     
     _filters = ClassLoaderUtils.getServices(AdfFacesFilterImpl.class.getName());
     for(Filter f:_filters)
     {
       f.init(filterConfig);
     }
+    // after the 'services' filters are initialized, then register
+    // the skin extensions found in adf-faces-skins.xml. This
+    // gives a chance to the 'services' filters to create more base
+    // skins that the skins in adf-faces-skins.xml can extend.
+    SkinUtils.registerSkinExtensions(_servletContext);
+
+    
   }
 
   public void destroy()

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/test/java/org/apache/myfaces/adfinternal/renderkit/RenderKitBootstrap.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/test/java/org/apache/myfaces/adfinternal/renderkit/RenderKitBootstrap.java?rev=409710&r1=409709&r2=409710&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/test/java/org/apache/myfaces/adfinternal/renderkit/RenderKitBootstrap.java (original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/test/java/org/apache/myfaces/adfinternal/renderkit/RenderKitBootstrap.java Fri May 26 11:15:13 2006
@@ -13,165 +13,165 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.apache.myfaces.adfinternal.renderkit;
-
-import org.xml.sax.SAXException;
-
-import javax.faces.FactoryFinder;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.render.RenderKit;
-import javax.faces.render.RenderKitFactory;
-
-import java.io.IOException;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.myfaces.adf.context.Agent;
-
-import org.apache.myfaces.adfinternal.agent.AgentImpl;
-import org.apache.myfaces.adfinternal.agent.AgentFactoryImpl;
-
-import org.apache.myfaces.adfinternal.renderkit.core.CoreRenderKit;
-
-import org.apache.myfaces.adfinternal.skin.SkinFactory;
-import org.apache.myfaces.adfinternal.skin.SkinFactoryImpl;
-import org.apache.myfaces.adfinternal.skin.SkinUtils;
-
-public class RenderKitBootstrap
-{
-  static public UIViewRoot createUIViewRoot(MFacesContext context)
-  {
-    UIViewRoot root = new UIViewRoot();
-    root.setRenderKitId("org.apache.myfaces.adf.core");
-    root.setViewId("/test-view-id.jspx");
-    root.setLocale(context.getLocale());
-    return root;
-  }
-    
-
-  public FacesConfigInfo getFacesConfigInfo()
-  {
-    return _facesConfigInfo;
-  }
-
-  static public Agent getGeckoAgent()
-  {
-    return _geckoAgent;
-  }
-
-  static public Agent getIEAgent()
-  {
-    return _ieAgent;
-  }
-
-  static public Agent getSafariAgent()
-  {
-    return _safariAgent;
-  }
-
-  static public Agent getPocketPCAgent()
-  {
-    return _pocketPCAgent;
-  }
-
-  static public RenderKit getRenderKit(FacesContext context)
-  {
-    RenderKitFactory factory = (RenderKitFactory)
-      FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
-
-    String renderKitId = null;
-    if (context.getViewRoot() != null)
-      renderKitId = context.getViewRoot().getRenderKitId();
-    if (renderKitId == null)
-      renderKitId = "org.apache.myfaces.adf.core";
-
-    RenderKit renderKit = factory.getRenderKit(context,renderKitId);
-    if (renderKit == null)
-      throw new IllegalStateException("Could not create renderKit " + renderKitId);
-
-    return renderKit;
-  }
-
-  static public void clearFactories()
-  {
-    FactoryFinder.releaseFactories();
-  }
-
-  static public void setFactories(FacesConfigInfo info)
-  {
-    FactoryFinder.releaseFactories();
-    FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
-                             MRenderKitFactory.class.getName());
-    FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
-                             CoreRenderKitFactory.class.getName());
-    RenderKitFactory rkFactory = (RenderKitFactory)
-      FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
-    rkFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT,
-                           new BasicHtmlRenderKit());
-    if (info != null)
-    {
-      for (String rkId : info.getRenderKits().keySet())
-      {
-        rkFactory.addRenderKit(rkId, info.getRenderKits().get(rkId));
-      }
-    }
-
-    // Set up the SkinFactory
-    if (SkinFactory.getFactory() == null)
-    {
-      SkinFactory.setFactory(new SkinFactoryImpl());
-      
-      // register the skins 
-      // =-=AEW Because we're not passing a "ServletContext", we can't
-      // find any custom skins
-      SkinUtils.registerSkins(null);
-    }
-  }
-
-
-  public void init() throws IOException, SAXException
-  {
-    // Set up the Basic HTML RenderKit and core factories
-    setFactories(null);
-    _facesConfigInfo = new FacesConfigInfo();
-    _facesConfigInfo.load("META-INF/faces-config.xml");
-    clearFactories();
-
-
-    _facesConfigInfo.registerComponents(MApplication.sharedInstance());
-    _facesConfigInfo.registerConverters(MApplication.sharedInstance());
-  }
-
-  static private void _createAgents()
-  {
-    AgentFactoryImpl factory = new AgentFactoryImpl();
-    _geckoAgent = factory.createAgent("Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20050207 Firefox/1.0.1",
-                        null);
-    _ieAgent = factory.createAgent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)",
-                                   null);
-
-    // Give a Safari 2.0 agent
-    _safariAgent = factory.createAgent("Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/412 (KHTML, like Gecko) Safari/412",
-                                   null);
-
-    // I think this is PocketPC 2003
-    _pocketPCAgent = factory.createAgent("Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; MSN Companion 2.0; 800x600; Compaq)",
-                                   null);
-  }
-
-  private FacesConfigInfo _facesConfigInfo;
-  private CoreRenderKit   _coreRenderKit;
-
-  static private Agent           _geckoAgent;
-  static private Agent           _ieAgent;
-  static private Agent           _safariAgent;
-  static private Agent           _pocketPCAgent;
-
-  static
-  {
-    _createAgents();
-  }
-}
-
+package org.apache.myfaces.adfinternal.renderkit;
+
+import org.xml.sax.SAXException;
+
+import javax.faces.FactoryFinder;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+
+import java.io.IOException;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.myfaces.adf.context.Agent;
+
+import org.apache.myfaces.adfinternal.agent.AgentImpl;
+import org.apache.myfaces.adfinternal.agent.AgentFactoryImpl;
+
+import org.apache.myfaces.adfinternal.renderkit.core.CoreRenderKit;
+
+import org.apache.myfaces.adfinternal.skin.SkinFactory;
+import org.apache.myfaces.adfinternal.skin.SkinFactoryImpl;
+import org.apache.myfaces.adfinternal.skin.SkinUtils;
+
+public class RenderKitBootstrap
+{
+  static public UIViewRoot createUIViewRoot(MFacesContext context)
+  {
+    UIViewRoot root = new UIViewRoot();
+    root.setRenderKitId("org.apache.myfaces.adf.core");
+    root.setViewId("/test-view-id.jspx");
+    root.setLocale(context.getLocale());
+    return root;
+  }
+
+
+  public FacesConfigInfo getFacesConfigInfo()
+  {
+    return _facesConfigInfo;
+  }
+
+  static public Agent getGeckoAgent()
+  {
+    return _geckoAgent;
+  }
+
+  static public Agent getIEAgent()
+  {
+    return _ieAgent;
+  }
+
+  static public Agent getSafariAgent()
+  {
+    return _safariAgent;
+  }
+
+  static public Agent getPocketPCAgent()
+  {
+    return _pocketPCAgent;
+  }
+
+  static public RenderKit getRenderKit(FacesContext context)
+  {
+    RenderKitFactory factory = (RenderKitFactory)
+      FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+
+    String renderKitId = null;
+    if (context.getViewRoot() != null)
+      renderKitId = context.getViewRoot().getRenderKitId();
+    if (renderKitId == null)
+      renderKitId = "org.apache.myfaces.adf.core";
+
+    RenderKit renderKit = factory.getRenderKit(context,renderKitId);
+    if (renderKit == null)
+      throw new IllegalStateException("Could not create renderKit " + renderKitId);
+
+    return renderKit;
+  }
+
+  static public void clearFactories()
+  {
+    FactoryFinder.releaseFactories();
+  }
+
+  static public void setFactories(FacesConfigInfo info)
+  {
+    FactoryFinder.releaseFactories();
+    FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
+                             MRenderKitFactory.class.getName());
+    FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
+                             CoreRenderKitFactory.class.getName());
+    RenderKitFactory rkFactory = (RenderKitFactory)
+      FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+    rkFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT,
+                           new BasicHtmlRenderKit());
+    if (info != null)
+    {
+      for (String rkId : info.getRenderKits().keySet())
+      {
+        rkFactory.addRenderKit(rkId, info.getRenderKits().get(rkId));
+      }
+    }
+
+    // Set up the SkinFactory
+    if (SkinFactory.getFactory() == null)
+    {
+      SkinFactory.setFactory(new SkinFactoryImpl());
+
+      // register the base skins
+      // =-=AEW Because we don't have a "ServletContext", we can't
+      // find any custom skins
+      SkinUtils.registerBaseSkins();
+    }
+  }
+
+
+  public void init() throws IOException, SAXException
+  {
+    // Set up the Basic HTML RenderKit and core factories
+    setFactories(null);
+    _facesConfigInfo = new FacesConfigInfo();
+    _facesConfigInfo.load("META-INF/faces-config.xml");
+    clearFactories();
+
+
+    _facesConfigInfo.registerComponents(MApplication.sharedInstance());
+    _facesConfigInfo.registerConverters(MApplication.sharedInstance());
+  }
+
+  static private void _createAgents()
+  {
+    AgentFactoryImpl factory = new AgentFactoryImpl();
+    _geckoAgent = factory.createAgent("Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20050207 Firefox/1.0.1",
+                        null);
+    _ieAgent = factory.createAgent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)",
+                                   null);
+
+    // Give a Safari 2.0 agent
+    _safariAgent = factory.createAgent("Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/412 (KHTML, like Gecko) Safari/412",
+                                   null);
+
+    // I think this is PocketPC 2003
+    _pocketPCAgent = factory.createAgent("Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; MSN Companion 2.0; 800x600; Compaq)",
+                                   null);
+  }
+
+  private FacesConfigInfo _facesConfigInfo;
+  private CoreRenderKit   _coreRenderKit;
+
+  static private Agent           _geckoAgent;
+  static private Agent           _ieAgent;
+  static private Agent           _safariAgent;
+  static private Agent           _pocketPCAgent;
+
+  static
+  {
+    _createAgents();
+  }
+}
+