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 2009/04/30 06:03:59 UTC
svn commit: r770053 - in /myfaces/core/branches/2_0_0/impl/src:
main/conf/META-INF/ main/java/org/apache/myfaces/config/
main/java/org/apache/myfaces/context/
main/java/org/apache/myfaces/context/servlet/
main/resources/org/apache/myfaces/resource/ tes...
Author: lu4242
Date: Thu Apr 30 04:03:57 2009
New Revision: 770053
URL: http://svn.apache.org/viewvc?rev=770053&view=rev
Log:
MYFACES-2116 TODO 65: Partial View Lifecycle (Skeleton) and fix on FacesContextImpl.isPostback
Added:
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/PartialViewContextFactoryImpl.java (with props)
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/PartialViewContextImpl.java (with props)
Modified:
myfaces/core/branches/2_0_0/impl/src/main/conf/META-INF/standard-faces-config-base.xml
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java
myfaces/core/branches/2_0_0/impl/src/main/resources/org/apache/myfaces/resource/web-facesconfig_2_0.xsd
myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/ContextTestRequestWrapper.java
myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/ExecutePhaseClientIdsTest.java
myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/IsRenderedTest.java
myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/RenderPhaseClientIdsTest.java
myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/TestIsAjaxRequest.java
Modified: myfaces/core/branches/2_0_0/impl/src/main/conf/META-INF/standard-faces-config-base.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/conf/META-INF/standard-faces-config-base.xml?rev=770053&r1=770052&r2=770053&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/conf/META-INF/standard-faces-config-base.xml (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/conf/META-INF/standard-faces-config-base.xml Thu Apr 30 04:03:57 2009
@@ -49,6 +49,7 @@
<factory>
<application-factory>org.apache.myfaces.application.ApplicationFactoryImpl</application-factory>
<faces-context-factory>org.apache.myfaces.context.FacesContextFactoryImpl</faces-context-factory>
+ <partial-view-context-factory>org.apache.myfaces.context.PartialViewContextFactoryImpl</partial-view-context-factory>
<lifecycle-factory>org.apache.myfaces.lifecycle.LifecycleFactoryImpl</lifecycle-factory>
<render-kit-factory>org.apache.myfaces.renderkit.RenderKitFactoryImpl</render-kit-factory>
</factory>
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java?rev=770053&r1=770052&r2=770053&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java Thu Apr 30 04:03:57 2009
@@ -80,6 +80,7 @@
import org.apache.myfaces.config.impl.digester.elements.OrderSlot;
import org.apache.myfaces.config.impl.digester.elements.ResourceBundle;
import org.apache.myfaces.context.FacesContextFactoryImpl;
+import org.apache.myfaces.context.PartialViewContextFactoryImpl;
import org.apache.myfaces.el.DefaultPropertyResolver;
import org.apache.myfaces.el.VariableResolverImpl;
import org.apache.myfaces.lifecycle.LifecycleFactoryImpl;
@@ -115,6 +116,7 @@
private static final String DEFAULT_FACES_CONTEXT_FACTORY = FacesContextFactoryImpl.class.getName();
private static final String DEFAULT_LIFECYCLE_FACTORY = LifecycleFactoryImpl.class.getName();
private static final String DEFAULT_RENDER_KIT_FACTORY = RenderKitFactoryImpl.class.getName();
+ private static final String DEFAULT_PARTIAL_VIEW_CONTEXT_FACTORY = PartialViewContextFactoryImpl.class.getName();
private static final String DEFAULT_FACES_CONFIG = "/WEB-INF/faces-config.xml";
private static final Set<String> FACTORY_NAMES = new HashSet<String>();
@@ -123,6 +125,7 @@
FACTORY_NAMES.add(FactoryFinder.FACES_CONTEXT_FACTORY);
FACTORY_NAMES.add(FactoryFinder.LIFECYCLE_FACTORY);
FACTORY_NAMES.add(FactoryFinder.RENDER_KIT_FACTORY);
+ FACTORY_NAMES.add(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY);
}
private final ExternalContext _externalContext;
@@ -551,6 +554,9 @@
} else if (factoryName.equals(FactoryFinder.RENDER_KIT_FACTORY))
{
getDispenser().feedRenderKitFactory(className);
+ } else if (factoryName.equals(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY))
+ {
+ getDispenser().feedPartialViewContextFactory(className);
} else
{
throw new IllegalStateException("Unexpected factory name " + factoryName);
@@ -1406,6 +1412,8 @@
DEFAULT_LIFECYCLE_FACTORY);
setFactories(FactoryFinder.RENDER_KIT_FACTORY, dispenser.getRenderKitFactoryIterator(),
DEFAULT_RENDER_KIT_FACTORY);
+ setFactories(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY, dispenser.getPartialViewContextFactoryIterator(),
+ DEFAULT_PARTIAL_VIEW_CONTEXT_FACTORY);
}
private void setFactories(String factoryName, Collection<String> factories, String defaultFactory)
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/PartialViewContextFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/PartialViewContextFactoryImpl.java?rev=770053&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/PartialViewContextFactoryImpl.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/PartialViewContextFactoryImpl.java Thu Apr 30 04:03:57 2009
@@ -0,0 +1,35 @@
+/*
+ * 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.context;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.PartialViewContext;
+import javax.faces.context.PartialViewContextFactory;
+
+import org.apache.myfaces.context.servlet.PartialViewContextImpl;
+
+public class PartialViewContextFactoryImpl extends PartialViewContextFactory
+{
+
+ @Override
+ public PartialViewContext getPartialViewContext(FacesContext context)
+ {
+ return new PartialViewContextImpl(context);
+ }
+}
Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/PartialViewContextFactoryImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/PartialViewContextFactoryImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java?rev=770053&r1=770052&r2=770053&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java Thu Apr 30 04:03:57 2009
@@ -42,6 +42,7 @@
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.PartialViewContext;
+import javax.faces.context.PartialViewContextFactory;
import javax.faces.context.ResponseStream;
import javax.faces.context.ResponseWriter;
import javax.faces.event.PhaseId;
@@ -75,6 +76,7 @@
private static final String METHOD_GETEXTERNALCONTEXT = "getExternalContext";
private static final String METHOD_GETMAXIMUMSEVERITY = "getMaximumSeverity";
private static final String METHOD_GETMESSAGES = "getMessages";
+ private static final String METHOD_GETPARTIALVIEWCONTEXT = "getPartialViewContext";
private static final String METHOD_GETRENDERKIT = "getRenderKit";
private static final String METHOD_GETRESPONSECOMPLETE = "getResponseComplete";
private static final String METHOD_GETRESPONSESTREAM = "getResponseStream";
@@ -110,6 +112,7 @@
private ELContext _elContext;
private Map<Object, Object> _attributes = null;
//private ResponseSwitch _responseWrapper = null;
+ private PartialViewContext _partialViewContext = null;
// ~ Constructors -------------------------------------------------------------------------------
public FacesContextImpl(final ServletContext servletContext, final ServletRequest servletRequest,
@@ -259,8 +262,16 @@
@Override
public PartialViewContext getPartialViewContext()
{
- // TODO: JSF 2.0
- return null;
+ assertNotReleased(METHOD_GETPARTIALVIEWCONTEXT);
+
+ if (_partialViewContext == null)
+ {
+ //Get through factory finder
+ PartialViewContextFactory factory = (PartialViewContextFactory)
+ FactoryFinder.getFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY);
+ _partialViewContext = factory.getPartialViewContext(this);
+ }
+ return _partialViewContext;
}
@Override
@@ -418,6 +429,7 @@
_responseStream = null;
_responseWriter = null;
_viewRoot = null;
+ _partialViewContext = null;
_released = true;
FacesContext.setCurrentInstance(null);
@@ -428,7 +440,31 @@
{
assertNotReleased(METHOD_RENDERRESPONSE);
- return getRenderKit().getResponseStateManager().isPostback(this);
+ RenderKit renderKit = getRenderKit();
+ if (renderKit == null)
+ {
+ // NullPointerException with StateManager, because
+ // to restore state it first restore structure,
+ // then fill it and in the middle of the two previous
+ // process there is many calls from _ComponentChildrenList.childAdded
+ // to facesContext.isPostback, and getViewRoot is null.
+ //
+ // Setting a "phantom" UIViewRoot calling facesContext.setViewRoot(viewRoot)
+ // to avoid it is bad, because this is work of RestoreViewExecutor,
+ // and theorically ViewHandler.restoreView must return an UIViewRoot
+ // instance.
+ //
+ // The problem with this is if the user changes the renderkit directly
+ // using f:view renderKitId param, the ResponseStateManager returned
+ // will be the one tied to faces-config selected RenderKit. But the usual
+ // method to check if a request is a postback, is always detect the param
+ // javax.faces.ViewState, so there is no problem after all.
+ String renderKitId = this.getApplication().getViewHandler().calculateRenderKitId(this);
+ RenderKitFactory factory = (RenderKitFactory)
+ FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ renderKit = factory.getRenderKit(this, renderKitId);
+ }
+ return renderKit.getResponseStateManager().isPostback(this);
}
@Override
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/PartialViewContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/PartialViewContextImpl.java?rev=770053&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/PartialViewContextImpl.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/PartialViewContextImpl.java Thu Apr 30 04:03:57 2009
@@ -0,0 +1,270 @@
+/*
+ * 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.context.servlet;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.PartialResponseWriter;
+import javax.faces.context.PartialViewContext;
+import javax.faces.event.PhaseId;
+
+import org.apache.myfaces.shared_impl.util.StringUtils;
+
+public class PartialViewContextImpl extends PartialViewContext
+{
+ private static final String METHOD_GETEXECUTEIDS = "";
+ private static final String METHOD_GETPARTIALRESPONSEWRITER = "";
+ private static final String METHOD_GETRENDERIDS = "";
+ private static final String METHOD_ISAJAXREQUEST = "";
+ private static final String METHOD_ISEXECUTEALL = "";
+ private static final String METHOD_ISPARTIALREQUEST = "";
+ private static final String METHOD_ISRENDERALL = "";
+ private static final String METHOD_PROCESSPARTIAL = "";
+ private static final String METHOD_RELEASE = "";
+ private static final String METHOD_SETPARTIALREQUEST = "";
+ private static final String METHOD_SETRENDERALL = "";
+
+ private static final String FACES_REQUEST = "Faces-Request";
+ private static final String PARTIAL_AJAX = "partial/ajax";
+ private static final String PARTIAL_PROCESS = "partial/process";
+
+ private FacesContext _facesContext = null;
+ private boolean _released = false;
+
+ // Cached values, since their parent methods could be called
+ // many times and the result does not change during the life time
+ // of this object.
+ private Boolean _ajaxRequest = null;
+ private Collection<String> _executeClientIds = null;
+ private Collection<String> _renderClientIds = null;
+
+ // Values that need to be saved because exists a setXX method
+ private Boolean _partialRequest = null;
+ private Boolean _renderAll = null;
+
+
+ public PartialViewContextImpl(FacesContext context)
+ {
+ _facesContext = context;
+ }
+
+ @Override
+ public boolean isAjaxRequest()
+ {
+ assertNotReleased(METHOD_ISAJAXREQUEST);
+
+ if (_ajaxRequest == null)
+ {
+ String requestType = _facesContext.getExternalContext().
+ getRequestHeaderMap().get(FACES_REQUEST);
+ _ajaxRequest = (requestType != null && PARTIAL_AJAX.equals(requestType));
+ }
+ return _ajaxRequest;
+ }
+
+ @Override
+ public boolean isExecuteAll()
+ {
+ assertNotReleased(METHOD_ISEXECUTEALL);
+
+ if (isAjaxRequest())
+ {
+ String executeMode = _facesContext.getExternalContext().
+ getRequestParameterMap().get(
+ PartialViewContext.PARTIAL_EXECUTE_PARAM_NAME);
+ if (PartialViewContext.ALL_PARTIAL_PHASE_CLIENT_IDS.equals(executeMode))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isPartialRequest()
+ {
+ assertNotReleased(METHOD_ISPARTIALREQUEST);
+
+ if (_partialRequest == null)
+ {
+ String requestType = _facesContext.getExternalContext().
+ getRequestHeaderMap().get(FACES_REQUEST);
+ _partialRequest = (requestType != null && PARTIAL_PROCESS.equals(requestType));
+ }
+ return isAjaxRequest() || _partialRequest;
+ }
+
+ @Override
+ public boolean isRenderAll()
+ {
+ assertNotReleased(METHOD_ISRENDERALL);
+
+ if (_renderAll == null)
+ {
+ if (isAjaxRequest())
+ {
+ String executeMode = _facesContext.getExternalContext().
+ getRequestParameterMap().get(
+ PartialViewContext.PARTIAL_RENDER_PARAM_NAME);
+ if (PartialViewContext.ALL_PARTIAL_PHASE_CLIENT_IDS.equals(executeMode))
+ {
+ _renderAll = true;
+ }
+ }
+ if (_renderAll == null)
+ {
+ _renderAll = false;
+ }
+ }
+ return _renderAll;
+ }
+
+
+ @Override
+ public void setPartialRequest(boolean isPartialRequest)
+ {
+ assertNotReleased(METHOD_SETPARTIALREQUEST);
+
+ _partialRequest = isPartialRequest;
+
+ }
+
+ @Override
+ public void setRenderAll(boolean renderAll)
+ {
+ assertNotReleased(METHOD_SETRENDERALL);
+
+ _renderAll = renderAll;
+ }
+
+ @Override
+ public Collection<String> getExecuteIds()
+ {
+ assertNotReleased(METHOD_GETEXECUTEIDS);
+
+ if (_executeClientIds == null)
+ {
+ String executeMode = _facesContext.getExternalContext().
+ getRequestParameterMap().get(
+ PartialViewContext.PARTIAL_EXECUTE_PARAM_NAME);
+
+ if (executeMode != null && !"".equals(executeMode) &&
+ !PartialViewContext.NO_PARTIAL_PHASE_CLIENT_IDS.equals(executeMode) &&
+ !PartialViewContext.ALL_PARTIAL_PHASE_CLIENT_IDS.equals(executeMode))
+ {
+ String[] clientIds = StringUtils.splitShortString(executeMode.replaceAll("[ \\t\\n]*",""), ',');
+
+ //The collection must be mutable
+ List<String> tempList = new ArrayList<String>();
+ for (int i = 0; i < clientIds.length ; i++)
+ {
+ tempList.add(clientIds[i]);
+ }
+ _executeClientIds = tempList;
+ }
+ else
+ {
+ _executeClientIds = new ArrayList<String>();
+ }
+ }
+ return _executeClientIds;
+ }
+
+
+ @Override
+ public Collection<String> getRenderIds()
+ {
+ assertNotReleased(METHOD_GETRENDERIDS);
+
+ if (_renderClientIds == null)
+ {
+ String renderMode = _facesContext.getExternalContext().
+ getRequestParameterMap().get(
+ PartialViewContext.PARTIAL_RENDER_PARAM_NAME);
+
+ if (renderMode != null && !"".equals(renderMode) &&
+ !PartialViewContext.NO_PARTIAL_PHASE_CLIENT_IDS.equals(renderMode) &&
+ !PartialViewContext.ALL_PARTIAL_PHASE_CLIENT_IDS.equals(renderMode))
+ {
+ String[] clientIds = StringUtils.splitShortString(renderMode.replaceAll("[ \\t\\n]*",""), ',');
+
+ //The collection must be mutable
+ List<String> tempList = new ArrayList<String>();
+ for (int i = 0; i < clientIds.length ; i++)
+ {
+ tempList.add(clientIds[i]);
+ }
+ _renderClientIds = tempList;
+ }
+ else
+ {
+ _renderClientIds = new ArrayList<String>();
+ }
+ }
+ return _renderClientIds;
+ }
+
+ @Override
+ public PartialResponseWriter getPartialResponseWriter()
+ {
+ assertNotReleased(METHOD_GETPARTIALRESPONSEWRITER);
+ //TODO: JSF 2.0, add impl
+
+ return new PartialResponseWriter(_facesContext.getResponseWriter());
+ }
+
+ @Override
+ public void processPartial(PhaseId phaseId)
+ {
+ assertNotReleased(METHOD_PROCESSPARTIAL);
+ //TODO: JSF 2.0, add impl
+
+ }
+
+ /**
+ * has to be thrown in many of the methods if the method is called after the instance has been released!
+ */
+ private final void assertNotReleased(String string)
+ {
+ if (_released)
+ {
+ StringBuilder errorMessage = new StringBuilder(128);
+ errorMessage.append("Error in method call on javax.faces.context.FacesContext.");
+ errorMessage.append(string);
+ errorMessage.append(", the facesContext is already released!");
+ throw new IllegalStateException(errorMessage.toString());
+ }
+ }
+
+ @Override
+ public void release()
+ {
+ assertNotReleased(METHOD_RELEASE);
+ _executeClientIds = null;
+ _renderClientIds = null;
+ _ajaxRequest = null;
+ _partialRequest = null;
+ _renderAll = null;
+ _facesContext = null;
+ _released = true;
+ }
+}
Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/PartialViewContextImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/context/servlet/PartialViewContextImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/core/branches/2_0_0/impl/src/main/resources/org/apache/myfaces/resource/web-facesconfig_2_0.xsd
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/resources/org/apache/myfaces/resource/web-facesconfig_2_0.xsd?rev=770053&r1=770052&r2=770053&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/resources/org/apache/myfaces/resource/web-facesconfig_2_0.xsd (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/resources/org/apache/myfaces/resource/web-facesconfig_2_0.xsd Thu Apr 30 04:03:57 2009
@@ -145,6 +145,7 @@
<xsd:choice maxOccurs="unbounded" minOccurs="0">
<xsd:element name="application-factory" type="javaee:fully-qualified-classType"/>
<xsd:element name="faces-context-factory" type="javaee:fully-qualified-classType"/>
+ <xsd:element name="partial-view-context-factory" type="javaee:fully-qualified-classType"/>
<xsd:element name="lifecycle-factory" type="javaee:fully-qualified-classType"/>
<xsd:element name="render-kit-factory" type="javaee:fully-qualified-classType"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="factory-extension"
Modified: myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/ContextTestRequestWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/ContextTestRequestWrapper.java?rev=770053&r1=770052&r2=770053&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/ContextTestRequestWrapper.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/ContextTestRequestWrapper.java Thu Apr 30 04:03:57 2009
@@ -18,8 +18,9 @@
import java.util.Enumeration;
import java.util.Map;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletRequestWrapper;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
/**
* Context request wrapper
@@ -29,7 +30,7 @@
* @author Werner Punz(latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class ContextTestRequestWrapper extends ServletRequestWrapper {
+public class ContextTestRequestWrapper extends HttpServletRequestWrapper {
Map<String, String> _paramDelegate = null;
/**
@@ -37,7 +38,7 @@
* @param _delegate
* @param newRequestParameters
*/
- public ContextTestRequestWrapper(ServletRequest _delegate, Map<String, String> newRequestParameters) {
+ public ContextTestRequestWrapper(HttpServletRequest _delegate, Map<String, String> newRequestParameters) {
super(_delegate);
_paramDelegate = newRequestParameters;
}
Modified: myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/ExecutePhaseClientIdsTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/ExecutePhaseClientIdsTest.java?rev=770053&r1=770052&r2=770053&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/ExecutePhaseClientIdsTest.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/ExecutePhaseClientIdsTest.java Thu Apr 30 04:03:57 2009
@@ -18,6 +18,7 @@
import java.util.HashMap;
import java.util.Map;
+import javax.faces.FactoryFinder;
import javax.faces.context.FacesContext;
import javax.faces.context.PartialViewContext;
@@ -33,6 +34,13 @@
public ExecutePhaseClientIdsTest() {
super("ExecutePhaseClientIdsTest");
}
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ FactoryFinder.setFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY,
+ "org.apache.myfaces.context.PartialViewContextFactoryImpl");
+ }
/**
* Empty String as request param
Modified: myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/IsRenderedTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/IsRenderedTest.java?rev=770053&r1=770052&r2=770053&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/IsRenderedTest.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/IsRenderedTest.java Thu Apr 30 04:03:57 2009
@@ -15,6 +15,7 @@
*/
package org.apache.myfaces.context;
+import javax.faces.FactoryFinder;
import javax.faces.context.FacesContext;
import javax.faces.context.PartialViewContext;
@@ -37,6 +38,8 @@
@Override
protected void setUp() throws Exception {
super.setUp();
+ FactoryFinder.setFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY,
+ "org.apache.myfaces.context.PartialViewContextFactoryImpl");
}
/**
Modified: myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/RenderPhaseClientIdsTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/RenderPhaseClientIdsTest.java?rev=770053&r1=770052&r2=770053&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/RenderPhaseClientIdsTest.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/RenderPhaseClientIdsTest.java Thu Apr 30 04:03:57 2009
@@ -18,6 +18,7 @@
import java.util.HashMap;
import java.util.Map;
+import javax.faces.FactoryFinder;
import javax.faces.context.FacesContext;
import javax.faces.context.PartialViewContext;
@@ -38,6 +39,13 @@
super("RenderPhaseClientIdsTest");
}
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ FactoryFinder.setFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY,
+ "org.apache.myfaces.context.PartialViewContextFactoryImpl");
+ }
+
/**
* Empty String as request param
* has to result in an empty list
Modified: myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/TestIsAjaxRequest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/TestIsAjaxRequest.java?rev=770053&r1=770052&r2=770053&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/TestIsAjaxRequest.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/context/TestIsAjaxRequest.java Thu Apr 30 04:03:57 2009
@@ -17,6 +17,8 @@
import java.util.HashMap;
import java.util.Map;
+
+import javax.faces.FactoryFinder;
import javax.faces.context.FacesContext;
import org.apache.myfaces.context.servlet.FacesContextImpl;
import org.apache.shale.test.base.AbstractJsfTestCase;
@@ -39,14 +41,16 @@
public void setUp() throws Exception {
super.setUp();
- requestParameterMap = new HashMap<String, String>();
- ContextTestRequestWrapper wrapper = new ContextTestRequestWrapper(request, requestParameterMap);
- context = new FacesContextImpl(servletContext, wrapper, response);
+ //requestParameterMap = new HashMap<String, String>();
+ //ContextTestRequestWrapper wrapper = new ContextTestRequestWrapper(request, requestParameterMap);
+ FactoryFinder.setFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY,
+ "org.apache.myfaces.context.PartialViewContextFactoryImpl");
+ context = new FacesContextImpl(servletContext, request, response);
}
public void tearDown() throws Exception {
super.tearDown();
- requestParameterMap.clear();
+ //requestParameterMap.clear();
}
public void testNoEntry() {
@@ -55,11 +59,7 @@
}
public void testEntry() {
- requestParameterMap.put("javax.faces.partial.ajax", "yess");
-
+ request.addHeader("Faces-Request", "partial/ajax");
assertTrue("no ajax request found", context.getPartialViewContext().isAjaxRequest());
}
-
-
-
}