Permalink
Browse files

JSF 2.2 --> JSF 2.3 migration

  • Loading branch information...
BalusC committed Apr 8, 2017
1 parent 804ad96 commit e2d03d9cc407cd1f991c5994cba68b76a34fb1a5
Showing with 145 additions and 293 deletions.
  1. +1 −1 pom.xml
  2. +2 −7 src/main/java/org/omnifaces/application/OmniApplication.java
  3. +3 −12 src/main/java/org/omnifaces/application/OmniApplicationFactory.java
  4. +1 −0 src/main/java/org/omnifaces/cdi/Param.java
  5. +2 −1 src/main/java/org/omnifaces/cdi/converter/ConverterManager.java
  6. +1 −0 src/main/java/org/omnifaces/cdi/eager/EagerExtension.java
  7. +3 −4 src/main/java/org/omnifaces/cdi/param/ParamProducer.java
  8. +1 −0 src/main/java/org/omnifaces/cdi/validator/ValidatorManager.java
  9. +1 −0 src/main/java/org/omnifaces/component/SimpleParam.java
  10. +4 −30 src/main/java/org/omnifaces/component/input/Form.java
  11. +2 −9 src/main/java/org/omnifaces/component/input/componentidparam/ConditionalResponseWriter.java
  12. +5 −2 src/main/java/org/omnifaces/component/output/Param.java
  13. +2 −6 src/main/java/org/omnifaces/component/script/OnloadScript.java
  14. +1 −10 src/main/java/org/omnifaces/context/OmniExternalContext.java
  15. +2 −14 src/main/java/org/omnifaces/context/OmniExternalContextFactory.java
  16. +1 −7 src/main/java/org/omnifaces/context/OmniPartialViewContext.java
  17. +2 −14 src/main/java/org/omnifaces/context/OmniPartialViewContextFactory.java
  18. +7 −14 src/main/java/org/omnifaces/converter/GenericEnumConverter.java
  19. +1 −1 src/main/java/org/omnifaces/converter/ListConverter.java
  20. +1 −1 src/main/java/org/omnifaces/converter/ListIndexConverter.java
  21. +1 −1 src/main/java/org/omnifaces/converter/SelectItemsConverter.java
  22. +1 −1 src/main/java/org/omnifaces/converter/SelectItemsIndexConverter.java
  23. +6 −5 src/main/java/org/omnifaces/converter/ToCollectionConverter.java
  24. +2 −2 src/main/java/org/omnifaces/converter/ToLowerCaseConverter.java
  25. +2 −2 src/main/java/org/omnifaces/converter/ToUpperCaseConverter.java
  26. +5 −4 src/main/java/org/omnifaces/converter/TrimConverter.java
  27. +1 −1 src/main/java/org/omnifaces/converter/ValueChangeConverter.java
  28. +2 −2 src/main/java/org/omnifaces/eventlistener/BeanValidationEventListener.java
  29. +1 −15 src/main/java/org/omnifaces/exceptionhandler/DefaultExceptionHandlerFactory.java
  30. +2 −11 src/main/java/org/omnifaces/exceptionhandler/FacesMessageExceptionHandler.java
  31. +2 −8 src/main/java/org/omnifaces/exceptionhandler/FullAjaxExceptionHandler.java
  32. +2 −8 src/main/java/org/omnifaces/facesviews/FacesViewsViewHandler.java
  33. +11 −0 src/main/java/org/omnifaces/io/DefaultServletOutputStream.java
  34. +1 −10 src/main/java/org/omnifaces/resourcehandler/DefaultResourceHandler.java
  35. +4 −6 src/main/java/org/omnifaces/resourcehandler/GraphicResource.java
  36. +1 −1 src/main/java/org/omnifaces/servlet/GzipHttpServletResponse.java
  37. +2 −2 src/main/java/org/omnifaces/taghandler/Converter.java
  38. +4 −4 src/main/java/org/omnifaces/taghandler/SkipValidators.java
  39. +3 −3 src/main/java/org/omnifaces/taghandler/ValidateBean.java
  40. +2 −2 src/main/java/org/omnifaces/taghandler/Validator.java
  41. +2 −8 src/main/java/org/omnifaces/util/Components.java
  42. +12 −6 src/main/java/org/omnifaces/util/Faces.java
  43. +23 −19 src/main/java/org/omnifaces/util/FacesLocal.java
  44. +3 −3 src/main/java/org/omnifaces/util/selectitems/SelectItemsUtils.java
  45. +2 −2 src/main/java/org/omnifaces/validator/RequiredCheckboxValidator.java
  46. +1 −1 src/main/java/org/omnifaces/validator/ValueChangeValidator.java
  47. +3 −23 src/main/java/org/omnifaces/viewhandler/NoAutoGeneratedIdViewHandler.java
  48. +1 −10 src/main/java/org/omnifaces/viewhandler/OmniViewHandler.java
