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/02/15 02:12:44 UTC
svn commit: r744589 -
/myfaces/extensions/validator/branches/branch_for_jsf_1_1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/interceptor/TrinidadRendererInterceptor.java
Author: gpetracek
Date: Sun Feb 15 01:12:44 2009
New Revision: 744589
URL: http://svn.apache.org/viewvc?rev=744589&view=rev
Log:
EXTVAL-34: read-only and disabled input aware initialization
Modified:
myfaces/extensions/validator/branches/branch_for_jsf_1_1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/interceptor/TrinidadRendererInterceptor.java
Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/interceptor/TrinidadRendererInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/interceptor/TrinidadRendererInterceptor.java?rev=744589&r1=744588&r2=744589&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/interceptor/TrinidadRendererInterceptor.java (original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/interceptor/TrinidadRendererInterceptor.java Sun Feb 15 01:12:44 2009
@@ -29,6 +29,7 @@
import org.apache.myfaces.extensions.validator.core.CustomInformation;
import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
import org.apache.myfaces.extensions.validator.trinidad.util.TrinidadUtils;
import org.apache.myfaces.trinidad.component.core.output.CoreOutputLabel;
@@ -39,6 +40,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.List;
+import java.lang.annotation.Annotation;
/**
* @author Gerhard Petracek
@@ -70,7 +72,7 @@
UIComponent targetComponent = TrinidadUtils.findLabeledEditableComponent(coreOutputLabel);
- if(targetComponent == null)
+ if(targetComponent == null || !isComponentEditable(targetComponent))
{
return;
}
@@ -121,18 +123,31 @@
}
}
+ private boolean isComponentEditable(UIComponent uiComponent)
+ {
+ //compare with false so true = true or null
+ boolean isReadOnly = !Boolean.FALSE.equals(ReflectionUtils.tryToInvokeMethod(
+ uiComponent, ReflectionUtils.tryToGetMethod(uiComponent.getClass(), "isReadOnly")));
+ boolean isDisabled = !Boolean.FALSE.equals(ReflectionUtils.tryToInvokeMethod(
+ uiComponent, ReflectionUtils.tryToGetMethod(uiComponent.getClass(), "isDisabled")));
+
+ return !(isReadOnly || isDisabled);
+ }
+
+ @SuppressWarnings({"unchecked"})
private boolean isSkipableValidationStrategy(Class<? extends ValidationStrategy> validationStrategyClass)
{
String key = ExtValContext.getContext().getInformationProviderBean()
.get(CustomInformation.BASE_PACKAGE) + CommonMetaDataKeys.SKIP_VALIDATION.toUpperCase();
- List<Class> markerList = (List<Class>)ExtValContext.getContext().getGlobalProperty(key);
+ List<Class<? extends Annotation>> markerList =
+ (List<Class<? extends Annotation>>)ExtValContext.getContext().getGlobalProperty(key);
if(markerList == null)
{
return false;
}
- for(Class currentClass : markerList)
+ for(Class<? extends Annotation> currentClass : markerList)
{
if(currentClass.isAnnotation())
{