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 2013/02/08 00:47:18 UTC
svn commit: r1443794 -
/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java
Author: lu4242
Date: Thu Feb 7 23:47:18 2013
New Revision: 1443794
URL: http://svn.apache.org/r1443794
Log:
MYFACES-3674 Implement f:viewAction (fix lifecycle activation)
Modified:
myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java
Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java?rev=1443794&r1=1443793&r2=1443794&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java (original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java Thu Feb 7 23:47:18 2013
@@ -18,7 +18,7 @@
*/
package org.apache.myfaces.lifecycle;
-import java.util.Collection;
+import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -27,9 +27,9 @@ import javax.faces.FacesException;
import javax.faces.FactoryFinder;
import javax.faces.application.Application;
import javax.faces.application.ProjectStage;
+import javax.faces.application.ProtectedViewException;
import javax.faces.application.ViewExpiredException;
import javax.faces.application.ViewHandler;
-import javax.faces.component.UIViewParameter;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
@@ -168,7 +168,7 @@ class RestoreViewExecutor extends PhaseE
{
ViewMetadata metadata = vdl.getViewMetadata(facesContext, viewId);
- Collection<UIViewParameter> viewParameters = null;
+ //Collection<UIViewParameter> viewParameters = null;
if (metadata != null)
{
@@ -176,7 +176,7 @@ class RestoreViewExecutor extends PhaseE
if (viewRoot != null)
{
- viewParameters = ViewMetadata.getViewParameters(viewRoot);
+ //viewParameters = ViewMetadata.getViewParameters(viewRoot);
}
else if(facesContext.getResponseComplete())
{
@@ -187,9 +187,17 @@ class RestoreViewExecutor extends PhaseE
}
// If viewParameters is not an empty collection DO NOT call renderResponse
- if ( !(viewParameters != null && !viewParameters.isEmpty()) )
- {
+ //if ( !(viewParameters != null && !viewParameters.isEmpty()) )
+ //{
// Call renderResponse() on the FacesContext.
+ //facesContext.renderResponse();
+ //}
+ if (viewRoot == null)
+ {
+ facesContext.renderResponse();
+ }
+ else if (viewRoot != null && !ViewMetadata.hasMetadata(viewRoot))
+ {
facesContext.renderResponse();
}
}
@@ -237,6 +245,36 @@ class RestoreViewExecutor extends PhaseE
return false;
}
+ private void checkViewProtection(FacesContext facesContext, ViewHandler viewHandler,
+ UIViewRoot root) throws ProtectedViewException
+ {
+ Set<String> protectedViews = viewHandler.getProtectedViewsUnmodifiable();
+
+ if (protectedViews.contains(root.getViewId()))
+ {
+ String referer = facesContext.getExternalContext().
+ getRequestHeaderMap().get("Referer");
+ if (referer != null)
+ {
+ // If the header is present, use the protected view API to determine if any of
+ // the declared protected views match the value of the Referer header.
+
+ // - If so, conclude that the previously visited page is also a protected
+ // view and it is therefore safe to continue
+
+ // - Otherwise, try to determine if the value of the Referer header corresponds
+ // to any of the views in the current web application.
+
+ // - If not, throw a ProtectedViewException
+ }
+ else
+ {
+ // fall back on inspecting the incoming URL.
+ }
+
+ }
+ }
+
/**
* Invoke afterPhase MethodExpression of UIViewRoot.
* Note: In this phase it is not possible to invoke the beforePhase method, because we