View
@@ -446,7 +446,7 @@
<profile>
<id>wildfly</id>
<activation>
<activeByDefault>true</activeByDefault>
<activeByDefault>false</activeByDefault><!-- TODO: put back to 'true' once figured out how to upgrade it to JSF 2.3 via Maven -->
</activation>
<dependencies>
<dependency>
@@ -46,11 +46,11 @@
* @see ValidatorManager
* @since 1.6
*/
@SuppressWarnings("rawtypes")
public class OmniApplication extends ApplicationWrapper {
// Variables ------------------------------------------------------------------------------------------------------
private final Application wrapped;
private final ConverterManager converterManager;
private final ValidatorManager validatorManager;
private final TimeZone dateTimeConverterDefaultTimeZone;
@@ -62,7 +62,7 @@
* @param wrapped The wrapped application.
*/
public OmniApplication(Application wrapped) {
this.wrapped = wrapped;
super(wrapped);
converterManager = getReference(ConverterManager.class);
validatorManager = getReference(ValidatorManager.class);
dateTimeConverterDefaultTimeZone =
@@ -120,11 +120,6 @@ public Validator createValidator(String validatorId) {
return super.createValidator(validatorId);
}
@Override
public Application getWrapped() {
return wrapped;
}
// Helpers --------------------------------------------------------------------------------------------------------
private void setDefaultPropertiesIfNecessary(Converter converter) {
@@ -28,7 +28,6 @@
// Variables ------------------------------------------------------------------------------------------------------
private final ApplicationFactory wrapped;
private volatile Application application;
// Constructors ---------------------------------------------------------------------------------------------------
@@ -38,7 +37,7 @@
* @param wrapped The wrapped factory.
*/
public OmniApplicationFactory(ApplicationFactory wrapped) {
this.wrapped = wrapped;
super(wrapped);
}
// Actions --------------------------------------------------------------------------------------------------------
@@ -48,7 +47,7 @@ public OmniApplicationFactory(ApplicationFactory wrapped) {
*/
@Override
public Application getApplication() {
return (application == null) ? createOmniApplication(wrapped.getApplication()) : application;
return (application == null) ? createOmniApplication(getWrapped().getApplication()) : application;
}
/**
@@ -57,15 +56,7 @@ public Application getApplication() {
*/
@Override
public void setApplication(Application application) {
wrapped.setApplication(createOmniApplication(application));
}
/**
* Returns the wrapped factory.
*/
@Override
public ApplicationFactory getWrapped() {
return wrapped;
getWrapped().setApplication(createOmniApplication(application));
}
// Helpers --------------------------------------------------------------------------------------------------------
@@ -163,6 +163,7 @@
@Qualifier
@Retention(RUNTIME)
@Target({ METHOD, FIELD, PARAMETER })
@SuppressWarnings("rawtypes")
public @interface Param {
/**
@@ -91,6 +91,7 @@
* @since 1.6
*/
@ApplicationScoped
@SuppressWarnings("rawtypes")
public class ConverterManager {
// Dependencies ---------------------------------------------------------------------------------------------------
@@ -120,7 +121,7 @@ public Converter createConverter(Application application, String converterId) {
if (converter != null) {
Class<? extends Converter> converterClass = converter.getClass();
bean = (Bean<Converter>) resolve(manager, converterClass);
if (bean != null && bean.getBeanClass() != converterClass) {
bean = null;
}
@@ -78,6 +78,7 @@ else if (getAnnotation(beanManager, annotated, RequestScoped.class) != null) {
}
}
@SuppressWarnings("unused")
public void load(@Observes AfterDeploymentValidation event, BeanManager beanManager) {
if (eagerBeans.isEmpty()) {
@@ -71,6 +71,7 @@
* @author Arjan Tijms
*/
@Dependent
@SuppressWarnings({"rawtypes", "unchecked"}) // For now.
public class ParamProducer {
private static final String DEFAULT_REQUIRED_MESSAGE = "{0}: Value is required";
@@ -174,7 +175,6 @@ private static boolean interpretEmptyStringSubmittedValuesAsNull(FacesContext co
return interpretEmptyStringSubmittedValuesAsNull;
}
@SuppressWarnings("unchecked")
static <V> V coerceValues(Type type, Object... values) {
if (type instanceof ParameterizedType) {
return coerceValues(((ParameterizedType) type).getRawType(), values);
@@ -297,7 +297,6 @@ private static Converter getConverter(Param requestParameter, Class<?> targetTyp
return converter;
}
@SuppressWarnings("unchecked")
private static <V> Class<V> getTargetType(Type type) {
if (type instanceof Class && ((Class<?>) type).isArray()) {
return (Class<V>) ((Class<?>) type).getComponentType();
@@ -379,7 +378,6 @@ private static boolean shouldDoBeanValidation(Param requestParameter) {
return isBeanValidationAvailable();
}
@SuppressWarnings({ "rawtypes", "unchecked" })
private static <V> Set<ConstraintViolation<?>> doBeanValidation(V paramValue, InjectionPoint injectionPoint) {
Class<?> base = injectionPoint.getBean().getBeanClass();
@@ -406,7 +404,8 @@ private static boolean shouldDoBeanValidation(Param requestParameter) {
List<Validator> validators = new ArrayList<>();
for (String validatorIdentifier : requestParameter.validators()) {
Validator validator = createValidator(evaluateExpressionGet(validatorIdentifier));
Object evaluatedValidatorIdentifier = evaluateExpressionGet(validatorIdentifier);
Validator validator = createValidator(evaluatedValidatorIdentifier);
if (validator != null) {
validators.add(validator);
@@ -80,6 +80,7 @@
* @since 1.6
*/
@ApplicationScoped
@SuppressWarnings("rawtypes")
public class ValidatorManager {
// Dependencies ---------------------------------------------------------------------------------------------------
@@ -24,6 +24,7 @@
* @author Bauke Scholtz
* @since 1.7
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public class SimpleParam implements ParamHolder {
// Properties -----------------------------------------------------------------------------------------------------
@@ -256,10 +256,8 @@ public void setIgnoreValidationFailed(boolean ignoreValidationFailed) {
*/
private static class IgnoreValidationFailedFacesContext extends FacesContextWrapper {
private FacesContext wrapped;
public IgnoreValidationFailedFacesContext(FacesContext wrapped) {
this.wrapped = wrapped;
super(wrapped);
}
@Override
@@ -271,12 +269,6 @@ public void validationFailed() {
public void renderResponse() {
// NOOP.
}
@Override
public FacesContext getWrapped() {
return wrapped;
}
}
/**
@@ -287,53 +279,40 @@ public FacesContext getWrapped() {
*/
private static class ActionURLDecorator extends FacesContextWrapper {
private FacesContext wrapped;
private Form form;
public ActionURLDecorator(FacesContext wrapped, Form form) {
this.wrapped = wrapped;
super(wrapped);
this.form = form;
}
@Override
public Application getApplication() {
return new ActionURLDecoratorApplication(getWrapped().getApplication(), form);
}
@Override
public FacesContext getWrapped() {
return wrapped;
}
}
private static class ActionURLDecoratorApplication extends ApplicationWrapper {
private Application wrapped;
private Form form;
public ActionURLDecoratorApplication(Application wrapped, Form form) {
this.wrapped = wrapped;
super(wrapped);
this.form = form;
}
@Override
public ViewHandler getViewHandler() {
return new ActionURLDecoratorViewHandler(getWrapped().getViewHandler(), form);
}
@Override
public Application getWrapped() {
return wrapped;
}
}
private static class ActionURLDecoratorViewHandler extends ViewHandlerWrapper {
private ViewHandler wrapped;
private Form form;
public ActionURLDecoratorViewHandler(ViewHandler wrapped, Form form) {
this.wrapped = wrapped;
super(wrapped);
this.form = form;
}
@@ -354,11 +333,6 @@ private String getActionURL(FacesContext context) {
String actionURL = (getRequestAttribute(context, ERROR_REQUEST_URI) != null) ? getRequestContextPath(context) : getRequestURI(context);
return actionURL.isEmpty() ? "/" : actionURL;
}
@Override
public ViewHandler getWrapped() {
return wrapped;
}
}
}
@@ -37,7 +37,6 @@
*/
public class ConditionalResponseWriter extends ResponseWriterWrapper {
private final ResponseWriter responseWriter;
private final FacesContext facesContext;
private final List<String> componentIds;
private final List<String> clientIds;
@@ -48,9 +47,8 @@
private Map<String, Boolean> renderedIdCache = new HashMap<>();
private Map<UIComponent, Boolean> renderedReferenceCache = new HashMap<>();
public ConditionalResponseWriter(ResponseWriter responseWriter, FacesContext facesContext, List<String> componentIds, List<String> clientIds,
boolean renderChildren) {
this.responseWriter = responseWriter;
public ConditionalResponseWriter(ResponseWriter responseWriter, FacesContext facesContext, List<String> componentIds, List<String> clientIds, boolean renderChildren) {
super(responseWriter);
this.facesContext = facesContext;
this.componentIds = componentIds;
this.clientIds = clientIds;
@@ -264,9 +262,4 @@ else if (renderedReferenceCache.containsKey(parent)) {
renderedIdCache.put(component.getClientId(), lastRendered);
}
@Override
public ResponseWriter getWrapped() {
return responseWriter;
}
}
@@ -12,6 +12,8 @@
*/
package org.omnifaces.component.output;
import static org.omnifaces.util.FacesLocal.createConverter;
import java.io.IOException;
import java.io.StringWriter;
@@ -55,6 +57,7 @@
* @see ParamHolder
*/
@FacesComponent(Param.COMPONENT_TYPE)
@SuppressWarnings({"rawtypes", "unchecked"})
public class Param extends UIParameter implements ParamHolder {
// Public constants -----------------------------------------------------------------------------------------------
@@ -92,7 +95,7 @@ public Object getLocalValue() {
@Override
public Object getValue() {
FacesContext context = getFacesContext();
Converter converter = getConverter();
Converter<Object> converter = getConverter();
Object value = getLocalValue();
if (value == null && getChildCount() > 0) {
@@ -114,7 +117,7 @@ public Object getValue() {
}
if (converter == null && value != null) {
converter = context.getApplication().createConverter(value.getClass());
converter = createConverter(context, value.getClass());
}
if (converter != null) {
@@ -116,14 +116,10 @@ public void processEvent(SystemEvent event) {
String encoding = context.getExternalContext().getRequestCharacterEncoding();
context.getExternalContext().setResponseCharacterEncoding(encoding);
final ResponseWriter writer = context.getRenderKit().createResponseWriter(buffer, null, encoding);
context.setResponseWriter(new ResponseWriterWrapper() {
context.setResponseWriter(new ResponseWriterWrapper(writer) {
@Override
public void writeText(Object text, String property) throws IOException {
writer.write(text.toString()); // So, don't escape HTML.
}
@Override
public ResponseWriter getWrapped() {
return writer;
getWrapped().write(text.toString()); // So, don't escape HTML.
}
});
@@ -40,18 +40,14 @@
private static final Flash DUMMY_FLASH = new DummyFlash();
// Variables ------------------------------------------------------------------------------------------------------
private ExternalContext wrapped;
// Constructors ---------------------------------------------------------------------------------------------------
/**
* Construct a new OmniFaces external context around the given wrapped external context.
* @param wrapped The wrapped external context.
*/
public OmniExternalContext(ExternalContext wrapped) {
this.wrapped = wrapped;
super(wrapped);
}
// Actions --------------------------------------------------------------------------------------------------------
@@ -65,11 +61,6 @@ public Flash getFlash() {
return ViewScopeManager.isUnloadRequest(Faces.getContext()) ? DUMMY_FLASH : super.getFlash();
}
@Override
public ExternalContext getWrapped() {
return wrapped;
}
// Inner classes --------------------------------------------------------------------------------------------------
/**
Oops, something went wrong.

0 comments on commit e2d03d9

Please sign in to comment.