You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2011/06/30 01:33:01 UTC

svn commit: r1141328 - /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/

Author: lu4242
Date: Wed Jun 29 23:33:00 2011
New Revision: 1141328

URL: http://svn.apache.org/viewvc?rev=1141328&view=rev
Log:
Add ViewNotFoundException (MYFACES-3188 NPE in org.apache.myfaces.lifecycle.RenderResponseExecutor.execute and MYFACES-3189 NavigationHandler: navigation to nonexistent view after ViewExpired throws NPE)

Added:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/ViewNotFoundException.java
Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/ApplyRequestValuesExecutor.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/InvokeApplicationExecutor.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/ProcessValidationsExecutor.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/RenderResponseExecutor.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/UpdateModelValuesExecutor.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/ApplyRequestValuesExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/ApplyRequestValuesExecutor.java?rev=1141328&r1=1141327&r2=1141328&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/ApplyRequestValuesExecutor.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/ApplyRequestValuesExecutor.java Wed Jun 29 23:33:00 2011
@@ -31,6 +31,10 @@ class ApplyRequestValuesExecutor extends
 {
     public boolean execute(FacesContext facesContext)
     {
+        if (facesContext.getViewRoot() == null)
+        {
+            throw new ViewNotFoundException("A view is required to execute "+facesContext.getCurrentPhaseId());
+        }
         facesContext.getViewRoot().processDecodes(facesContext);
         return false;
     }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/InvokeApplicationExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/InvokeApplicationExecutor.java?rev=1141328&r1=1141327&r2=1141328&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/InvokeApplicationExecutor.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/InvokeApplicationExecutor.java Wed Jun 29 23:33:00 2011
@@ -31,6 +31,10 @@ class InvokeApplicationExecutor extends 
 {
     public boolean execute(FacesContext facesContext)
     {
+        if (facesContext.getViewRoot() == null)
+        {
+            throw new ViewNotFoundException("A view is required to execute "+facesContext.getCurrentPhaseId());
+        }
         facesContext.getViewRoot().processApplication(facesContext);
         return false;
     }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/ProcessValidationsExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/ProcessValidationsExecutor.java?rev=1141328&r1=1141327&r2=1141328&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/ProcessValidationsExecutor.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/ProcessValidationsExecutor.java Wed Jun 29 23:33:00 2011
@@ -31,6 +31,10 @@ class ProcessValidationsExecutor extends
 {
     public boolean execute(FacesContext facesContext)
     {
+        if (facesContext.getViewRoot() == null)
+        {
+            throw new ViewNotFoundException("A view is required to execute "+facesContext.getCurrentPhaseId());
+        }
         facesContext.getViewRoot().processValidators(facesContext);
         return false;
     }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/RenderResponseExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/RenderResponseExecutor.java?rev=1141328&r1=1141327&r2=1141328&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/RenderResponseExecutor.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/RenderResponseExecutor.java Wed Jun 29 23:33:00 2011
@@ -51,6 +51,11 @@ class RenderResponseExecutor extends Pha
         String viewId;
         String newViewId;
         
+        if (facesContext.getViewRoot() == null)
+        {
+            throw new ViewNotFoundException("A view is required to execute "+facesContext.getCurrentPhaseId());
+        }
+        
         try
         {
             // do-while, because the view might change in PreRenderViewEvent-listeners

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/UpdateModelValuesExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/UpdateModelValuesExecutor.java?rev=1141328&r1=1141327&r2=1141328&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/UpdateModelValuesExecutor.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/UpdateModelValuesExecutor.java Wed Jun 29 23:33:00 2011
@@ -31,6 +31,10 @@ class UpdateModelValuesExecutor extends 
 {
     public boolean execute(FacesContext facesContext)
     {
+        if (facesContext.getViewRoot() == null)
+        {
+            throw new ViewNotFoundException("A view is required to execute "+facesContext.getCurrentPhaseId());
+        }
         facesContext.getViewRoot().processUpdates(facesContext);
         return false;
     }

Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/ViewNotFoundException.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/ViewNotFoundException.java?rev=1141328&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/ViewNotFoundException.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/lifecycle/ViewNotFoundException.java Wed Jun 29 23:33:00 2011
@@ -0,0 +1,61 @@
+/*
+ * 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.lifecycle;
+
+import javax.faces.FacesException;
+
+/**
+ * This exception is thrown when a view is not present before start
+ * one of the following phases: APPLY_REQUEST_VALUES, PROCESS_VALIDATIONS,
+ * INVOKE_APPLICATION, UPDATE_MODEL_VALUES, RENDER_RESPONSE.
+
+ * 
+ * @author Leonardo Uribe
+ * @since 2.0.8
+ *
+ */
+public class ViewNotFoundException extends FacesException
+{
+    
+    /**
+     * 
+     */
+    private static final long serialVersionUID = -537576038024094272L;
+
+    public ViewNotFoundException()
+    {
+        super();
+    }
+
+    public ViewNotFoundException(String message, Throwable cause)
+    {
+        super(message, cause);
+    }
+
+    public ViewNotFoundException(String message)
+    {
+        super(message);
+    }
+
+    public ViewNotFoundException(Throwable cause)
+    {
+        super(cause);
+    }
+
+}