myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r698776 - in /myfaces/extensions/validator/branches/jsf_1.1: component-support/trinidad-support/ component-support/trinidad-support/src/main/config/ component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/in...
Date Wed, 24 Sep 2008 23:37:32 GMT
Author: gpetracek
Date: Wed Sep 24 16:37:32 2008
New Revision: 698776

URL: http://svn.apache.org/viewvc?rev=698776&view=rev
Log:
trinidad render-kit adapter

Added:
    myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/initializer/trinidad/ExtValTrinidadRenderKit.java
    myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/initializer/trinidad/ExtValTrinidadValidationPhaseListener.java
Removed:
    myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/initializer/trinidad/rendering/TrinidadRenderingContextInitializer.java
Modified:
    myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/pom.xml
    myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/config/faces-config.xml
    myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/initializer/trinidad/InitTrinidadModulePhaseListener.java
    myfaces/extensions/validator/branches/jsf_1.1/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValValidationPhaseListener.java

Modified: myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/pom.xml?rev=698776&r1=698775&r2=698776&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/pom.xml
(original)
+++ myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/pom.xml
Wed Sep 24 16:37:32 2008
@@ -50,6 +50,13 @@
             <scope>compile</scope>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.myfaces.trinidad</groupId>
+            <artifactId>trinidad-impl</artifactId>
+            <version>${trinidad.version}</version>
+            <scope>compile</scope>
+        </dependency>
+
 <!--
         <dependency>
             <groupId>org.apache.myfaces.extensions.validator</groupId>

Modified: myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/config/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/config/faces-config.xml?rev=698776&r1=698775&r2=698776&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/config/faces-config.xml
(original)
+++ myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/config/faces-config.xml
Wed Sep 24 16:37:32 2008
@@ -28,4 +28,10 @@
             org.apache.myfaces.extensions.validator.initializer.trinidad.InitTrinidadModulePhaseListener
         </phase-listener>
     </lifecycle>
+
+    <lifecycle>
+        <phase-listener>
+            org.apache.myfaces.extensions.validator.initializer.trinidad.ExtValTrinidadValidationPhaseListener
+        </phase-listener>
+    </lifecycle>
 </faces-config>

Added: myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/initializer/trinidad/ExtValTrinidadRenderKit.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/initializer/trinidad/ExtValTrinidadRenderKit.java?rev=698776&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/initializer/trinidad/ExtValTrinidadRenderKit.java
(added)
+++ myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/initializer/trinidad/ExtValTrinidadRenderKit.java
Wed Sep 24 16:37:32 2008
@@ -0,0 +1,81 @@
+/*
+ * 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.extensions.validator.initializer.trinidad;
+
+import org.apache.myfaces.extensions.validator.core.ExtValRenderKit;
+import org.apache.myfaces.trinidadinternal.renderkit.RenderKitDecorator;
+import org.apache.myfaces.trinidadinternal.renderkit.core.CoreRenderKit;
+
+import javax.faces.render.RenderKit;
+import javax.faces.render.Renderer;
+import javax.faces.render.ResponseStateManager;
+import javax.faces.context.ResponseWriter;
+import javax.faces.context.ResponseStream;
+import java.io.Writer;
+import java.io.OutputStream;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class ExtValTrinidadRenderKit extends RenderKitDecorator
+{
+    protected ExtValRenderKit extValRenderKit;
+
+    public static final String ID = "EXTVAL_TRINIDAD_RENDERKIT";
+
+    public ExtValTrinidadRenderKit(RenderKit wrapped)
+    {
+        this.extValRenderKit = new ExtValRenderKit(wrapped);
+    }
+
+    @Override
+    public void addRenderer(String family, String rendererType, Renderer renderer)
+    {
+        this.extValRenderKit.addRenderer(family, rendererType, renderer);
+    }
+
+    @Override
+    public Renderer getRenderer(String family, String rendererType)
+    {
+        return this.extValRenderKit.getRenderer(family, rendererType);
+    }
+
+    @Override
+    public ResponseStateManager getResponseStateManager()
+    {
+        return this.extValRenderKit.getResponseStateManager();
+    }
+
+    @Override
+    public ResponseWriter createResponseWriter(Writer writer, String s, String s1)
+    {
+        return this.extValRenderKit.createResponseWriter(writer, s, s1);
+    }
+
+    @Override
+    public ResponseStream createResponseStream(OutputStream outputStream)
+    {
+        return this.extValRenderKit.createResponseStream(outputStream);
+    }
+
+    protected String getDecoratedRenderKitId()
+    {
+        return CoreRenderKit.BASE_RENDER_KIT_ID;
+    }
+}

Added: myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/initializer/trinidad/ExtValTrinidadValidationPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/initializer/trinidad/ExtValTrinidadValidationPhaseListener.java?rev=698776&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/initializer/trinidad/ExtValTrinidadValidationPhaseListener.java
(added)
+++ myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/initializer/trinidad/ExtValTrinidadValidationPhaseListener.java
Wed Sep 24 16:37:32 2008
@@ -0,0 +1,66 @@
+/*
+ * 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.extensions.validator.initializer.trinidad;
+
+import javax.faces.FactoryFinder;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class ExtValTrinidadValidationPhaseListener implements PhaseListener
+{
+    public void afterPhase(PhaseEvent event)
+    {
+    }
+
+    public void beforePhase(PhaseEvent event)
+    {
+        if(event.getPhaseId() != PhaseId.APPLY_REQUEST_VALUES && event.getPhaseId()
!= PhaseId.RENDER_RESPONSE)
+        {
+            return;
+        }
+
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+
+        RenderKitFactory renderKitFactory = (RenderKitFactory)
+            FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+
+        String renderKitId = facesContext.getViewRoot().getRenderKitId();
+
+        if(ExtValTrinidadRenderKit.ID.equals(renderKitId))
+        {
+            return;
+        }
+
+        RenderKit renderKit = renderKitFactory.getRenderKit(FacesContext.getCurrentInstance(),
renderKitId);
+        renderKitFactory.addRenderKit(ExtValTrinidadRenderKit.ID, new ExtValTrinidadRenderKit(renderKit));
+        facesContext.getViewRoot().setRenderKitId(ExtValTrinidadRenderKit.ID);
+    }
+
+    public PhaseId getPhaseId()
+    {
+        return PhaseId.RENDER_RESPONSE;
+    }
+}

Modified: myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/initializer/trinidad/InitTrinidadModulePhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/initializer/trinidad/InitTrinidadModulePhaseListener.java?rev=698776&r1=698775&r2=698776&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/initializer/trinidad/InitTrinidadModulePhaseListener.java
(original)
+++ myfaces/extensions/validator/branches/jsf_1.1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/initializer/trinidad/InitTrinidadModulePhaseListener.java
Wed Sep 24 16:37:32 2008
@@ -19,12 +19,18 @@
 package org.apache.myfaces.extensions.validator.initializer.trinidad;
 
 import org.apache.myfaces.extensions.validator.core.AbstractStartupConfigListener;
+import org.apache.myfaces.extensions.validator.core.ExtValValidationPhaseListener;
 import org.apache.myfaces.extensions.validator.initializer.trinidad.component.TrinidadComponentInitializer;
-import org.apache.myfaces.extensions.validator.initializer.trinidad.rendering.TrinidadRenderingContextInitializer;
 import org.apache.myfaces.extensions.validator.internal.Priority;
 import org.apache.myfaces.extensions.validator.internal.ToDo;
 import org.apache.myfaces.extensions.validator.util.ExtValUtils;
 
+import javax.faces.lifecycle.LifecycleFactory;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.event.PhaseListener;
+import javax.faces.FactoryFinder;
+import java.util.Iterator;
+
 /**
  * @author Gerhard Petracek
  */
