Author: alexsmirnov
Date: 2010-09-14 19:05:28 -0400 (Tue, 14 Sep 2010)
New Revision: 19207
Added:
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/GraphValidator.java
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/NullValueValidator.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/ValidatorModule.java
branches/RF-8742/ui/validator/impl/src/main/resources/
branches/RF-8742/ui/validator/impl/src/main/resources/META-INF/
branches/RF-8742/ui/validator/impl/src/main/resources/META-INF/services/
branches/RF-8742/ui/validator/impl/src/main/resources/META-INF/services/org.richfaces.application.Module
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIRichMessages.java
branches/RF-8742/ui/validator/ui/src/test/resources/
Removed:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/taglib/
Modified:
branches/RF-8742/core/api/src/main/java/org/richfaces/el/util/CapturingELResolver.java
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ObjectValidator.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/BeanValidator.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesBeanValidator.java
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIAjaxValidator.java
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIGraphValidator.java
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
Log:
RESOLVED - issue RF-9214: CSV: create project in sandbox
https://jira.jboss.org/browse/RF-9214
Import BeanValidator code from 3.3
Modified:
branches/RF-8742/core/api/src/main/java/org/richfaces/el/util/CapturingELResolver.java
===================================================================
---
branches/RF-8742/core/api/src/main/java/org/richfaces/el/util/CapturingELResolver.java 2010-09-14
22:30:39 UTC (rev 19206)
+++
branches/RF-8742/core/api/src/main/java/org/richfaces/el/util/CapturingELResolver.java 2010-09-14
23:05:28 UTC (rev 19207)
@@ -30,7 +30,7 @@
* @author Nick Belaevski
* @since 3.3.0
*/
-class CapturingELResolver extends ELResolverWrapper {
+public class CapturingELResolver extends ELResolverWrapper {
private Object base;
private Object property;
Added:
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/GraphValidator.java
===================================================================
---
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/GraphValidator.java
(rev 0)
+++
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/GraphValidator.java 2010-09-14
23:05:28 UTC (rev 19207)
@@ -0,0 +1,25 @@
+/**
+ *
+ */
+package org.richfaces.validator;
+
+import java.util.Collection;
+import java.util.Set;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+
+/**
+ * This interface should be implemented by the JSF {@link Validator} which able to
+ * validate entire graph.
+ * @author asmirnov
+ *
+ */
+public interface GraphValidator {
+
+ public Collection<String> validateGraph(FacesContext context, UIComponent
component, Object value,
+ Set<String> profiles) throws ValidatorException ;
+
+}
Property changes on:
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/GraphValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/NullValueValidator.java
===================================================================
---
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/NullValueValidator.java
(rev 0)
+++
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/NullValueValidator.java 2010-09-14
23:05:28 UTC (rev 19207)
@@ -0,0 +1,15 @@
+/**
+ *
+ */
+package org.richfaces.validator;
+
+import javax.faces.validator.Validator;
+
+/**
+ * Marker interface for validators that allows null-values to validate.
+ * @author asmirnov
+ *
+ */
+public interface NullValueValidator extends Validator {
+
+}
Property changes on:
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/NullValueValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ObjectValidator.java
===================================================================
---
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ObjectValidator.java 2010-09-14
22:30:39 UTC (rev 19206)
+++
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ObjectValidator.java 2010-09-14
23:05:28 UTC (rev 19207)
@@ -17,11 +17,9 @@
import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.application.Application;
-import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.richfaces.application.ServiceTracker;
import org.richfaces.component.ClonedObjectResolver;
import org.richfaces.el.ELContextWrapper;
@@ -33,31 +31,10 @@
protected static final String INPUT_PARAMETERS_IS_NOT_CORRECT = "Input parameters
is not correct.";
private static final String LOCALE_IS_NOT_SET = "Locale is not set";
private static final String VIEW_ROOT_IS_NOT_INITIALIZED = "ViewRoot is not
initialized";
- private static final Object MUTEX = new Object();
- private static final Log log = LogFactory.getLog(ObjectValidator.class);
protected final ObjectValidator parent;
- /**
- * Create BeanValidator instance. For a Junit tests only.
- *
- * @return
- */
- static ObjectValidator createInstance() {
- // TODO - get instance class name from a "META-INF/service"
- // If the Seam framework is active, org.jboss.seam.core.Validators
- // component should be used.
- ObjectValidator validator = null;
- try {
- validator = new BeanValidator();
- } catch (Throwable e){
- // JSR-303 is not avalable.
- log.warn("Validator implementations not found at classpath, default
NullValidator will be used.");
- validator = new NullValidator();
- }
- return validator;
- }
ObjectValidator() {
this.parent = null;
@@ -74,21 +51,7 @@
* @return
*/
public static ObjectValidator getInstance(FacesContext context) {
- ExternalContext externalContext = context.getExternalContext();
- externalContext.getContext();
- ObjectValidator instance;
- // TODO - use properly synchronization mutex ?
- synchronized (MUTEX) {
- Map<String, Object> applicationMap = externalContext
- .getApplicationMap();
- instance = (ObjectValidator) applicationMap.get(VALIDATOR_PARAM);
- if (null == instance) {
- // Vaildator not initialized - create and store new instance.
- instance = createInstance();
- applicationMap.put(VALIDATOR_PARAM, instance);
- }
- }
- return instance;
+ return ServiceTracker.getService(context, ObjectValidator.class);
}
public abstract Collection<String> validateGraph(FacesContext context, Object
value,
Added:
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/ValidatorModule.java
===================================================================
---
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/ValidatorModule.java
(rev 0)
+++
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/ValidatorModule.java 2010-09-14
23:05:28 UTC (rev 19207)
@@ -0,0 +1,61 @@
+/*
+ * $Id$
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.application;
+
+import org.richfaces.validator.BeanValidator;
+import org.richfaces.validator.NullValidator;
+import org.richfaces.validator.ObjectValidator;
+
+/**
+ * <p class="changed_added_4_0">This class initializes validator-related
services</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ValidatorModule implements Module {
+
+ /* (non-Javadoc)
+ * @see
org.richfaces.application.Module#configure(org.richfaces.application.ServicesFactory)
+ */
+ public void configure(ServicesFactory factory) {
+ factory.setInstance(ObjectValidator.class, createInstance());
+
+ }
+ /**
+ * Create BeanValidator instance. For a Junit tests only.
+ *
+ * @return
+ */
+ static ObjectValidator createInstance() {
+ ObjectValidator validator = null;
+ try {
+ validator = new BeanValidator();
+ } catch (Throwable e){
+ // JSR-303 is not avalable.
+// log.warn("Validator implementations not found at classpath, default
NullValidator will be used.");
+ validator = new NullValidator();
+ }
+ return validator;
+ }
+
+}
Property changes on:
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/ValidatorModule.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/BeanValidator.java
===================================================================
---
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/BeanValidator.java 2010-09-14
22:30:39 UTC (rev 19206)
+++
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/BeanValidator.java 2010-09-14
23:05:28 UTC (rev 19207)
@@ -29,7 +29,7 @@
private final ValidatorFactory validatorFactory;
private ValidatorContext validatorContext;
- BeanValidator() {
+ public BeanValidator() {
// Enforce class to load
ValidatorFactory.class.getName();
// Check Factory, to avoid instantiation errors
Modified:
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesBeanValidator.java
===================================================================
---
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesBeanValidator.java 2010-09-14
22:30:39 UTC (rev 19206)
+++
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesBeanValidator.java 2010-09-14
23:05:28 UTC (rev 19207)
@@ -30,14 +30,12 @@
import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.application.FacesMessage;
-import javax.faces.component.UIComponent;
import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-
/**
* Implementation of the JSF validator to use with Bean Validation / Hibernate
* validator
@@ -45,7 +43,7 @@
* @author asmirnov
*
*/
-public class FacesBeanValidator implements NullValueValidator,Serializable,
GraphValidator {
+public class FacesBeanValidator implements Serializable, Validator, GraphValidator {
/**
*
@@ -59,7 +57,7 @@
private ValueExpression profilesExpression = null;
- private Object profiles = null;
+ private Set<String> profiles = null;
/**
* @return the summary
*/
@@ -149,9 +147,9 @@
}
public Collection<String> validateGraph(FacesContext context, UIComponent
component,
- Object value, Object profiles) throws ValidatorException {
+ Object value, Set<String> profiles) throws ValidatorException {
ObjectValidator beanValidator = ObjectValidator.getInstance(context);
- Collection<String> messages = beanValidator.validateGraph(context,
value,AjaxRendererUtils.asSet(profiles));
+ Collection<String> messages = beanValidator.validateGraph(context,
value,profiles);
return messages;
}
@@ -159,19 +157,19 @@
* @return the profiles
*/
public Set<String> getProfiles() {
- Object profiles;
+ Set<String> profiles;
if(null != profilesExpression){
- profiles =
profilesExpression.getValue(FacesContext.getCurrentInstance().getELContext());
+ profiles = (Set<String>)
profilesExpression.getValue(FacesContext.getCurrentInstance().getELContext());
}else {
profiles = this.profiles;
}
- return AjaxRendererUtils.asSet(profiles);
+ return profiles;
}
/**
* @param profiles the profiles to set
*/
- public void setProfiles(Object profiles) {
+ public void setProfiles(Set<String> profiles) {
this.profiles = profiles;
}
Added:
branches/RF-8742/ui/validator/impl/src/main/resources/META-INF/services/org.richfaces.application.Module
===================================================================
---
branches/RF-8742/ui/validator/impl/src/main/resources/META-INF/services/org.richfaces.application.Module
(rev 0)
+++
branches/RF-8742/ui/validator/impl/src/main/resources/META-INF/services/org.richfaces.application.Module 2010-09-14
23:05:28 UTC (rev 19207)
@@ -0,0 +1 @@
+org.richfaces.application.ValidatorModule
\ No newline at end of file
Modified:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIAjaxValidator.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIAjaxValidator.java 2010-09-14
22:30:39 UTC (rev 19206)
+++
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIAjaxValidator.java 2010-09-14
23:05:28 UTC (rev 19207)
@@ -26,8 +26,6 @@
import java.util.Iterator;
import java.util.Set;
-import javax.el.MethodExpression;
-import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.component.EditableValueHolder;
import javax.faces.component.NamingContainer;
@@ -42,14 +40,8 @@
import javax.faces.event.PhaseId;
import org.ajax4jsf.component.AjaxComponent;
-import org.ajax4jsf.component.AjaxContainer;
import org.ajax4jsf.component.AjaxSupport;
-import org.ajax4jsf.component.EventValueExpression;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.event.AjaxEvent;
-import org.ajax4jsf.event.AjaxListener;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.webapp.taglib.MethodExpressionAjaxListener;
import org.richfaces.event.ValidatorEvent;
/**
@@ -84,10 +76,10 @@
"Parent component must be an EditableValueHolder");
}
- if (null != getEvent()) {
- ValueExpression binding = new EventValueExpression(this);
- parent.setValueExpression(getEvent(), binding);
- }
+// if (null != getEvent()) {
+// ValueExpression binding = new EventValueExpression(this);
+// parent.setValueExpression(getEvent(), binding);
+// }
}
@Override
@@ -98,13 +90,6 @@
if (event instanceof ValidatorEvent) {
// ByPass UpdateModelValue
context.renderResponse();
- } else if (event instanceof AjaxEvent) {
- // TODO - find all UIMessages components for a parent UIInput.
- // for an ajaxSingle component, re-render only target message.
- AjaxContext ajaxContext = AjaxContext
- .getCurrentInstance(context);
- ajaxContext.setSubmittedRegionClientId(this
- .getClientId(context));
}
}
}
@@ -132,8 +117,8 @@
if (null != onsubmit) {
buildOnEvent.append(onsubmit).append(";");
}
- buildOnEvent.append(AjaxRendererUtils.buildOnEvent(this,
- getFacesContext(), getEvent(), true));
+// buildOnEvent.append(AjaxRendererUtils.buildOnEvent(this,
+// getFacesContext(), getEvent(), true));
String script = buildOnEvent.toString();
return script;
}
@@ -152,7 +137,7 @@
}
}
// Write information about encoded areas after submission.
- AjaxRendererUtils.encodeAreas(context, this);
+// AjaxRendererUtils.encodeAreas(context, this);
}
public Set<UIComponent> getMessages(FacesContext context) {
@@ -220,71 +205,4 @@
return found;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.ajax4jsf.event.AjaxSource#addAjaxListener(org.ajax4jsf.event.AjaxListener
- * )
- */
- public void addAjaxListener(AjaxListener listener) {
- addFacesListener(listener);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.event.AjaxSource#getAjaxListeners()
- */
- public AjaxListener[] getAjaxListeners() {
- return (AjaxListener[]) getFacesListeners(AjaxListener.class);
- }
-
- /*
- * (non-Javadoc)
- *
- * @seeorg.ajax4jsf.event.AjaxSource#removeAjaxListener(org.ajax4jsf.event.
- * AjaxListener)
- */
- public void removeAjaxListener(AjaxListener listener) {
- removeFacesListener(listener);
- }
-
- public void setAjaxListener(MethodExpression listener) {
- AjaxListener[] ajaxListeners = getAjaxListeners();
- for (int i = 0; i < ajaxListeners.length; i++) {
- AjaxListener ajaxListener = ajaxListeners[i];
- if (ajaxListener.getClass().equals(
- MethodExpressionAjaxListener.class)) {
- MethodExpressionAjaxListener expressionListener = (MethodExpressionAjaxListener)
ajaxListener;
- if (expressionListener.getExpression() != listener) {
- removeAjaxListener(ajaxListener);
-
- if (listener == null) {
-
- return;
- } else {
-
- break;
- }
- }
- }
- }
-
- addAjaxListener(new MethodExpressionAjaxListener(listener));
- }
-
- public MethodExpression getAjaxListener() {
- AjaxListener[] ajaxListeners = getAjaxListeners();
- for (int i = 0; i < ajaxListeners.length; i++) {
- AjaxListener ajaxListener = ajaxListeners[i];
- if (ajaxListener.getClass().equals(
- MethodExpressionAjaxListener.class)) {
- MethodExpressionAjaxListener expressionListener = (MethodExpressionAjaxListener)
ajaxListener;
- return expressionListener.getExpression();
- }
- }
-
- return null;
- }
}
Modified:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIGraphValidator.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIGraphValidator.java 2010-09-14
22:30:39 UTC (rev 19206)
+++
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIGraphValidator.java 2010-09-14
23:05:28 UTC (rev 19207)
@@ -24,10 +24,8 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
-import java.util.List;
import java.util.Set;
import javax.el.ELContext;
@@ -38,28 +36,11 @@
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
-import javax.faces.component.UIInput;
-import javax.faces.component.UIMessage;
-import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.PhaseId;
import javax.faces.validator.Validator;
-import org.ajax4jsf.component.AjaxComponent;
-import org.ajax4jsf.component.AjaxContainer;
-import org.ajax4jsf.component.AjaxSupport;
-import org.ajax4jsf.component.EventValueExpression;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.el.ELContextWrapper;
-import org.ajax4jsf.event.AjaxEvent;
-import org.ajax4jsf.event.AjaxListener;
-import org.ajax4jsf.renderkit.AjaxContainerRenderer;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.util.CapturingELResolver;
-import org.richfaces.event.ValidatorEvent;
-import org.richfaces.validator.HibernateValidator;
+import org.richfaces.el.ELContextWrapper;
+import org.richfaces.el.util.CapturingELResolver;
import org.richfaces.validator.FacesBeanValidator;
import org.richfaces.validator.GraphValidator;
@@ -112,7 +93,7 @@
*
* @return
*/
- public abstract Object getProfiles();
+ public abstract Set<String> getProfiles();
/**
* Set set of profiles for validation
Added:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIRichMessages.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIRichMessages.java
(rev 0)
+++
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIRichMessages.java 2010-09-14
23:05:28 UTC (rev 19207)
@@ -0,0 +1,41 @@
+/*
+ * $Id$
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.component;
+
+import javax.faces.component.UIMessages;
+import javax.faces.context.FacesContext;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class UIRichMessages extends UIMessages {
+
+ public void updateMessages(FacesContext context, String clientId) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIRichMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-09-14
22:30:39 UTC (rev 19206)
+++
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-09-14
23:05:28 UTC (rev 19207)
@@ -16,6 +16,7 @@
public static final String RENDERER_TYPE =
"org.richfaces.ClientValidatorRenderer";
+
public ClientValidatorRenderer () {
super();
}