Update spring-faces to Jakarta EE
FlowResourceResolver.java is removed, since it was deprecated, see https://github.com/jakartaee/faces/issues/1583 See gh-1794
This commit is contained in:
committed by
rstoyanchev
parent
c0173e54d5
commit
bce7f0cc91
30
build.gradle
30
build.gradle
@@ -32,28 +32,32 @@ allprojects {
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "org.springframework:spring-framework-bom:6.0.0-M5"
|
||||
mavenBom "org.springframework.security:spring-security-bom:5.5.6"
|
||||
mavenBom "org.springframework:spring-framework-bom:6.0.3"
|
||||
mavenBom "org.springframework.security:spring-security-bom:6.0.1"
|
||||
mavenBom "org.junit:junit-bom:5.7.1"
|
||||
}
|
||||
dependencies {
|
||||
dependency "jakarta.servlet:jakarta.servlet-api:5.0.0"
|
||||
dependency "jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api:2.0.0"
|
||||
dependency "jakarta.servlet.jsp:jakarta.servlet.jsp-api:3.0.0"
|
||||
dependency "jakarta.el:jakarta.el-api:4.0.0"
|
||||
dependency "jakarta.validation:jakarta.validation-api:3.0.0"
|
||||
dependency "jakarta.servlet:jakarta.servlet-api:6.0.0"
|
||||
dependency "jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api:3.0.0"
|
||||
dependency "jakarta.servlet.jsp:jakarta.servlet.jsp-api:3.1.0"
|
||||
dependency "jakarta.el:jakarta.el-api:5.0.1"
|
||||
dependency "jakarta.faces:jakarta.faces-api:4.0.1"
|
||||
dependency "jakarta.enterprise:jakarta.enterprise.cdi-api:4.0.1"
|
||||
dependency "org.glassfish:jakarta.faces:4.0.0"
|
||||
dependency "jakarta.validation:jakarta.validation-api:3.0.2"
|
||||
dependencySet(group: 'org.hibernate', version: '5.6.10.Final') {
|
||||
entry 'hibernate-core-jakarta'
|
||||
entry 'hibernate-entitymanager'
|
||||
}
|
||||
dependency "org.hibernate:hibernate-validator:7.0.4.Final"
|
||||
dependency "org.hibernate.validator:hibernate-validator:8.0.0.Final"
|
||||
|
||||
dependency "org.apache.myfaces.core:myfaces-impl:4.0.0-RC4"
|
||||
dependency "org.apache.myfaces.core:myfaces-test:4.0.0-RC4"
|
||||
/*
|
||||
dependencySet(group: 'com.sun.faces', version: '2.2.20') {
|
||||
entry 'jsf-api'
|
||||
entry 'jsf-impl'
|
||||
}
|
||||
dependency "org.apache.myfaces.core:myfaces-impl:3.0.1"
|
||||
dependency "com.sun.facelets:jsf-facelets:1.1.14"
|
||||
*/
|
||||
|
||||
@@ -63,13 +67,13 @@ allprojects {
|
||||
entry 'log4j-slf4j-impl'
|
||||
entry 'log4j-jul'
|
||||
}
|
||||
dependency "org.slf4j:slf4j-api:1.7.30"
|
||||
dependency "org.slf4j:slf4j-api:2.0.6"
|
||||
|
||||
dependency("junit:junit:4.13.2")
|
||||
dependency "org.easymock:easymock:4.2"
|
||||
dependency "org.hamcrest:hamcrest:2.1"
|
||||
dependency "org.apache.tomcat:tomcat-jasper-el:10.0.20"
|
||||
dependency "org.hsqldb:hsqldb:2.5.0"
|
||||
dependency "org.hamcrest:hamcrest:2.2"
|
||||
dependency "org.apache.tomcat:tomcat-jasper-el:11.0.0-M1"
|
||||
dependency "org.hsqldb:hsqldb:2.7.1"
|
||||
|
||||
/*
|
||||
dependency "org.apache.myfaces.test:myfaces-test22:1.0.8"
|
||||
|
||||
@@ -10,8 +10,7 @@ rootProject.name = 'webflow'
|
||||
include 'spring-binding'
|
||||
include 'spring-webflow'
|
||||
include 'spring-js-resources'
|
||||
|
||||
// include 'spring-faces'
|
||||
include 'spring-faces'
|
||||
|
||||
rootProject.children.each {project ->
|
||||
project.buildFileName = "${project.name}.gradle"
|
||||
|
||||
@@ -6,26 +6,25 @@ dependencies {
|
||||
implementation("org.springframework:spring-web")
|
||||
implementation("org.springframework:spring-webmvc")
|
||||
|
||||
compileOnly("javax.el:javax.el-api")
|
||||
compileOnly("javax.servlet:javax.servlet-api")
|
||||
compileOnly("com.sun.faces:jsf-api")
|
||||
compileOnly("com.sun.faces:jsf-impl")
|
||||
compileOnly("jakarta.el:jakarta.el-api")
|
||||
compileOnly("jakarta.servlet:jakarta.servlet-api")
|
||||
compileOnly("org.glassfish:jakarta.faces")
|
||||
compileOnly("org.apache.myfaces.core:myfaces-impl")
|
||||
|
||||
optional("com.sun.facelets:jsf-facelets")
|
||||
optional("jakarta.faces:jakarta.faces-api")
|
||||
optional("org.springframework.security:spring-security-core")
|
||||
optional("org.springframework.security:spring-security-web")
|
||||
optional("org.springframework.security:spring-security-taglibs")
|
||||
|
||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||
testImplementation("org.easymock:easymock")
|
||||
testImplementation("org.apache.myfaces.test:myfaces-test22")
|
||||
testImplementation("org.apache.myfaces.core:myfaces-test")
|
||||
testImplementation("org.apache.tomcat:tomcat-jasper-el")
|
||||
testImplementation("org.springframework:spring-test")
|
||||
testImplementation("javax.servlet:javax.servlet-api")
|
||||
testImplementation("com.sun.faces:jsf-api")
|
||||
testImplementation("com.sun.faces:jsf-impl")
|
||||
testImplementation("jakarta.servlet:jakarta.servlet-api")
|
||||
testImplementation("org.glassfish:jakarta.faces")
|
||||
testImplementation("org.apache.myfaces.core:myfaces-impl")
|
||||
testImplementation("jakarta.enterprise:jakarta.enterprise.cdi-api")
|
||||
testRuntimeOnly("org.apache.logging.log4j:log4j-core")
|
||||
testRuntimeOnly("org.apache.logging.log4j:log4j-slf4j-impl")
|
||||
testRuntimeOnly("org.apache.logging.log4j:log4j-jul")
|
||||
|
||||
@@ -46,7 +46,7 @@ import org.springframework.webflow.executor.FlowExecutor;
|
||||
* </ul>
|
||||
* <p>
|
||||
* Also registers a HandlerMapping bean to provide JSF 2 resource handling at
|
||||
* {@code "/javax.faces.resource/**"} or Rich Faces at {@code "/rfRes/**"}.
|
||||
* {@code "/jakarta.faces.resource/**"} or Rich Faces at {@code "/rfRes/**"}.
|
||||
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 2.4
|
||||
@@ -107,7 +107,7 @@ public class AbstractFacesFlowConfiguration implements ApplicationContextAware {
|
||||
public SimpleUrlHandlerMapping jsrResourceHandlerMapping() {
|
||||
|
||||
Map<String, Object> urlMap = new HashMap<>();
|
||||
urlMap.put("/javax.faces.resource/**", jsfResourceRequestHandler());
|
||||
urlMap.put("/jakarta.faces.resource/**", jsfResourceRequestHandler());
|
||||
if (isRichFacesPresent) {
|
||||
urlMap.put("/rfRes/**", jsfResourceRequestHandler());
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
|
||||
|
||||
private void registerHandlerMappings(Element element, Object source, ParserContext parserContext) {
|
||||
Map<String, String> urlMap = new ManagedMap<>();
|
||||
urlMap.put("/javax.faces.resource/**", SERVLET_RESOURCE_HANDLER_BEAN_NAME);
|
||||
urlMap.put("/jakarta.faces.resource/**", SERVLET_RESOURCE_HANDLER_BEAN_NAME);
|
||||
|
||||
if (isRichFacesPresent) {
|
||||
urlMap.put("/rfRes/**", SERVLET_RESOURCE_HANDLER_BEAN_NAME);
|
||||
@@ -92,4 +92,4 @@ public class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
|
||||
parserContext.getReaderContext().registerWithGeneratedName(beanDefinition);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ package org.springframework.faces.model;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.model.DataModel;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import jakarta.faces.model.DataModel;
|
||||
|
||||
/**
|
||||
* A {@link DataModel} implementation that tracks the currently selected rows, allowing any number of rows to be
|
||||
* selected at one time.
|
||||
|
||||
@@ -18,16 +18,15 @@ package org.springframework.faces.model;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.model.DataModel;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import jakarta.faces.model.DataModel;
|
||||
|
||||
/**
|
||||
* A {@link DataModel} implementation that tracks the currently selected row, allowing only one selection at a time.
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class OneSelectionTrackingListDataModel<T> extends SerializableListDataModel<T> implements SelectionAware<T> {
|
||||
|
||||
/**
|
||||
@@ -70,7 +69,7 @@ public class OneSelectionTrackingListDataModel<T> extends SerializableListDataMo
|
||||
|
||||
if (!rowSelected) {
|
||||
this.selections.remove(getRowData());
|
||||
} else if (rowSelected && !this.selections.contains(getRowData())) {
|
||||
} else if (!this.selections.contains(getRowData())) {
|
||||
this.selections.clear();
|
||||
this.selections.add(getRowData());
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.faces.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.model.DataModel;
|
||||
import jakarta.faces.model.DataModel;
|
||||
|
||||
/**
|
||||
* Interface for {@link DataModel} implementations that need to track selected rows.
|
||||
|
||||
@@ -19,19 +19,19 @@ import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIData;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.event.AbortProcessingException;
|
||||
import javax.faces.event.ActionEvent;
|
||||
import javax.faces.event.ActionListener;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.faces.webflow.FlowActionListener;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import jakarta.faces.component.UIComponent;
|
||||
import jakarta.faces.component.UIData;
|
||||
import jakarta.faces.component.UIViewRoot;
|
||||
import jakarta.faces.event.AbortProcessingException;
|
||||
import jakarta.faces.event.ActionEvent;
|
||||
import jakarta.faces.event.ActionListener;
|
||||
|
||||
/**
|
||||
* Custom {@link ActionListener} that inspects the {@link UIComponent} that signaled the current {@link ActionEvent} to
|
||||
* determine whether it is a child of any iterator type of component (such as {@link UIData}) that uses a
|
||||
@@ -72,7 +72,7 @@ public class SelectionTrackingActionListener implements ActionListener {
|
||||
Method valueAccessor = getValueMethod(parent.getClass());
|
||||
if (valueAccessor != null) {
|
||||
Object value = ReflectionUtils.invokeMethod(valueAccessor, parent);
|
||||
if (value != null && value instanceof SelectionAware) {
|
||||
if (value instanceof SelectionAware) {
|
||||
((SelectionAware<?>) value).setCurrentRowSelected(true);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Row selection has been set on the current SelectionAware data model.");
|
||||
|
||||
@@ -22,17 +22,16 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.model.ListDataModel;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import jakarta.faces.model.ListDataModel;
|
||||
|
||||
/**
|
||||
* A simple {@link ListDataModel List-to-JSF-DataModel} adapter that is also {@link Serializable}.
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class SerializableListDataModel<T> extends ListDataModel<T> implements Serializable {
|
||||
|
||||
|
||||
|
||||
@@ -18,12 +18,12 @@ package org.springframework.faces.model.converter;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.model.DataModel;
|
||||
|
||||
import org.springframework.binding.convert.converters.Converter;
|
||||
import org.springframework.faces.model.OneSelectionTrackingListDataModel;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import jakarta.faces.model.DataModel;
|
||||
|
||||
/**
|
||||
* A {@link Converter} implementation that converts an Object, Object array, or {@link List} into a JSF
|
||||
* {@link DataModel}.
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.faces.model.converter;
|
||||
|
||||
import javax.faces.model.DataModel;
|
||||
import jakarta.faces.model.DataModel;
|
||||
|
||||
import org.springframework.binding.convert.service.DefaultConversionService;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
|
||||
@@ -16,14 +16,6 @@
|
||||
package org.springframework.faces.mvc;
|
||||
|
||||
import java.util.Map;
|
||||
import javax.faces.application.ViewHandler;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.PhaseId;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
import javax.faces.lifecycle.LifecycleFactory;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.faces.webflow.FacesContextHelper;
|
||||
import org.springframework.faces.webflow.JsfUtils;
|
||||
@@ -31,6 +23,15 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.web.servlet.support.RequestContextUtils;
|
||||
import org.springframework.web.servlet.view.AbstractUrlBasedView;
|
||||
|
||||
import jakarta.faces.application.ViewHandler;
|
||||
import jakarta.faces.component.UIViewRoot;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.event.PhaseId;
|
||||
import jakarta.faces.lifecycle.Lifecycle;
|
||||
import jakarta.faces.lifecycle.LifecycleFactory;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* JSF View that renders a transient (stateless) JSF view template. The UIViewRoot will not be saved and thus the JSF
|
||||
* lifecycle will not be able to be invoked on postback.
|
||||
@@ -47,7 +48,7 @@ public class JsfView extends AbstractUrlBasedView {
|
||||
}
|
||||
|
||||
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
HttpServletResponse response) {
|
||||
|
||||
FacesContextHelper facesContextHelper = new FacesContextHelper();
|
||||
FacesContext facesContext = facesContextHelper.getFacesContext(getServletContext(), request, response);
|
||||
@@ -83,6 +84,7 @@ public class JsfView extends AbstractUrlBasedView {
|
||||
Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
|
||||
for (Map.Entry<String, Object> entry : model.entrySet()) {
|
||||
// JSF does not insist that putAll is implemented, hence we use individual put calls
|
||||
//noinspection UseBulkOperation
|
||||
requestMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,19 +15,19 @@
|
||||
*/
|
||||
package org.springframework.faces.security;
|
||||
|
||||
import javax.el.ValueExpression;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.view.facelets.FaceletContext;
|
||||
import javax.faces.view.facelets.TagAttribute;
|
||||
import javax.faces.view.facelets.TagHandler;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
import org.springframework.security.taglibs.authz.AbstractAuthorizeTag;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import jakarta.el.ValueExpression;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.view.facelets.FaceletContext;
|
||||
import jakarta.faces.view.facelets.TagAttribute;
|
||||
import jakarta.faces.view.facelets.TagHandler;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
|
||||
/**
|
||||
* A concrete implementation of {@link AbstractAuthorizeTag} for use with standard Facelets rendering technology.
|
||||
*
|
||||
@@ -131,7 +131,7 @@ public class FaceletsAuthorizeTag extends AbstractAuthorizeTag {
|
||||
if (tagAttribute != null) {
|
||||
if (evaluate) {
|
||||
ValueExpression expression = tagAttribute.getValueExpression(faceletContext, String.class);
|
||||
value = (String) expression.getValue(faceletContext.getFacesContext().getELContext());
|
||||
value = expression.getValue(faceletContext.getFacesContext().getELContext());
|
||||
} else {
|
||||
value = tagAttribute.getValue();
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@ package org.springframework.faces.security;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.view.facelets.FaceletContext;
|
||||
import javax.faces.view.facelets.TagAttribute;
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
import javax.faces.view.facelets.TagHandler;
|
||||
import jakarta.faces.component.UIComponent;
|
||||
import jakarta.faces.view.facelets.FaceletContext;
|
||||
import jakarta.faces.view.facelets.TagAttribute;
|
||||
import jakarta.faces.view.facelets.TagConfig;
|
||||
import jakarta.faces.view.facelets.TagHandler;
|
||||
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
package org.springframework.faces.support;
|
||||
|
||||
import javax.faces.FacesException;
|
||||
import javax.faces.FacesWrapper;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.PhaseListener;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
import jakarta.faces.FacesException;
|
||||
import jakarta.faces.FacesWrapper;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.event.PhaseListener;
|
||||
import jakarta.faces.lifecycle.Lifecycle;
|
||||
|
||||
/**
|
||||
* Provides a simple implementation of {@link Lifecycle} that can be subclassed by developers wishing to provide
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
*/
|
||||
package org.springframework.faces.support;
|
||||
|
||||
import javax.faces.event.PhaseEvent;
|
||||
import javax.faces.event.PhaseId;
|
||||
import javax.faces.event.PhaseListener;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import jakarta.faces.event.PhaseEvent;
|
||||
import jakarta.faces.event.PhaseId;
|
||||
import jakarta.faces.event.PhaseListener;
|
||||
|
||||
/**
|
||||
* {@link PhaseListener} that logs the execution of the individual phases of the JSF lifecycle. Useful during JSF
|
||||
* application development in order to detect unreported JSF errors that cause the lifecycle to short-circuit. Turn
|
||||
@@ -29,7 +29,6 @@ import org.apache.commons.logging.LogFactory;
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class RequestLoggingPhaseListener implements PhaseListener {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(RequestLoggingPhaseListener.class);
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.FacesContextFactory;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.context.FacesContextFactory;
|
||||
import jakarta.faces.lifecycle.Lifecycle;
|
||||
|
||||
/**
|
||||
* Provides helper methods for getting a FacesContext that is suitable for use outside of Web Flow. Inside a running
|
||||
@@ -44,7 +44,7 @@ public class FacesContextHelper {
|
||||
* @see #release
|
||||
*/
|
||||
public FacesContext getFacesContext(Object context, Object request, Object response) {
|
||||
FacesContext facesContext = null;
|
||||
FacesContext facesContext;
|
||||
if (FacesContext.getCurrentInstance() != null) {
|
||||
facesContext = FacesContext.getCurrentInstance();
|
||||
} else {
|
||||
|
||||
@@ -18,12 +18,12 @@ package org.springframework.faces.webflow;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.application.NavigationHandler;
|
||||
import javax.faces.component.ActionSource2;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.AbortProcessingException;
|
||||
import javax.faces.event.ActionEvent;
|
||||
import javax.faces.event.ActionListener;
|
||||
import jakarta.faces.application.NavigationHandler;
|
||||
import jakarta.faces.component.ActionSource2;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.event.AbortProcessingException;
|
||||
import jakarta.faces.event.ActionEvent;
|
||||
import jakarta.faces.event.ActionListener;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -43,7 +43,6 @@ import org.springframework.webflow.validation.WebFlowMessageCodesResolver;
|
||||
|
||||
/**
|
||||
* The default {@link ActionListener} implementation to be used with Web Flow.
|
||||
*
|
||||
* This implementation bypasses the JSF {@link NavigationHandler} mechanism to instead let the event be handled directly
|
||||
* by Web Flow.
|
||||
* <p>
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.application.ApplicationWrapper;
|
||||
import javax.faces.application.StateManager;
|
||||
import javax.faces.application.ViewHandler;
|
||||
import jakarta.faces.application.Application;
|
||||
import jakarta.faces.application.ApplicationWrapper;
|
||||
import jakarta.faces.application.StateManager;
|
||||
import jakarta.faces.application.ViewHandler;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.application.ApplicationFactory;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import jakarta.faces.application.Application;
|
||||
import jakarta.faces.application.ApplicationFactory;
|
||||
|
||||
/**
|
||||
* Custom {@link ApplicationFactory} that ensures the FlowApplication is the first {@link Application} in the chain,
|
||||
* which in turn guarantees the install order for other JSF components.
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import javax.el.CompositeELResolver;
|
||||
import javax.el.ELResolver;
|
||||
import jakarta.el.CompositeELResolver;
|
||||
import jakarta.el.ELResolver;
|
||||
|
||||
import org.springframework.binding.expression.el.MapAdaptableELResolver;
|
||||
import org.springframework.webflow.expression.el.FlowResourceELResolver;
|
||||
|
||||
@@ -17,9 +17,9 @@ package org.springframework.faces.webflow;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.faces.context.ExternalContext;
|
||||
import javax.faces.context.ExternalContextWrapper;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.faces.context.ExternalContext;
|
||||
import jakarta.faces.context.ExternalContextWrapper;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -29,14 +29,14 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.ExternalContext;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.FacesContextWrapper;
|
||||
import javax.faces.context.PartialViewContext;
|
||||
import javax.faces.context.PartialViewContextFactory;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
import jakarta.el.ELContext;
|
||||
import jakarta.faces.application.FacesMessage;
|
||||
import jakarta.faces.context.ExternalContext;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.context.FacesContextWrapper;
|
||||
import jakarta.faces.context.PartialViewContext;
|
||||
import jakarta.faces.context.PartialViewContextFactory;
|
||||
import jakarta.faces.lifecycle.Lifecycle;
|
||||
|
||||
import org.springframework.binding.message.Message;
|
||||
import org.springframework.binding.message.MessageResolver;
|
||||
@@ -130,7 +130,7 @@ public class FlowFacesContext extends FacesContextWrapper {
|
||||
|
||||
public boolean getRenderResponse() {
|
||||
Boolean renderResponse = this.context.getFlashScope().getBoolean(RENDER_RESPONSE_KEY);
|
||||
return (renderResponse == null ? false : renderResponse);
|
||||
return (renderResponse != null && renderResponse);
|
||||
}
|
||||
|
||||
public boolean getResponseComplete() {
|
||||
@@ -170,7 +170,7 @@ public class FlowFacesContext extends FacesContextWrapper {
|
||||
Set<String> clientIds = new LinkedHashSet<>();
|
||||
for (Message message : this.context.getMessageContext().getAllMessages()) {
|
||||
Object source = message.getSource();
|
||||
if (source != null && source instanceof String) {
|
||||
if (source instanceof String) {
|
||||
clientIds.add((String) source);
|
||||
} else if (message.getSource() instanceof FacesMessageSource) {
|
||||
clientIds.add(((FacesMessageSource) source).getClientId());
|
||||
@@ -293,9 +293,8 @@ public class FlowFacesContext extends FacesContextWrapper {
|
||||
* uncommon for <code>FacesMessages</code> to be changed after they have been added to a <code>FacesContext</code>, for
|
||||
* example, from a <code>PhaseListener</code>.
|
||||
* <p>
|
||||
* NOTE: Only {@link javax.faces.application.FacesMessage} instances are directly adapted, any subclasses will be
|
||||
* NOTE: Only {@link jakarta.faces.application.FacesMessage} instances are directly adapted, any subclasses will be
|
||||
* converted to the standard FacesMessage implementation. This is to protect against bugs such as SWF-1073.
|
||||
*
|
||||
* For convenience this class also implements the {@link MessageResolver} interface.
|
||||
*/
|
||||
protected static class FlowFacesMessage extends Message implements MessageResolver {
|
||||
@@ -310,8 +309,8 @@ public class FlowFacesContext extends FacesContextWrapper {
|
||||
/**
|
||||
* Use standard faces message as required to protect against bugs such as SWF-1073.
|
||||
*
|
||||
* @param message {@link javax.faces.application.FacesMessage} or subclass.
|
||||
* @return {@link javax.faces.application.FacesMessage} instance
|
||||
* @param message {@link jakarta.faces.application.FacesMessage} or subclass.
|
||||
* @return {@link jakarta.faces.application.FacesMessage} instance
|
||||
*/
|
||||
private FacesMessage asStandardFacesMessageInstance(FacesMessage message) {
|
||||
if (FacesMessage.class.equals(message.getClass())) {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
|
||||
import org.springframework.webflow.execution.FlowExecutionListener;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import javax.faces.FacesException;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.PhaseId;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
import javax.faces.lifecycle.LifecycleFactory;
|
||||
import jakarta.faces.FacesException;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.event.PhaseId;
|
||||
import jakarta.faces.lifecycle.Lifecycle;
|
||||
import jakarta.faces.lifecycle.LifecycleFactory;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -74,10 +74,8 @@ public class FlowLifecycle extends LifecycleWrapper {
|
||||
private boolean skipPhase(FacesContext context, PhaseId phaseId) {
|
||||
if (context.getResponseComplete()) {
|
||||
return true;
|
||||
} else if (context.getRenderResponse()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
return context.getRenderResponse();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.faces.context.PartialViewContext;
|
||||
import javax.faces.context.PartialViewContextWrapper;
|
||||
import jakarta.faces.context.PartialViewContext;
|
||||
import jakarta.faces.context.PartialViewContextWrapper;
|
||||
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
import org.springframework.webflow.execution.RequestContextHolder;
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import javax.faces.render.RenderKit;
|
||||
import javax.faces.render.RenderKitWrapper;
|
||||
import javax.faces.render.ResponseStateManager;
|
||||
import jakarta.faces.render.RenderKit;
|
||||
import jakarta.faces.render.RenderKitWrapper;
|
||||
import jakarta.faces.render.ResponseStateManager;
|
||||
|
||||
/**
|
||||
* A render kit implementation that ensures use of Web Flow's FlowViewResponseStateManager, which takes over reading and
|
||||
|
||||
@@ -17,17 +17,18 @@ package org.springframework.faces.webflow;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import javax.faces.FacesException;
|
||||
import javax.faces.application.ResourceHandler;
|
||||
import javax.faces.application.ResourceHandlerWrapper;
|
||||
import javax.faces.application.ViewResource;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
import org.springframework.webflow.execution.RequestContextHolder;
|
||||
|
||||
import jakarta.faces.FacesException;
|
||||
import jakarta.faces.application.ResourceHandler;
|
||||
import jakarta.faces.application.ResourceHandlerWrapper;
|
||||
import jakarta.faces.application.ViewResource;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
|
||||
/**
|
||||
* Resolves Facelets resources using Spring Resource paths such as "classpath:foo.xhtml".
|
||||
* <p>This handler is auto-configured in the faces-config.xml bundled with the
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2012 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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.springframework.faces.webflow;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.FacesException;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
import org.springframework.webflow.execution.RequestContextHolder;
|
||||
|
||||
/**
|
||||
* Resolves Facelets templates using Spring Resource paths such as "classpath:foo.xhtml".
|
||||
* Configure it via a context parameter in web.xml:
|
||||
* <pre>
|
||||
* <context-param/>
|
||||
* <param-name>facelets.RESOURCE_RESOLVER</param-name>
|
||||
* <param-value>org.springframework.faces.webflow.FlowResourceResolver</param-value>
|
||||
* </context-param>
|
||||
* </pre>
|
||||
* @deprecated as of 2.5 in favor of {@link FlowResourceHandler}.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class FlowResourceResolver extends javax.faces.view.facelets.ResourceResolver {
|
||||
|
||||
/**
|
||||
* All known {@code ResourceResolver} implementations in the priority order
|
||||
*/
|
||||
private static final List<String> RESOLVERS_CLASSES;
|
||||
static {
|
||||
List<String> resolvers = new ArrayList<>();
|
||||
resolvers.add("com.sun.faces.facelets.impl.DefaultResourceResolver");
|
||||
resolvers.add("org.apache.myfaces.view.facelets.impl.DefaultResourceResolver");
|
||||
RESOLVERS_CLASSES = Collections.unmodifiableList(resolvers);
|
||||
}
|
||||
|
||||
private final javax.faces.view.facelets.ResourceResolver delegateResolver;
|
||||
|
||||
public FlowResourceResolver() {
|
||||
this.delegateResolver = createDelegateResolver();
|
||||
}
|
||||
|
||||
private javax.faces.view.facelets.ResourceResolver createDelegateResolver() {
|
||||
try {
|
||||
ClassLoader classLoader = getClass().getClassLoader();
|
||||
for (String resolverClass : RESOLVERS_CLASSES) {
|
||||
if (ClassUtils.isPresent(resolverClass, classLoader)) {
|
||||
return (javax.faces.view.facelets.ResourceResolver)
|
||||
ClassUtils.forName(resolverClass, classLoader).newInstance();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
throw new IllegalStateException("Unable to find Default ResourceResolver");
|
||||
}
|
||||
|
||||
public URL resolveUrl(String path) {
|
||||
|
||||
if (!JsfUtils.isFlowRequest()) {
|
||||
return this.delegateResolver.resolveUrl(path);
|
||||
}
|
||||
|
||||
try {
|
||||
RequestContext context = RequestContextHolder.getRequestContext();
|
||||
ApplicationContext flowContext = context.getActiveFlow().getApplicationContext();
|
||||
if (flowContext == null) {
|
||||
throw new IllegalStateException("A Flow ApplicationContext is required to resolve Flow View Resources");
|
||||
}
|
||||
|
||||
ApplicationContext appContext = flowContext.getParent();
|
||||
Resource viewResource = appContext.getResource(path);
|
||||
if (viewResource.exists()) {
|
||||
return viewResource.getURL();
|
||||
} else {
|
||||
return this.delegateResolver.resolveUrl(path);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
throw new FacesException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,11 +18,11 @@ package org.springframework.faces.webflow;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import javax.faces.FacesWrapper;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.ResponseWriter;
|
||||
import javax.faces.render.RenderKitFactory;
|
||||
import javax.faces.render.ResponseStateManager;
|
||||
import jakarta.faces.FacesWrapper;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.context.ResponseWriter;
|
||||
import jakarta.faces.render.RenderKitFactory;
|
||||
import jakarta.faces.render.ResponseStateManager;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -94,7 +94,7 @@ public class FlowResponseStateManager extends ResponseStateManager
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the flow execution key to be used as the value for the "javax.faces.ViewState" hidden input
|
||||
* This method returns the flow execution key to be used as the value for the "jakarta.faces.ViewState" hidden input
|
||||
* field. The value of this key is not important because JSF state is stored in a Web Flow managed view scoped
|
||||
* variable. However the presence of the view state parameter alone is important for triggering actions. Hence we
|
||||
* return the most logical value, which is the flow execution key.
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import javax.faces.application.StateManager;
|
||||
import javax.faces.application.StateManagerWrapper;
|
||||
import javax.faces.context.FacesContext;
|
||||
import jakarta.faces.application.StateManager;
|
||||
import jakarta.faces.application.StateManagerWrapper;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
|
||||
/**
|
||||
* Custom {@link StateManager} that manages ensures web flow's state is always stored server side.
|
||||
@@ -33,6 +33,7 @@ public class FlowStateManager extends StateManagerWrapper {
|
||||
private final StateManager wrapped;
|
||||
|
||||
public FlowStateManager(StateManager wrapped) {
|
||||
super(wrapped);
|
||||
this.wrapped = wrapped;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import java.util.Locale;
|
||||
import javax.faces.application.ViewHandler;
|
||||
import javax.faces.application.ViewHandlerWrapper;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.FacesContext;
|
||||
import jakarta.faces.application.ViewHandler;
|
||||
import jakarta.faces.application.ViewHandlerWrapper;
|
||||
import jakarta.faces.component.UIViewRoot;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.io.ContextResource;
|
||||
|
||||
@@ -18,17 +18,17 @@ package org.springframework.faces.webflow;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import javax.faces.context.ExternalContext;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.PartialResponseWriter;
|
||||
import javax.faces.context.ResponseWriter;
|
||||
import javax.faces.render.RenderKit;
|
||||
import javax.faces.render.RenderKitFactory;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.webflow.context.servlet.AbstractAjaxHandler;
|
||||
|
||||
import jakarta.faces.context.ExternalContext;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.context.PartialResponseWriter;
|
||||
import jakarta.faces.context.ResponseWriter;
|
||||
import jakarta.faces.render.RenderKit;
|
||||
import jakarta.faces.render.RenderKitFactory;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Ajax handler for JSF 2 requests that can identify JSF 2 Ajax requests and send redirect instructions back to the
|
||||
* client by including a redirect instruction in the content of the response.
|
||||
@@ -54,7 +54,7 @@ public class JsfAjaxHandler extends AbstractAjaxHandler {
|
||||
return facesContext.getPartialViewContext().isAjaxRequest();
|
||||
} else {
|
||||
String header = request.getHeader("Faces-Request");
|
||||
String param = request.getParameter("javax.faces.partial.ajax");
|
||||
String param = request.getParameter("jakarta.faces.partial.ajax");
|
||||
return "partial/ajax".equals(header) || "true".equals(param);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.webflow.context.servlet.AjaxHandler;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
@@ -18,11 +18,11 @@ package org.springframework.faces.webflow;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import javax.el.ELResolver;
|
||||
import javax.el.ExpressionFactory;
|
||||
import javax.el.FunctionMapper;
|
||||
import javax.el.VariableMapper;
|
||||
import jakarta.el.ELContext;
|
||||
import jakarta.el.ELResolver;
|
||||
import jakarta.el.ExpressionFactory;
|
||||
import jakarta.el.FunctionMapper;
|
||||
import jakarta.el.VariableMapper;
|
||||
|
||||
import org.springframework.binding.expression.el.DefaultELResolver;
|
||||
import org.springframework.binding.expression.el.ELContextFactory;
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import javax.el.ExpressionFactory;
|
||||
import javax.el.ValueExpression;
|
||||
import javax.faces.context.FacesContext;
|
||||
import jakarta.el.ELContext;
|
||||
import jakarta.el.ExpressionFactory;
|
||||
import jakarta.el.ValueExpression;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.expression.PropertyAccessor;
|
||||
|
||||
@@ -18,10 +18,10 @@ package org.springframework.faces.webflow;
|
||||
import java.beans.FeatureDescriptor;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import javax.el.ELResolver;
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.context.FacesContext;
|
||||
import jakarta.el.ELContext;
|
||||
import jakarta.el.ELResolver;
|
||||
import jakarta.faces.application.Application;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
@@ -109,8 +109,7 @@ public class JsfManagedBeanResolver extends ELResolver {
|
||||
RequestContext requestContext = RequestContextHolder.getRequestContext();
|
||||
Assert.notNull(requestContext, "RequestContext cannot be null - This resolver is only intended to be invoked "
|
||||
+ "from an active Flow Execution.");
|
||||
FacesContext facesContext = FlowFacesContext.newInstance(requestContext, FlowLifecycle.newInstance());
|
||||
return facesContext;
|
||||
return FlowFacesContext.newInstance(requestContext, FlowLifecycle.newInstance());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,14 +16,15 @@
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.faces.application.ResourceHandler;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.web.HttpRequestHandler;
|
||||
import org.springframework.web.context.support.WebApplicationObjectSupport;
|
||||
|
||||
import jakarta.faces.application.ResourceHandler;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Handles a request by delegating to the JSF ResourceHandler, which serves web
|
||||
* application and classpath resources such as images, CSS and JavaScript files
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.FacesContextWrapper;
|
||||
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.context.FacesContextWrapper;
|
||||
|
||||
/**
|
||||
* Helper class to provide information about the JSF runtime environment such as
|
||||
* JSF version and implementation.
|
||||
|
||||
@@ -17,23 +17,23 @@ package org.springframework.faces.webflow;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.faces.FactoryFinder;
|
||||
import javax.faces.application.ApplicationFactory;
|
||||
import javax.faces.component.visit.VisitContextFactory;
|
||||
import javax.faces.context.ExceptionHandlerFactory;
|
||||
import javax.faces.context.ExternalContextFactory;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.FacesContextFactory;
|
||||
import javax.faces.context.PartialViewContextFactory;
|
||||
import javax.faces.event.PhaseEvent;
|
||||
import javax.faces.event.PhaseId;
|
||||
import javax.faces.event.PhaseListener;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
import javax.faces.lifecycle.LifecycleFactory;
|
||||
import javax.faces.render.RenderKitFactory;
|
||||
import javax.faces.view.ViewDeclarationLanguageFactory;
|
||||
import javax.faces.view.facelets.FaceletCacheFactory;
|
||||
import javax.faces.view.facelets.TagHandlerDelegateFactory;
|
||||
import jakarta.faces.FactoryFinder;
|
||||
import jakarta.faces.application.ApplicationFactory;
|
||||
import jakarta.faces.component.visit.VisitContextFactory;
|
||||
import jakarta.faces.context.ExceptionHandlerFactory;
|
||||
import jakarta.faces.context.ExternalContextFactory;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.context.FacesContextFactory;
|
||||
import jakarta.faces.context.PartialViewContextFactory;
|
||||
import jakarta.faces.event.PhaseEvent;
|
||||
import jakarta.faces.event.PhaseId;
|
||||
import jakarta.faces.event.PhaseListener;
|
||||
import jakarta.faces.lifecycle.Lifecycle;
|
||||
import jakarta.faces.lifecycle.LifecycleFactory;
|
||||
import jakarta.faces.render.RenderKitFactory;
|
||||
import jakarta.faces.view.ViewDeclarationLanguageFactory;
|
||||
import jakarta.faces.view.facelets.FaceletCacheFactory;
|
||||
import jakarta.faces.view.facelets.TagHandlerDelegateFactory;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.webflow.execution.RequestContextHolder;
|
||||
@@ -67,19 +67,11 @@ public class JsfUtils {
|
||||
}
|
||||
|
||||
public static boolean isFlowRequest() {
|
||||
if (RequestContextHolder.getRequestContext() != null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return RequestContextHolder.getRequestContext() != null;
|
||||
}
|
||||
|
||||
public static boolean isAsynchronousFlowRequest() {
|
||||
if (isFlowRequest() && RequestContextHolder.getRequestContext().getExternalContext().isAjaxRequest()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return isFlowRequest() && RequestContextHolder.getRequestContext().getExternalContext().isAjaxRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,11 +18,11 @@ package org.springframework.faces.webflow;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
import javax.faces.view.StateManagementStrategy;
|
||||
import javax.faces.view.ViewDeclarationLanguage;
|
||||
import jakarta.faces.component.UIViewRoot;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.lifecycle.Lifecycle;
|
||||
import jakarta.faces.view.StateManagementStrategy;
|
||||
import jakarta.faces.view.ViewDeclarationLanguage;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -48,7 +48,7 @@ public class JsfView implements View {
|
||||
|
||||
private final RequestContext requestContext;
|
||||
|
||||
private String viewId;
|
||||
private final String viewId;
|
||||
|
||||
/**
|
||||
* Creates a new JSF view.
|
||||
@@ -97,7 +97,7 @@ public class JsfView implements View {
|
||||
FacesContext facesContext = FlowFacesContext.getCurrentInstance();
|
||||
if (facesContext != null) {
|
||||
// Use ExternalContext for multipart request parsing by component libraries
|
||||
return facesContext.getExternalContext().getRequestParameterMap().containsKey("javax.faces.ViewState");
|
||||
return facesContext.getExternalContext().getRequestParameterMap().containsKey("jakarta.faces.ViewState");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -17,19 +17,19 @@ package org.springframework.faces.webflow;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
import javax.el.ValueExpression;
|
||||
import javax.faces.application.ViewHandler;
|
||||
import javax.faces.component.EditableValueHolder;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.component.visit.VisitContext;
|
||||
import javax.faces.component.visit.VisitHint;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.AbortProcessingException;
|
||||
import javax.faces.event.ExceptionQueuedEvent;
|
||||
import javax.faces.event.ExceptionQueuedEventContext;
|
||||
import javax.faces.event.PhaseId;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
import jakarta.el.ValueExpression;
|
||||
import jakarta.faces.application.ViewHandler;
|
||||
import jakarta.faces.component.EditableValueHolder;
|
||||
import jakarta.faces.component.UIComponent;
|
||||
import jakarta.faces.component.UIViewRoot;
|
||||
import jakarta.faces.component.visit.VisitContext;
|
||||
import jakarta.faces.component.visit.VisitHint;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.event.AbortProcessingException;
|
||||
import jakarta.faces.event.ExceptionQueuedEvent;
|
||||
import jakarta.faces.event.ExceptionQueuedEventContext;
|
||||
import jakarta.faces.event.PhaseId;
|
||||
import jakarta.faces.lifecycle.Lifecycle;
|
||||
|
||||
import com.sun.faces.component.CompositeComponentStackManager;
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -159,7 +159,7 @@ public class JsfViewFactory implements ViewFactory {
|
||||
*/
|
||||
private void processTree(FacesContext context, UIComponent component) {
|
||||
|
||||
Object mojarraTreeHandler = null;
|
||||
MojarraProcessTreeHandler mojarraTreeHandler = null;
|
||||
if (isMojarraPresent() && !JsfRuntimeInformation.isMyFacesInUse()) {
|
||||
mojarraTreeHandler = new MojarraProcessTreeHandler().handleBefore(context, component);
|
||||
}
|
||||
@@ -181,7 +181,7 @@ public class JsfViewFactory implements ViewFactory {
|
||||
}
|
||||
|
||||
if (mojarraTreeHandler != null) {
|
||||
((MojarraProcessTreeHandler) mojarraTreeHandler).handleAfter();
|
||||
mojarraTreeHandler.handleAfter();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ public class JsfViewFactory implements ViewFactory {
|
||||
catch (IllegalArgumentException ex) {
|
||||
// JSF < 2.1
|
||||
}
|
||||
String name = "javax.faces.visit.SKIP_ITERATION";
|
||||
String name = "jakarta.faces.visit.SKIP_ITERATION";
|
||||
facesContext.getAttributes().put(name, true);
|
||||
try {
|
||||
VisitContext visitContext = (visitHint != null ?
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
import jakarta.faces.lifecycle.Lifecycle;
|
||||
|
||||
import org.springframework.binding.convert.ConversionService;
|
||||
import org.springframework.binding.expression.Expression;
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.visit.VisitCallback;
|
||||
import javax.faces.component.visit.VisitContext;
|
||||
import javax.faces.component.visit.VisitResult;
|
||||
import javax.faces.event.PostRestoreStateEvent;
|
||||
import jakarta.faces.component.UIComponent;
|
||||
import jakarta.faces.component.visit.VisitCallback;
|
||||
import jakarta.faces.component.visit.VisitContext;
|
||||
import jakarta.faces.component.visit.VisitResult;
|
||||
import jakarta.faces.event.PostRestoreStateEvent;
|
||||
|
||||
/**
|
||||
* A VisitCallback used to deliver a PostRestoreStataEvent similar to
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.faces.webflow;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import jakarta.faces.component.UIViewRoot;
|
||||
|
||||
/**
|
||||
* Holder for the JSF UIViewRoot
|
||||
@@ -26,7 +26,7 @@ import javax.faces.component.UIViewRoot;
|
||||
*/
|
||||
class ViewRootHolder implements Serializable {
|
||||
|
||||
private transient UIViewRoot viewRoot;
|
||||
private final transient UIViewRoot viewRoot;
|
||||
|
||||
public ViewRootHolder(UIViewRoot viewRoot) {
|
||||
this.viewRoot = viewRoot;
|
||||
@@ -36,4 +36,4 @@ class ViewRootHolder implements Serializable {
|
||||
return this.viewRoot;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public abstract class AbstractResourcesConfigurationTests {
|
||||
map = this.context.getBeansOfType(SimpleUrlHandlerMapping.class);
|
||||
assertEquals(1, map.values().size());
|
||||
SimpleUrlHandlerMapping handlerMapping = (SimpleUrlHandlerMapping) map.values().iterator().next();
|
||||
assertSame(resourceHandler, handlerMapping.getHandlerMap().get("/javax.faces.resource/**"));
|
||||
assertSame(resourceHandler, handlerMapping.getHandlerMap().get("/jakarta.faces.resource/**"));
|
||||
assertEquals(0, handlerMapping.getOrder());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.springframework.faces.model;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@@ -8,16 +9,6 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.component.UIColumn;
|
||||
import javax.faces.component.UICommand;
|
||||
import javax.faces.component.UIData;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.AbortProcessingException;
|
||||
import javax.faces.event.ActionEvent;
|
||||
import javax.faces.event.ActionListener;
|
||||
|
||||
|
||||
import org.apache.myfaces.test.mock.MockFacesContext;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -27,6 +18,15 @@ import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import com.sun.faces.facelets.component.UIRepeat;
|
||||
|
||||
import jakarta.faces.component.UIColumn;
|
||||
import jakarta.faces.component.UICommand;
|
||||
import jakarta.faces.component.UIData;
|
||||
import jakarta.faces.component.UIViewRoot;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.event.AbortProcessingException;
|
||||
import jakarta.faces.event.ActionEvent;
|
||||
import jakarta.faces.event.ActionListener;
|
||||
|
||||
public class SelectionTrackingActionListenerTests {
|
||||
|
||||
/**
|
||||
@@ -92,7 +92,7 @@ public class SelectionTrackingActionListenerTests {
|
||||
|
||||
this.dataModel.setRowIndex(2);
|
||||
assertFalse(this.dataModel.isCurrentRowSelected());
|
||||
assertTrue(this.dataModel.getSelectedRow() != this.dataModel.getRowData());
|
||||
assertNotSame(this.dataModel.getSelectedRow(), this.dataModel.getRowData());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -120,14 +120,14 @@ public class SelectionTrackingActionListenerTests {
|
||||
|
||||
ReflectionUtils.invokeMethod(indexMutator, uiRepeat, new MockFacesContext(), 2);
|
||||
assertFalse(this.dataModel.isCurrentRowSelected());
|
||||
assertTrue(this.dataModel.getSelectedRow() != this.dataModel.getRowData());
|
||||
assertNotSame(this.dataModel.getSelectedRow(), this.dataModel.getRowData());
|
||||
}
|
||||
|
||||
private class TestRowData {
|
||||
private static class TestRowData {
|
||||
|
||||
}
|
||||
|
||||
private class TestDelegateActionListener implements ActionListener {
|
||||
private static class TestDelegateActionListener implements ActionListener {
|
||||
|
||||
public boolean processedEvent = false;
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.model.DataModel;
|
||||
import javax.faces.model.ListDataModel;
|
||||
import jakarta.faces.model.DataModel;
|
||||
import jakarta.faces.model.ListDataModel;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.binding.convert.converters.Converter;
|
||||
|
||||
@@ -3,12 +3,12 @@ package org.springframework.faces.model.converter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.model.DataModel;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.binding.convert.ConversionExecutor;
|
||||
|
||||
import jakarta.faces.model.DataModel;
|
||||
|
||||
public class FacesConversionServiceTests {
|
||||
private FacesConversionService service;
|
||||
|
||||
|
||||
@@ -7,9 +7,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -22,6 +19,9 @@ import org.springframework.web.context.support.StaticWebApplicationContext;
|
||||
import org.springframework.web.servlet.View;
|
||||
import org.springframework.web.servlet.view.UrlBasedViewResolver;
|
||||
|
||||
import jakarta.faces.component.UIViewRoot;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
|
||||
public class JsfViewTests {
|
||||
|
||||
UrlBasedViewResolver resolver;
|
||||
@@ -59,7 +59,7 @@ public class JsfViewTests {
|
||||
view.render(new HashMap<>(), new MockHttpServletRequest(), new MockHttpServletResponse());
|
||||
}
|
||||
|
||||
private class ResourceCheckingViewHandler extends MockViewHandler {
|
||||
private static class ResourceCheckingViewHandler extends MockViewHandler {
|
||||
|
||||
public UIViewRoot createView(FacesContext context, String viewId) {
|
||||
assertNotNull(viewId);
|
||||
|
||||
@@ -4,12 +4,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import javax.el.MethodExpression;
|
||||
import javax.el.MethodInfo;
|
||||
import javax.faces.component.UICommand;
|
||||
import javax.faces.event.ActionEvent;
|
||||
|
||||
import org.easymock.EasyMock;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -20,6 +14,12 @@ import org.springframework.webflow.engine.ViewState;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
import org.springframework.webflow.execution.RequestContextHolder;
|
||||
|
||||
import jakarta.el.ELContext;
|
||||
import jakarta.el.MethodExpression;
|
||||
import jakarta.el.MethodInfo;
|
||||
import jakarta.faces.component.UICommand;
|
||||
import jakarta.faces.event.ActionEvent;
|
||||
|
||||
public class FlowActionListenerTests {
|
||||
|
||||
FlowActionListener listener;
|
||||
@@ -78,7 +78,7 @@ public class FlowActionListenerTests {
|
||||
"An unexpected event was signaled");
|
||||
}
|
||||
|
||||
private class MethodExpressionStub extends MethodExpression {
|
||||
private static class MethodExpressionStub extends MethodExpression {
|
||||
|
||||
String result;
|
||||
|
||||
@@ -117,7 +117,7 @@ public class FlowActionListenerTests {
|
||||
}
|
||||
}
|
||||
|
||||
private class MockViewState extends ViewState {
|
||||
private static class MockViewState extends ViewState {
|
||||
|
||||
public MockViewState() {
|
||||
super(new Flow("mockFlow"), "mockView", context -> {
|
||||
|
||||
@@ -7,7 +7,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import jakarta.el.ELContext;
|
||||
|
||||
import org.apache.myfaces.test.el.MockELContext;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
||||
@@ -4,6 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -14,8 +15,8 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.FacesContext;
|
||||
import jakarta.faces.application.FacesMessage;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
|
||||
import org.easymock.EasyMock;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
@@ -44,7 +45,7 @@ public class FlowFacesContextTests {
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
this.jsf.setUp();
|
||||
this.requestContext = (RequestContext) EasyMock.createMock(RequestContext.class);
|
||||
this.requestContext = EasyMock.createMock(RequestContext.class);
|
||||
this.facesContext = new FlowFacesContext(this.requestContext, this.jsf.facesContext());
|
||||
setupMessageContext();
|
||||
}
|
||||
@@ -286,7 +287,7 @@ public class FlowFacesContextTests {
|
||||
|
||||
this.facesContext.addMessage("foo", new FacesMessage(FacesMessage.SEVERITY_ERROR, "foo", "bar"));
|
||||
|
||||
assertEquals(true, this.facesContext.isValidationFailed());
|
||||
assertTrue(this.facesContext.isValidationFailed());
|
||||
}
|
||||
|
||||
private void setupMessageContext() {
|
||||
|
||||
@@ -6,8 +6,8 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.context.PartialViewContext;
|
||||
import javax.faces.context.PartialViewContextWrapper;
|
||||
import jakarta.faces.context.PartialViewContext;
|
||||
import jakarta.faces.context.PartialViewContextWrapper;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class FlowResponseStateManagerTests {
|
||||
|
||||
assertEquals(state, viewMap.get(FlowResponseStateManager.FACES_VIEW_STATE));
|
||||
assertEquals(
|
||||
"<input type=\"hidden\" name=\"javax.faces.ViewState\" id=\"javax.faces.ViewState\" value=\"e1s1\" />",
|
||||
"<input type=\"hidden\" name=\"jakarta.faces.ViewState\" id=\"jakarta.faces.ViewState\" value=\"e1s1\" />",
|
||||
this.jsfMock.contentAsString());
|
||||
EasyMock.verify(this.flowExecutionContext, this.requestContext);
|
||||
}
|
||||
|
||||
@@ -4,16 +4,7 @@ import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
import javax.faces.FactoryFinder;
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.application.ApplicationFactory;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.FacesContextFactory;
|
||||
import javax.faces.lifecycle.LifecycleFactory;
|
||||
import javax.faces.render.RenderKitFactory;
|
||||
|
||||
import org.apache.myfaces.test.base.AbstractJsfTestCase;
|
||||
import org.apache.myfaces.test.base.junit.AbstractJsfTestCase;
|
||||
import org.apache.myfaces.test.mock.MockApplicationFactory;
|
||||
import org.apache.myfaces.test.mock.MockExternalContext;
|
||||
import org.apache.myfaces.test.mock.MockHttpServletRequest;
|
||||
@@ -30,6 +21,15 @@ import org.apache.myfaces.test.mock.lifecycle.MockLifecycle;
|
||||
import org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory;
|
||||
import org.apache.myfaces.test.mock.visit.MockVisitContextFactory;
|
||||
|
||||
import jakarta.faces.FactoryFinder;
|
||||
import jakarta.faces.application.Application;
|
||||
import jakarta.faces.application.ApplicationFactory;
|
||||
import jakarta.faces.component.UIViewRoot;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.context.FacesContextFactory;
|
||||
import jakarta.faces.lifecycle.LifecycleFactory;
|
||||
import jakarta.faces.render.RenderKitFactory;
|
||||
|
||||
/**
|
||||
* Helper for using the mock JSF environment provided by shale-test inside unit tests that do not extend
|
||||
* {@link AbstractJsfTestCase}
|
||||
@@ -106,7 +106,7 @@ public class JSFMockHelper {
|
||||
private ClassLoader threadContextClassLoader;
|
||||
|
||||
public JSFMock() {
|
||||
super("JSFMock");
|
||||
super();
|
||||
}
|
||||
|
||||
FacesContext facesContext;
|
||||
|
||||
@@ -8,20 +8,11 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.FacesException;
|
||||
import javax.faces.application.ViewHandler;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.PhaseEvent;
|
||||
import javax.faces.event.PhaseId;
|
||||
import javax.faces.event.PhaseListener;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
|
||||
import org.apache.el.ExpressionFactoryImpl;
|
||||
import org.easymock.EasyMock;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.apache.el.ExpressionFactoryImpl;
|
||||
import org.springframework.binding.expression.ExpressionParser;
|
||||
import org.springframework.binding.expression.support.FluentParserContext;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
@@ -35,6 +26,15 @@ import org.springframework.webflow.execution.View;
|
||||
import org.springframework.webflow.expression.el.WebFlowELExpressionParser;
|
||||
import org.springframework.webflow.test.MockExternalContext;
|
||||
|
||||
import jakarta.faces.FacesException;
|
||||
import jakarta.faces.application.ViewHandler;
|
||||
import jakarta.faces.component.UIViewRoot;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.event.PhaseEvent;
|
||||
import jakarta.faces.event.PhaseId;
|
||||
import jakarta.faces.event.PhaseListener;
|
||||
import jakarta.faces.lifecycle.Lifecycle;
|
||||
|
||||
public class JsfFinalResponseActionTests {
|
||||
|
||||
private static final String VIEW_ID = "/testView.xhtml";
|
||||
@@ -47,10 +47,6 @@ public class JsfFinalResponseActionTests {
|
||||
|
||||
private final ViewHandler viewHandler = new NoRenderViewHandler();
|
||||
|
||||
private TestLifecycle lifecycle;
|
||||
|
||||
private PhaseListener trackingListener;
|
||||
|
||||
ExpressionParser parser = new WebFlowELExpressionParser(new ExpressionFactoryImpl());
|
||||
|
||||
@BeforeEach
|
||||
@@ -68,13 +64,13 @@ public class JsfFinalResponseActionTests {
|
||||
|
||||
this.jsfMock.setUp();
|
||||
|
||||
this.trackingListener = new TrackingPhaseListener();
|
||||
this.jsfMock.lifecycle().addPhaseListener(this.trackingListener);
|
||||
PhaseListener trackingListener = new TrackingPhaseListener();
|
||||
this.jsfMock.lifecycle().addPhaseListener(trackingListener);
|
||||
this.jsfMock.facesContext().setViewRoot(null);
|
||||
this.jsfMock.facesContext().getApplication().setViewHandler(this.viewHandler);
|
||||
this.lifecycle = new TestLifecycle(this.jsfMock.lifecycle());
|
||||
TestLifecycle lifecycle = new TestLifecycle(this.jsfMock.lifecycle());
|
||||
this.factory = new JsfViewFactory(this.parser.parseExpression("#{'" + VIEW_ID + "'}", new FluentParserContext()
|
||||
.template().evaluate(RequestContext.class).expectResult(String.class)), this.lifecycle);
|
||||
.template().evaluate(RequestContext.class).expectResult(String.class)), lifecycle);
|
||||
RequestContextHolder.setRequestContext(this.context);
|
||||
MockExternalContext ext = new MockExternalContext();
|
||||
ext.setNativeContext(new MockServletContext());
|
||||
@@ -97,7 +93,7 @@ public class JsfFinalResponseActionTests {
|
||||
this.context.inViewState();
|
||||
EasyMock.expectLastCall().andReturn(false);
|
||||
|
||||
EasyMock.replay(new Object[] { this.context });
|
||||
EasyMock.replay(this.context);
|
||||
|
||||
View view = this.factory.getView(this.context);
|
||||
((JsfView) view).getViewRoot().setTransient(true);
|
||||
@@ -107,7 +103,7 @@ public class JsfFinalResponseActionTests {
|
||||
assertTrue(((NoRenderViewHandler) this.viewHandler).rendered);
|
||||
}
|
||||
|
||||
private class TestLifecycle extends FlowLifecycle {
|
||||
private static class TestLifecycle extends FlowLifecycle {
|
||||
|
||||
boolean executed = false;
|
||||
|
||||
@@ -123,7 +119,7 @@ public class JsfFinalResponseActionTests {
|
||||
|
||||
}
|
||||
|
||||
private class TrackingPhaseListener implements PhaseListener {
|
||||
private static class TrackingPhaseListener implements PhaseListener {
|
||||
|
||||
private final List<String> phaseCallbacks = new ArrayList<>();
|
||||
|
||||
@@ -146,10 +142,10 @@ public class JsfFinalResponseActionTests {
|
||||
}
|
||||
}
|
||||
|
||||
private class NoRenderViewHandler extends MockViewHandler {
|
||||
private static class NoRenderViewHandler extends MockViewHandler {
|
||||
boolean rendered = false;
|
||||
|
||||
public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException, FacesException {
|
||||
public void renderView(FacesContext context, UIViewRoot viewToRender) throws FacesException {
|
||||
this.rendered = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,27 +4,27 @@ import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.application.ApplicationFactory;
|
||||
import javax.faces.context.FacesContextFactory;
|
||||
import javax.faces.event.PhaseEvent;
|
||||
import javax.faces.event.PhaseId;
|
||||
import javax.faces.event.PhaseListener;
|
||||
import javax.faces.lifecycle.LifecycleFactory;
|
||||
import javax.faces.render.RenderKitFactory;
|
||||
|
||||
import org.apache.myfaces.test.base.AbstractJsfTestCase;
|
||||
import org.apache.myfaces.test.base.junit.AbstractJsfTestCase;
|
||||
import org.apache.myfaces.test.mock.MockApplicationFactory;
|
||||
import org.apache.myfaces.test.mock.MockFacesContext20;
|
||||
import org.apache.myfaces.test.mock.MockFacesContext;
|
||||
import org.apache.myfaces.test.mock.MockFacesContextFactory;
|
||||
import org.apache.myfaces.test.mock.MockRenderKitFactory;
|
||||
import org.apache.myfaces.test.mock.lifecycle.MockLifecycle;
|
||||
import org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory;
|
||||
import org.junit.Test;
|
||||
|
||||
import jakarta.faces.application.ApplicationFactory;
|
||||
import jakarta.faces.context.FacesContextFactory;
|
||||
import jakarta.faces.event.PhaseEvent;
|
||||
import jakarta.faces.event.PhaseId;
|
||||
import jakarta.faces.event.PhaseListener;
|
||||
import jakarta.faces.lifecycle.LifecycleFactory;
|
||||
import jakarta.faces.render.RenderKitFactory;
|
||||
|
||||
public class JsfUtilsTests extends AbstractJsfTestCase {
|
||||
|
||||
public JsfUtilsTests(String name) {
|
||||
super(name);
|
||||
public JsfUtilsTests() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -37,7 +37,7 @@ public class JsfUtilsTests extends AbstractJsfTestCase {
|
||||
lifecycle.addPhaseListener(listener2);
|
||||
PhaseListener listener3 = new OrderVerifyingPhaseListener(null, list);
|
||||
lifecycle.addPhaseListener(listener3);
|
||||
JsfUtils.notifyBeforeListeners(PhaseId.ANY_PHASE, lifecycle, new MockFacesContext20());
|
||||
JsfUtils.notifyBeforeListeners(PhaseId.ANY_PHASE, lifecycle, new MockFacesContext());
|
||||
assertEquals(listener1, list.get(0));
|
||||
assertEquals(listener2, list.get(1));
|
||||
assertEquals(listener3, list.get(2));
|
||||
@@ -53,7 +53,7 @@ public class JsfUtilsTests extends AbstractJsfTestCase {
|
||||
lifecycle.addPhaseListener(listener2);
|
||||
PhaseListener listener3 = new OrderVerifyingPhaseListener(list, null);
|
||||
lifecycle.addPhaseListener(listener3);
|
||||
JsfUtils.notifyAfterListeners(PhaseId.ANY_PHASE, lifecycle, new MockFacesContext20());
|
||||
JsfUtils.notifyAfterListeners(PhaseId.ANY_PHASE, lifecycle, new MockFacesContext());
|
||||
assertEquals(listener3, list.get(0));
|
||||
assertEquals(listener2, list.get(1));
|
||||
assertEquals(listener1, list.get(2));
|
||||
@@ -78,7 +78,7 @@ public class JsfUtilsTests extends AbstractJsfTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
private class OrderVerifyingPhaseListener implements PhaseListener {
|
||||
private static class OrderVerifyingPhaseListener implements PhaseListener {
|
||||
|
||||
private final List<OrderVerifyingPhaseListener> afterPhaseList;
|
||||
private final List<OrderVerifyingPhaseListener> beforePhaseList;
|
||||
|
||||
@@ -10,23 +10,6 @@ import static org.junit.jupiter.api.Assertions.fail;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import javax.faces.FacesException;
|
||||
import javax.faces.application.ViewHandler;
|
||||
import javax.faces.component.UIInput;
|
||||
import javax.faces.component.UIOutput;
|
||||
import javax.faces.component.UIPanel;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.AbortProcessingException;
|
||||
import javax.faces.event.ComponentSystemEvent;
|
||||
import javax.faces.event.ExceptionQueuedEvent;
|
||||
import javax.faces.event.ExceptionQueuedEventContext;
|
||||
import javax.faces.event.PhaseEvent;
|
||||
import javax.faces.event.PhaseId;
|
||||
import javax.faces.event.PhaseListener;
|
||||
import javax.faces.event.PostRestoreStateEvent;
|
||||
import javax.faces.event.SystemEvent;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
|
||||
import org.apache.el.ExpressionFactoryImpl;
|
||||
import org.apache.myfaces.test.mock.MockApplication20;
|
||||
@@ -51,6 +34,24 @@ import org.springframework.webflow.execution.ViewFactory;
|
||||
import org.springframework.webflow.expression.el.WebFlowELExpressionParser;
|
||||
import org.springframework.webflow.test.MockExternalContext;
|
||||
|
||||
import jakarta.faces.FacesException;
|
||||
import jakarta.faces.application.ViewHandler;
|
||||
import jakarta.faces.component.UIInput;
|
||||
import jakarta.faces.component.UIOutput;
|
||||
import jakarta.faces.component.UIPanel;
|
||||
import jakarta.faces.component.UIViewRoot;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.event.AbortProcessingException;
|
||||
import jakarta.faces.event.ComponentSystemEvent;
|
||||
import jakarta.faces.event.ExceptionQueuedEvent;
|
||||
import jakarta.faces.event.ExceptionQueuedEventContext;
|
||||
import jakarta.faces.event.PhaseEvent;
|
||||
import jakarta.faces.event.PhaseId;
|
||||
import jakarta.faces.event.PhaseListener;
|
||||
import jakarta.faces.event.PostRestoreStateEvent;
|
||||
import jakarta.faces.event.SystemEvent;
|
||||
import jakarta.faces.lifecycle.Lifecycle;
|
||||
|
||||
public class JsfViewFactoryTests {
|
||||
|
||||
private static final String VIEW_ID = "/testView.xhtml";
|
||||
@@ -184,10 +185,15 @@ public class JsfViewFactoryTests {
|
||||
UIPanel panel = new UIPanel();
|
||||
panel.setId("panel1");
|
||||
UIOutput output = new UIOutput();
|
||||
output.setValueBinding("binding", this.jsfMock.facesContext().getApplication().createValueBinding("#{myBean.output}"));
|
||||
FacesContext facesContext = this.jsfMock.facesContext();
|
||||
output.setValueExpression("binding",
|
||||
facesContext.getApplication().getExpressionFactory().createValueExpression(
|
||||
facesContext.getELContext(), "#{myBean.output}", UIOutput.class));
|
||||
output.setId("output1");
|
||||
UIInput input = new UIInput();
|
||||
input.setValueBinding("binding", this.jsfMock.facesContext().getApplication().createValueBinding("#{myBean.input}"));
|
||||
input.setValueExpression("binding",
|
||||
facesContext.getApplication().getExpressionFactory().createValueExpression(
|
||||
facesContext.getELContext(), "#{myBean.input}", UIInput.class));
|
||||
input.setId("input1");
|
||||
|
||||
existingRoot.getChildren().add(panel);
|
||||
@@ -245,7 +251,7 @@ public class JsfViewFactoryTests {
|
||||
|
||||
assertNotNull(restoredView, "A View was not restored");
|
||||
assertTrue(restoredView instanceof JsfView, "A JsfView was expected");
|
||||
assertTrue(((JsfView) restoredView).getViewRoot() != null, "An ViewRoot was not set");
|
||||
assertNotNull(((JsfView) restoredView).getViewRoot(), "An ViewRoot was not set");
|
||||
assertEquals(VIEW_ID, ((JsfView) restoredView).getViewRoot().getViewId(), "View name did not match");
|
||||
assertFalse(restoredView.hasFlowEvent(), "An unexpected event was signaled,");
|
||||
assertTrue(existingRoot.isPostRestoreStateEventSeen(), "The PostRestoreViewEvent was not seen");
|
||||
@@ -302,7 +308,7 @@ public class JsfViewFactoryTests {
|
||||
application.getExceptionQueuedEventContext().getException(), "Expected same exception");
|
||||
}
|
||||
|
||||
private class NoExecutionLifecycle extends FlowLifecycle {
|
||||
private static class NoExecutionLifecycle extends FlowLifecycle {
|
||||
|
||||
public NoExecutionLifecycle(Lifecycle delegate) {
|
||||
super(delegate);
|
||||
@@ -313,7 +319,7 @@ public class JsfViewFactoryTests {
|
||||
}
|
||||
}
|
||||
|
||||
private class TrackingPhaseListener implements PhaseListener {
|
||||
private static class TrackingPhaseListener implements PhaseListener {
|
||||
|
||||
private final List<String> phaseCallbacks = new ArrayList<>();
|
||||
|
||||
@@ -336,7 +342,7 @@ public class JsfViewFactoryTests {
|
||||
}
|
||||
}
|
||||
|
||||
private class NormalViewState implements StateDefinition {
|
||||
private static class NormalViewState implements StateDefinition {
|
||||
|
||||
public boolean isViewState() {
|
||||
return true;
|
||||
@@ -363,7 +369,7 @@ public class JsfViewFactoryTests {
|
||||
}
|
||||
}
|
||||
|
||||
protected class TestBean {
|
||||
public static class TestBean {
|
||||
|
||||
UIOutput output;
|
||||
UIInput input;
|
||||
|
||||
@@ -6,14 +6,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import javax.faces.FacesException;
|
||||
import javax.faces.component.UIForm;
|
||||
import javax.faces.component.UIInput;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.component.html.HtmlForm;
|
||||
import javax.faces.component.html.HtmlInputText;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
|
||||
import org.apache.myfaces.test.mock.MockResponseWriter;
|
||||
import org.easymock.EasyMock;
|
||||
@@ -28,6 +20,15 @@ import org.springframework.webflow.execution.RequestContextHolder;
|
||||
import org.springframework.webflow.test.MockExternalContext;
|
||||
import org.springframework.webflow.test.MockParameterMap;
|
||||
|
||||
import jakarta.faces.FacesException;
|
||||
import jakarta.faces.component.UIForm;
|
||||
import jakarta.faces.component.UIInput;
|
||||
import jakarta.faces.component.UIViewRoot;
|
||||
import jakarta.faces.component.html.HtmlForm;
|
||||
import jakarta.faces.component.html.HtmlInputText;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.lifecycle.Lifecycle;
|
||||
|
||||
public class JsfViewTests {
|
||||
|
||||
private static final String VIEW_ID = "testView.xhtml";
|
||||
@@ -44,9 +45,7 @@ public class JsfViewTests {
|
||||
|
||||
private final RequestContext context = EasyMock.createMock(RequestContext.class);
|
||||
private final FlowExecutionContext flowExecutionContext = EasyMock.createMock(FlowExecutionContext.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
private final MutableAttributeMap<Object> flashScope = EasyMock.createMock(MutableAttributeMap.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
private final MutableAttributeMap<Object> flowMap = EasyMock.createMock(MutableAttributeMap.class);
|
||||
|
||||
private final FlowExecutionKey key = new FlowExecutionKey() {
|
||||
@@ -130,7 +129,7 @@ public class JsfViewTests {
|
||||
|
||||
try {
|
||||
this.view.render();
|
||||
} catch (Exception ex) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +144,7 @@ public class JsfViewTests {
|
||||
EasyMock.expect(this.flashScope.put(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY), EasyMock.anyObject()))
|
||||
.andStubReturn(null);
|
||||
|
||||
Lifecycle lifecycle = new NoEventLifecycle(this.jsfMock.lifecycle());
|
||||
NoEventLifecycle lifecycle = new NoEventLifecycle(this.jsfMock.lifecycle());
|
||||
|
||||
UIViewRoot existingRoot = new UIViewRoot();
|
||||
existingRoot.setViewId(VIEW_ID);
|
||||
@@ -157,7 +156,7 @@ public class JsfViewTests {
|
||||
restoredView.processUserEvent();
|
||||
|
||||
assertFalse(restoredView.hasFlowEvent(), "An unexpected event was signaled,");
|
||||
assertTrue(((NoEventLifecycle) lifecycle).executed, "The lifecycle should have been invoked");
|
||||
assertTrue(lifecycle.executed, "The lifecycle should have been invoked");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,7 +170,7 @@ public class JsfViewTests {
|
||||
EasyMock.expect(this.flashScope.put(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY), EasyMock.anyObject()))
|
||||
.andStubReturn(null);
|
||||
|
||||
Lifecycle lifecycle = new EventSignalingLifecycle(this.jsfMock.lifecycle());
|
||||
EventSignalingLifecycle lifecycle = new EventSignalingLifecycle(this.jsfMock.lifecycle());
|
||||
|
||||
UIViewRoot existingRoot = new UIViewRoot();
|
||||
existingRoot.setViewId(VIEW_ID);
|
||||
@@ -184,7 +183,7 @@ public class JsfViewTests {
|
||||
|
||||
assertTrue(restoredView.hasFlowEvent(), "No event was signaled,");
|
||||
assertEquals(this.event, restoredView.getFlowEvent().getId(), "Event should be " + this.event);
|
||||
assertTrue(((EventSignalingLifecycle) lifecycle).executed, "The lifecycle should have been invoked");
|
||||
assertTrue(lifecycle.executed, "The lifecycle should have been invoked");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -205,7 +204,7 @@ public class JsfViewTests {
|
||||
public final void testUserEventQueued_FormSubmitted() {
|
||||
|
||||
this.jsfMock.request().addParameter("execution", "e1s1");
|
||||
this.jsfMock.request().addParameter("javax.faces.ViewState", "e1s1");
|
||||
this.jsfMock.request().addParameter("jakarta.faces.ViewState", "e1s1");
|
||||
|
||||
EasyMock.replay(this.context, this.flowExecutionContext, this.flowMap, this.flashScope);
|
||||
|
||||
@@ -214,13 +213,13 @@ public class JsfViewTests {
|
||||
assertTrue(createdView.userEventQueued(), "User event should be queued");
|
||||
}
|
||||
|
||||
private class ExceptionalViewHandler extends MockViewHandler {
|
||||
private static class ExceptionalViewHandler extends MockViewHandler {
|
||||
public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException, FacesException {
|
||||
throw new IOException("Rendering blew up");
|
||||
}
|
||||
}
|
||||
|
||||
private class NoEventLifecycle extends FlowLifecycle {
|
||||
private static class NoEventLifecycle extends FlowLifecycle {
|
||||
|
||||
boolean executed = false;
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@ package org.springframework.faces.webflow;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.FactoryFinder;
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.application.ApplicationFactory;
|
||||
import javax.faces.context.ExternalContext;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
|
||||
import org.apache.myfaces.test.mock.MockFacesContext20;
|
||||
|
||||
import jakarta.faces.FactoryFinder;
|
||||
import jakarta.faces.application.Application;
|
||||
import jakarta.faces.application.ApplicationFactory;
|
||||
import jakarta.faces.context.ExternalContext;
|
||||
import jakarta.faces.lifecycle.Lifecycle;
|
||||
|
||||
public class MockBaseFacesContext extends MockFacesContext20 {
|
||||
|
||||
private Application application;
|
||||
@@ -30,6 +30,11 @@ public class MockBaseFacesContext extends MockFacesContext20 {
|
||||
return super.getAttributes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Lifecycle getLifecycle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Application getApplication() {
|
||||
if (this.application == null) {
|
||||
ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import javax.faces.FacesException;
|
||||
import javax.faces.context.ExternalContext;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.FacesContextFactory;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.myfaces.test.mock.MockExternalContext20;
|
||||
import org.apache.myfaces.test.mock.MockExternalContext;
|
||||
import org.apache.myfaces.test.mock.MockHttpServletResponse;
|
||||
|
||||
import jakarta.faces.FacesException;
|
||||
import jakarta.faces.context.ExternalContext;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.context.FacesContextFactory;
|
||||
import jakarta.faces.lifecycle.Lifecycle;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
public class MockBaseFacesContextFactory extends FacesContextFactory {
|
||||
|
||||
public FacesContext getFacesContext(Object context, Object request, Object response, Lifecycle lifecycle)
|
||||
@@ -22,7 +22,7 @@ public class MockBaseFacesContextFactory extends FacesContextFactory {
|
||||
return FacesContext.getCurrentInstance();
|
||||
} else {
|
||||
|
||||
ExternalContext ext = new MockExternalContext20((ServletContext) context, (HttpServletRequest) request,
|
||||
ExternalContext ext = new MockExternalContext((ServletContext) context, (HttpServletRequest) request,
|
||||
(HttpServletResponse) response) {
|
||||
|
||||
public void setResponseBufferSize(int size) {
|
||||
@@ -33,6 +33,10 @@ public class MockBaseFacesContextFactory extends FacesContextFactory {
|
||||
((MockHttpServletResponse) getResponse()).setContentLength(length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
}
|
||||
|
||||
public void setResponseContentType(String contentType) {
|
||||
((MockHttpServletResponse) getResponse()).setContentType(contentType);
|
||||
}
|
||||
|
||||
@@ -17,15 +17,16 @@ package org.springframework.faces.webflow;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.application.FacesMessage.Severity;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.ExternalContext;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.ResponseStream;
|
||||
import javax.faces.context.ResponseWriter;
|
||||
import javax.faces.render.RenderKit;
|
||||
import jakarta.faces.application.Application;
|
||||
import jakarta.faces.application.FacesMessage;
|
||||
import jakarta.faces.application.FacesMessage.Severity;
|
||||
import jakarta.faces.component.UIViewRoot;
|
||||
import jakarta.faces.context.ExternalContext;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.faces.context.ResponseStream;
|
||||
import jakarta.faces.context.ResponseWriter;
|
||||
import jakarta.faces.lifecycle.Lifecycle;
|
||||
import jakarta.faces.render.RenderKit;
|
||||
|
||||
/**
|
||||
* Mock implementation of the <code>FacesContext</code> class to facilitate standalone Action unit tests.
|
||||
@@ -35,7 +36,7 @@ import javax.faces.render.RenderKit;
|
||||
* Fowler's</a> reasoning. This class is called <i>Mock</i>FacesContext to be consistent with the naming convention in
|
||||
* the rest of the Spring framework (e.g. MockHttpServletRequest, ...).
|
||||
*
|
||||
* @see javax.faces.context.FacesContext
|
||||
* @see jakarta.faces.context.FacesContext
|
||||
*
|
||||
* @author Ulrik Sandberg
|
||||
*/
|
||||
@@ -62,6 +63,11 @@ public class MockFacesContext extends FacesContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Lifecycle getLifecycle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ExternalContext getExternalContext() {
|
||||
return this.externalContext;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.security.Principal;
|
||||
@@ -27,7 +26,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.faces.context.ExternalContext;
|
||||
import jakarta.faces.context.ExternalContext;
|
||||
|
||||
public class MockJsfExternalContext extends ExternalContext {
|
||||
|
||||
@@ -39,7 +38,7 @@ public class MockJsfExternalContext extends ExternalContext {
|
||||
|
||||
private Map<String, String> requestParameterMap = Collections.emptyMap();
|
||||
|
||||
public void dispatch(String arg0) throws IOException {
|
||||
public void dispatch(String arg0) {
|
||||
}
|
||||
|
||||
public String encodeActionURL(String arg0) {
|
||||
@@ -54,6 +53,11 @@ public class MockJsfExternalContext extends ExternalContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodeWebsocketURL(String url) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map<String, Object> getApplicationMap() {
|
||||
return this.applicationMap;
|
||||
}
|
||||
@@ -70,7 +74,7 @@ public class MockJsfExternalContext extends ExternalContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map<String, Object> getInitParameterMap() {
|
||||
public Map<String, String> getInitParameterMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -184,6 +188,11 @@ public class MockJsfExternalContext extends ExternalContext {
|
||||
public void log(String arg0, Throwable arg1) {
|
||||
}
|
||||
|
||||
public void redirect(String arg0) throws IOException {
|
||||
public void redirect(String arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ package org.springframework.faces.webflow;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.faces.FacesException;
|
||||
import javax.faces.application.ViewHandler;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.FacesContext;
|
||||
import jakarta.faces.FacesException;
|
||||
import jakarta.faces.application.ViewHandler;
|
||||
import jakarta.faces.component.UIViewRoot;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
|
||||
public class MockViewHandler extends ViewHandler {
|
||||
private UIViewRoot createViewRoot;
|
||||
@@ -68,6 +68,11 @@ public class MockViewHandler extends ViewHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWebsocketURL(FacesContext context, String channel) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Really simple implementation to exercise rendering and state saving
|
||||
*/
|
||||
@@ -82,4 +87,4 @@ public class MockViewHandler extends ViewHandler {
|
||||
|
||||
public void writeState(FacesContext context) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ dependencies {
|
||||
testImplementation("org.springframework:spring-jdbc")
|
||||
testImplementation("org.springframework:spring-test")
|
||||
testImplementation("org.hibernate:hibernate-entitymanager")
|
||||
testImplementation("org.hibernate:hibernate-validator")
|
||||
testImplementation("org.hibernate.validator:hibernate-validator")
|
||||
testImplementation("org.hsqldb:hsqldb")
|
||||
testImplementation("jakarta.servlet.jsp:jakarta.servlet.jsp-api")
|
||||
testImplementation("jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api")
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.springframework.webflow.mvc.view.FlowViewResolver;
|
||||
*/
|
||||
public class FlowResourceFlowViewResolver implements FlowViewResolver {
|
||||
|
||||
private static final boolean JSTL_PRESENT = ClassUtils.isPresent("javax.servlet.jsp.jstl.fmt.LocalizationContext", FlowResourceFlowViewResolver.class.getClassLoader());
|
||||
private static final boolean JSTL_PRESENT = ClassUtils.isPresent("jakarta.servlet.jsp.jstl.fmt.LocalizationContext", FlowResourceFlowViewResolver.class.getClassLoader());
|
||||
|
||||
private String defaultViewSuffix = ".jsp";
|
||||
|
||||
@@ -95,4 +95,4 @@ public class FlowResourceFlowViewResolver implements FlowViewResolver {
|
||||
+ " only types supported by this FlowViewResolver implementation are [.jsp] and [.jspx]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user