@@ -33,8 +39,35 @@
     @ToDo(value = Priority.MEDIUM, description = "web.xml parameter to deactivate it")
     protected void init()
     {
-        ExtValUtils.addRenderingContextInitializer(new TrinidadRenderingContextInitializer());
+        deregisterExtValValidationPhaseListener();
+        initTrinidadSupport();
+    }
+
+    private void deregisterExtValValidationPhaseListener()
+    {
+        LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
+            .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+
+        String currentId;
+        Lifecycle currentLifecycle;
+        Iterator lifecycleIds = lifecycleFactory.getLifecycleIds();
 
+        while (lifecycleIds.hasNext())
+        {
+            currentId = (String) lifecycleIds.next();
+            currentLifecycle = lifecycleFactory.getLifecycle(currentId);
+            for(PhaseListener currentPhaseListener : currentLifecycle.getPhaseListeners())
+            {
+                if(currentPhaseListener instanceof ExtValValidationPhaseListener)
+                {
+                    currentLifecycle.removePhaseListener(currentPhaseListener);
+                }
+            }
+        }
+    }
+
+    private void initTrinidadSupport()
+    {
         String deactivateClientSideValidation = WebXmlParameter.DEACTIVATE_CLIENT_SIDE_TRINIDAD_VALIDATION;
 
         if(deactivateClientSideValidation == null || !deactivateClientSideValidation.equalsIgnoreCase("true"))
@@ -42,4 +75,4 @@
             ExtValUtils.addComponentInitializer(new TrinidadComponentInitializer());
         }
     }
-}
\ No newline at end of file
+}

Modified: myfaces/extensions/validator/branches/jsf_1.1/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValValidationPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/jsf_1.1/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValValidationPhaseListener.java?rev=698776&r1=698775&r2=698776&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/jsf_1.1/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValValidationPhaseListener.java
(original)
+++ myfaces/extensions/validator/branches/jsf_1.1/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValValidationPhaseListener.java
Wed Sep 24 16:37:32 2008
@@ -48,6 +48,12 @@
             FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
 
         String renderKitId = facesContext.getViewRoot().getRenderKitId();
+
+        if(ExtValRenderKit.ID.equals(renderKitId))
+        {
+            return;
+        }
+
         RenderKit renderKit = renderKitFactory.getRenderKit(FacesContext.getCurrentInstance(),
renderKitId);
         renderKitFactory.addRenderKit(ExtValRenderKit.ID, new ExtValRenderKit(renderKit));
         facesContext.getViewRoot().setRenderKitId(ExtValRenderKit.ID);



Mime
View raw message