You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ja...@apache.org on 2010/04/20 17:59:13 UTC
svn commit: r935971 - in /myfaces:
core/trunk/impl/src/main/java/org/apache/myfaces/view/jsp/JspViewDeclarationLanguage.java
shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/view/JspViewDeclarationLanguageBase.java
Author: jakobk
Date: Tue Apr 20 15:59:12 2010
New Revision: 935971
URL: http://svn.apache.org/viewvc?rev=935971&view=rev
Log:
MYFACES-2665 Legacy ViewHandler doesn't work in back compatibility mode for JSP pages
Modified:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/jsp/JspViewDeclarationLanguage.java
myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/view/JspViewDeclarationLanguageBase.java
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/jsp/JspViewDeclarationLanguage.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/jsp/JspViewDeclarationLanguage.java?rev=935971&r1=935970&r2=935971&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/jsp/JspViewDeclarationLanguage.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/jsp/JspViewDeclarationLanguage.java Tue Apr 20 15:59:12 2010
@@ -76,6 +76,9 @@ public class JspViewDeclarationLanguage
@Override
public void buildView(FacesContext context, UIViewRoot view) throws IOException
{
+ // call buildView() from JspViewDeclarationLanguageBase to do some startup work
+ super.buildView(context, view);
+
ExternalContext externalContext = context.getExternalContext();
if (context.getPartialViewContext().isPartialRequest())
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/view/JspViewDeclarationLanguageBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/view/JspViewDeclarationLanguageBase.java?rev=935971&r1=935970&r2=935971&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/view/JspViewDeclarationLanguageBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/view/JspViewDeclarationLanguageBase.java Tue Apr 20 15:59:12 2010
@@ -54,6 +54,14 @@ public abstract class JspViewDeclaration
private static final int FORM_STATE_MARKER_LEN = FORM_STATE_MARKER.length();
private ViewHandlerSupport _cachedViewHandlerSupport;
+
+ @Override
+ public void buildView(FacesContext context, UIViewRoot view) throws IOException
+ {
+ // memorize that buildView() has been called for this view
+ setViewBuilt(context, view);
+ }
+
/**
* {@inheritDoc}
*/
@@ -80,7 +88,7 @@ public abstract class JspViewDeclaration
//provide implementations of buildView but they do not override this class.
checkNull(context, "context");
checkNull(view, "view");
-
+
// do not render the view if the rendered attribute for the view is false
if (!view.isRendered())
{
@@ -88,6 +96,16 @@ public abstract class JspViewDeclaration
log.finest("View is not rendered");
return;
}
+
+ // Check if the current view has already been built via VDL.buildView()
+ // and if not, build it from here. This is necessary because legacy ViewHandler
+ // implementations return null on getViewDeclarationLanguage() and thus
+ // VDL.buildView() is never called. Furthermore, before JSF 2.0 introduced
+ // the VDLs, the code that built the view was in ViewHandler.renderView().
+ if (!isViewBuilt(context, view))
+ {
+ buildView(context, view);
+ }
ExternalContext externalContext = context.getExternalContext();
@@ -288,6 +306,34 @@ public abstract class JspViewDeclaration
return _cachedViewHandlerSupport.calculateViewId(context, viewId);
}
+
+ /**
+ * Returns true if the given UIViewRoot has already been built via VDL.buildView().
+ * This is necessary because legacy ViewHandler implementations return null on
+ * getViewDeclarationLanguage() and thus VDL.buildView() is never called.
+ * So we have to check this in renderView() and, if it is false, we have to
+ * call buildView() manually before the rendering.
+ *
+ * @param facesContext
+ * @param view
+ * @return
+ */
+ protected boolean isViewBuilt(FacesContext facesContext, UIViewRoot view)
+ {
+ return Boolean.TRUE.equals(facesContext.getAttributes().get(view));
+ }
+
+ /**
+ * Saves a flag in the attribute map of the FacesContext to indicate
+ * that the given UIViewRoot was already built with VDL.buildView().
+ *
+ * @param facesContext
+ * @param view
+ */
+ protected void setViewBuilt(FacesContext facesContext, UIViewRoot view)
+ {
+ facesContext.getAttributes().put(view, Boolean.TRUE);
+ }
/**
* Writes the response and replaces the state marker tags with the state information for the current context