You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2009/11/12 18:48:15 UTC
svn commit: r835469 - in
/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator:
core/ core/renderkit/ util/
Author: gpetracek
Date: Thu Nov 12 17:48:15 2009
New Revision: 835469
URL: http://svn.apache.org/viewvc?rev=835469&view=rev
Log:
EXTVAL-38 workaround for mojarra
Added:
myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/LazyRenderKitWrapperFactory.java
Modified:
myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContext.java
myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRenderKitFactory.java
myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContext.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContext.java?rev=835469&r1=835468&r2=835469&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContext.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContext.java Thu Nov 12 17:48:15 2009
@@ -85,12 +85,20 @@
if (extValContext == null)
{
extValContext = new ExtValContext();
- Object customExtValContext = ExtValUtils.getELHelper().getBean(
- extValContext.getInformationProviderBean().get(CustomInformation.EXTVAL_CONTEXT));
- if (customExtValContext instanceof ExtValContext)
+ if(ExtValUtils.isApplicationInitialized())
{
- extValContext = (ExtValContext) customExtValContext;
+ Object customExtValContext = ExtValUtils.getELHelper().getBean(
+ extValContext.getInformationProviderBean().get(CustomInformation.EXTVAL_CONTEXT));
+
+ if (customExtValContext instanceof ExtValContext)
+ {
+ extValContext = (ExtValContext) customExtValContext;
+ }
+ }
+ else
+ {
+ //TODO try to use web.xml context-param
}
}
return extValContext;
Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRenderKitFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRenderKitFactory.java?rev=835469&r1=835468&r2=835469&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRenderKitFactory.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRenderKitFactory.java Thu Nov 12 17:48:15 2009
@@ -22,6 +22,7 @@
import org.apache.myfaces.extensions.validator.internal.UsageInformation;
import org.apache.myfaces.extensions.validator.core.ExtValContext;
import org.apache.myfaces.extensions.validator.core.factory.FactoryNames;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -41,6 +42,7 @@
{
protected final Log logger = LogFactory.getLog(getClass());
private RenderKitFactory wrapped;
+ private LazyRenderKitWrapperFactory lazyRenderKitWrapperFactory = new LazyRenderKitWrapperFactory();
public ExtValRenderKitFactory(RenderKitFactory renderKitFactory)
{
@@ -67,6 +69,17 @@
return null;
}
+ //test early config in case of mojarra
+ if(!ExtValUtils.isApplicationInitialized())
+ {
+ return this.lazyRenderKitWrapperFactory.createWrapper(renderKit);
+ }
+
+ return tryToCreateWrapperWithWrapperFactory(renderKit);
+ }
+
+ private RenderKit tryToCreateWrapperWithWrapperFactory(RenderKit renderKit)
+ {
AbstractRenderKitWrapperFactory wrapperFactory = ExtValContext.getContext().getFactoryFinder()
.getFactory(FactoryNames.RENDERKIT_WRAPPER_FACTORY, AbstractRenderKitWrapperFactory.class);
Added: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/LazyRenderKitWrapperFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/LazyRenderKitWrapperFactory.java?rev=835469&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/LazyRenderKitWrapperFactory.java (added)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/LazyRenderKitWrapperFactory.java Thu Nov 12 17:48:15 2009
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.renderkit;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.ToDo;
+import org.apache.myfaces.extensions.validator.internal.Priority;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.factory.FactoryNames;
+
+import javax.faces.render.RenderKit;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@ToDo(value = Priority.MEDIUM, description = "test this workaround with mojarra")
+@UsageInformation(UsageCategory.INTERNAL)
+public class LazyRenderKitWrapperFactory extends DefaultRenderKitWrapperFactory
+{
+ private AbstractRenderKitWrapperFactory wrapped;
+
+ @Override
+ protected RenderKit createWrapper(RenderKit renderKit)
+ {
+ if(ExtValUtils.isApplicationInitialized())
+ {
+ tryToInitWrappedRenderKitWrapperFractory();
+ }
+
+ return tryToCreateWrapperWithWrappedFactory(renderKit);
+ }
+
+ private RenderKit tryToCreateWrapperWithWrappedFactory(RenderKit renderKit)
+ {
+ if(this.wrapped != null)
+ {
+ if(this.wrapped.isDeactivated())
+ {
+ return renderKit;
+ }
+ return this.wrapped.createWrapper(renderKit);
+ }
+
+ return super.createWrapper(renderKit);
+ }
+
+ private void tryToInitWrappedRenderKitWrapperFractory()
+ {
+ if(this.wrapped == null)
+ {
+ this.wrapped = ExtValContext.getContext().getFactoryFinder()
+ .getFactory(FactoryNames.RENDERKIT_WRAPPER_FACTORY, AbstractRenderKitWrapperFactory.class);
+ }
+ }
+}
\ No newline at end of file
Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java?rev=835469&r1=835468&r2=835469&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java Thu Nov 12 17:48:15 2009
@@ -894,4 +894,19 @@
}
return targetComponent;
}
+
+ public static boolean isApplicationInitialized()
+ {
+ try
+ {
+ //simple test for early config in case of mojarra
+ FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().isEmpty();
+ }
+ catch (Throwable e)
+ {
+ return false;
+ }
+
+ return true;
+ }
}