myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r918973 - in /myfaces/extensions/cdi/branches/branch_for_jsf_1_2: examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/ jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/ jee-...
Date Thu, 04 Mar 2010 12:52:37 GMT
Author: gpetracek
Date: Thu Mar  4 12:52:37 2010
New Revision: 918973

URL: http://svn.apache.org/viewvc?rev=918973&view=rev
Log:
EXTCDI-12 initial draft

Added:
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/JsfLifecyclePhaseInformation.java
Modified:
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/HelloCodiBean.java
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/JsfRequestLifecycleBroadcaster.java

Modified: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/HelloCodiBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/HelloCodiBean.java?rev=918973&r1=918972&r2=918973&view=diff
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/HelloCodiBean.java
(original)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/examples/hello_myfaces-codi/src/main/java/org/apache/myfaces/blank/HelloCodiBean.java
Thu Mar  4 12:52:37 2010
@@ -20,6 +20,7 @@
 
 import org.apache.myfaces.extensions.cdi.core.api.listener.phase.annotation.View;
 import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.PhaseId;
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.JsfLifecyclePhaseInformation;
 import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation.AfterPhase;
 import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation.BeforePhase;
 import org.apache.myfaces.extensions.cdi.javaee.jsf.api.project.stage.JsfProjectStage;
@@ -40,6 +41,9 @@
     @Inject
     private FacesContext facesContext;
 
+    @Inject
+    private JsfLifecyclePhaseInformation phaseInformation;
+
     private String text;
 
     //no restriction via @View -> invoked before rendering any view
@@ -74,12 +78,20 @@
         addGlobalMessage("preAny in phase:" + event.getPhaseId());
     }
 
-    public void preAnyFiltered(@Observes @BeforePhase(PhaseId.ANY_PHASE) PhaseEvent event)
+    public void preAnyFiltered1(@Observes @BeforePhase(PhaseId.ANY_PHASE) PhaseEvent event)
     {
         if (event.getPhaseId().equals(javax.faces.event.PhaseId.APPLY_REQUEST_VALUES) ||
                 event.getPhaseId().equals(javax.faces.event.PhaseId.UPDATE_MODEL_VALUES))
         {
-            addGlobalMessage("preAnyFiltered in phase:" + event.getPhaseId());
+            addGlobalMessage("preAnyFiltered1 in phase:" + event.getPhaseId());
+        }
+    }
+
+    public void preAnyFiltered2(@Observes @AfterPhase(PhaseId.ANY_PHASE) PhaseEvent event)
+    {
+        if (this.phaseInformation.isProcessValidationsPhase() || this.phaseInformation.isUpdateModelValuesPhase())
+        {
+            addGlobalMessage("preAnyFiltered2 in phase:" + event.getPhaseId());
         }
     }
 

Added: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/JsfLifecyclePhaseInformation.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/JsfLifecyclePhaseInformation.java?rev=918973&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/JsfLifecyclePhaseInformation.java
(added)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/api/listener/phase/JsfLifecyclePhaseInformation.java
Thu Mar  4 12:52:37 2010
@@ -0,0 +1,34 @@
+/*
+ * 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.cdi.javaee.jsf.api.listener.phase;
+
+public interface JsfLifecyclePhaseInformation
+{
+    boolean isRestoreViewPhase();
+
+    boolean isApplyRequestValuesPhase();
+
+    boolean isProcessValidationsPhase();
+
+    boolean isUpdateModelValuesPhase();
+
+    boolean isInvokeApplicationPhase();
+
+    boolean isRenderResponsePhase();
+}

Modified: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/JsfRequestLifecycleBroadcaster.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/JsfRequestLifecycleBroadcaster.java?rev=918973&r1=918972&r2=918973&view=diff
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/JsfRequestLifecycleBroadcaster.java
(original)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/JsfRequestLifecycleBroadcaster.java
Thu Mar  4 12:52:37 2010
@@ -19,22 +19,25 @@
 package org.apache.myfaces.extensions.cdi.javaee.jsf.impl.listener.phase;
 
 import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.PhaseId;
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.JsfLifecyclePhaseInformation;
 import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation.AfterPhase;
 import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation.BeforePhase;
 
-import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Event;
 import javax.faces.event.PhaseEvent;
 import javax.inject.Inject;
 import javax.inject.Named;
 import java.lang.annotation.Annotation;
 
-@ApplicationScoped
+@RequestScoped
 @Named
-public class JsfRequestLifecycleBroadcaster
+public class JsfRequestLifecycleBroadcaster implements JsfLifecyclePhaseInformation
 {
     static final String BEAN_NAME = "jsfRequestLifecycleBroadcaster";
 
+    private javax.faces.event.PhaseId facesPhaseId;
+
     @Inject
     private Event<PhaseEvent> phaseEvent;
 
@@ -48,6 +51,8 @@
 
     void broadcastBeforeEvent(PhaseEvent phaseEvent)
     {
+        this.facesPhaseId = phaseEvent.getPhaseId();
+
         this.phaseEvent.select(createAnnotationLiteral(phaseEvent.getPhaseId(), true)).fire(phaseEvent);
         this.beforeAnyPhaseEvent.fire(phaseEvent);
     }
@@ -92,4 +97,37 @@
             }
         };
     }
+
+    /*
+     * implementation of JsfLifecyclePhaseInformation methods
+     */
+    public boolean isRestoreViewPhase()
+    {
+        return javax.faces.event.PhaseId.RESTORE_VIEW.equals(this.facesPhaseId);
+    }
+
+    public boolean isApplyRequestValuesPhase()
+    {
+        return javax.faces.event.PhaseId.APPLY_REQUEST_VALUES.equals(this.facesPhaseId);
+    }
+
+    public boolean isProcessValidationsPhase()
+    {
+        return javax.faces.event.PhaseId.PROCESS_VALIDATIONS.equals(this.facesPhaseId);
+    }
+
+    public boolean isUpdateModelValuesPhase()
+    {
+        return javax.faces.event.PhaseId.UPDATE_MODEL_VALUES.equals(this.facesPhaseId);
+    }
+
+    public boolean isInvokeApplicationPhase()
+    {
+        return javax.faces.event.PhaseId.INVOKE_APPLICATION.equals(this.facesPhaseId);
+    }
+
+    public boolean isRenderResponsePhase()
+    {
+        return javax.faces.event.PhaseId.RENDER_RESPONSE.equals(this.facesPhaseId);
+    }
 }



Mime
View raw message