Author: alexsmirnov
Date: 2009-12-02 19:07:13 -0500 (Wed, 02 Dec 2009)
New Revision: 16044
Added:
tags/3.3.3.BETA1/framework/api/src/main/java/org/richfaces/validator/
tags/3.3.3.BETA1/framework/api/src/main/java/org/richfaces/validator/GraphValidator.java
tags/3.3.3.BETA1/framework/api/src/main/java/org/richfaces/validator/NullValueValidator.java
tags/3.3.3.BETA1/framework/impl/src/main/java/org/richfaces/component/UIRichInput.java
Removed:
tags/3.3.3.BETA1/framework/api/src/main/java/org/richfaces/validator/GraphValidator.java
tags/3.3.3.BETA1/framework/api/src/main/java/org/richfaces/validator/NullValueValidator.java
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/validator/GraphValidator.java
Modified:
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/component/html/HtmlInputSecret.java
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/component/html/HtmlInputText.java
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/component/html/HtmlInputTextarea.java
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/validator/FacesBeanValidator.java
tags/3.3.3.BETA1/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
tags/3.3.3.BETA1/ui/combobox/src/main/java/org/richfaces/component/UIComboBox.java
tags/3.3.3.BETA1/ui/inplaceInput/src/main/java/org/richfaces/component/UIInplaceInput.java
tags/3.3.3.BETA1/ui/inplaceSelect/src/main/java/org/richfaces/component/UIInplaceSelect.java
tags/3.3.3.BETA1/ui/pickList/src/main/java/org/richfaces/component/UIPickList.java
Log:
merge
https://jira.jboss.org/jira/browse/RF-8172
Copied: tags/3.3.3.BETA1/framework/api/src/main/java/org/richfaces/validator (from rev
16043, branches/community/3.3.X/framework/api/src/main/java/org/richfaces/validator)
Deleted:
tags/3.3.3.BETA1/framework/api/src/main/java/org/richfaces/validator/GraphValidator.java
===================================================================
---
branches/community/3.3.X/framework/api/src/main/java/org/richfaces/validator/GraphValidator.java 2009-12-02
21:59:42 UTC (rev 16043)
+++
tags/3.3.3.BETA1/framework/api/src/main/java/org/richfaces/validator/GraphValidator.java 2009-12-03
00:07:13 UTC (rev 16044)
@@ -1,24 +0,0 @@
-/**
- *
- */
-package org.richfaces.validator;
-
-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 String[] validateGraph(FacesContext context, UIComponent component, Object
value,
- Object profiles) throws ValidatorException ;
-
-}
Copied:
tags/3.3.3.BETA1/framework/api/src/main/java/org/richfaces/validator/GraphValidator.java
(from rev 16043,
branches/community/3.3.X/framework/api/src/main/java/org/richfaces/validator/GraphValidator.java)
===================================================================
---
tags/3.3.3.BETA1/framework/api/src/main/java/org/richfaces/validator/GraphValidator.java
(rev 0)
+++
tags/3.3.3.BETA1/framework/api/src/main/java/org/richfaces/validator/GraphValidator.java 2009-12-03
00:07:13 UTC (rev 16044)
@@ -0,0 +1,24 @@
+/**
+ *
+ */
+package org.richfaces.validator;
+
+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 String[] validateGraph(FacesContext context, UIComponent component, Object
value,
+ Object profiles) throws ValidatorException ;
+
+}
Deleted:
tags/3.3.3.BETA1/framework/api/src/main/java/org/richfaces/validator/NullValueValidator.java
===================================================================
---
branches/community/3.3.X/framework/api/src/main/java/org/richfaces/validator/NullValueValidator.java 2009-12-02
21:59:42 UTC (rev 16043)
+++
tags/3.3.3.BETA1/framework/api/src/main/java/org/richfaces/validator/NullValueValidator.java 2009-12-03
00:07:13 UTC (rev 16044)
@@ -1,15 +0,0 @@
-/**
- *
- */
-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 {
-
-}
Copied:
tags/3.3.3.BETA1/framework/api/src/main/java/org/richfaces/validator/NullValueValidator.java
(from rev 16043,
branches/community/3.3.X/framework/api/src/main/java/org/richfaces/validator/NullValueValidator.java)
===================================================================
---
tags/3.3.3.BETA1/framework/api/src/main/java/org/richfaces/validator/NullValueValidator.java
(rev 0)
+++
tags/3.3.3.BETA1/framework/api/src/main/java/org/richfaces/validator/NullValueValidator.java 2009-12-03
00:07:13 UTC (rev 16044)
@@ -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 {
+
+}
Copied:
tags/3.3.3.BETA1/framework/impl/src/main/java/org/richfaces/component/UIRichInput.java
(from rev 16043,
branches/community/3.3.X/framework/impl/src/main/java/org/richfaces/component/UIRichInput.java)
===================================================================
---
tags/3.3.3.BETA1/framework/impl/src/main/java/org/richfaces/component/UIRichInput.java
(rev 0)
+++
tags/3.3.3.BETA1/framework/impl/src/main/java/org/richfaces/component/UIRichInput.java 2009-12-03
00:07:13 UTC (rev 16044)
@@ -0,0 +1,90 @@
+/**
+ *
+ */
+package org.richfaces.component;
+
+import java.util.List;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+
+import org.richfaces.validator.NullValueValidator;
+
+/**
+ * @author asmirnov
+ *
+ */
+public abstract class UIRichInput extends UIInput {
+ @Override
+ protected void validateValue(FacesContext context, Object newValue) {
+ // If our value is valid, enforce the required property if present
+ if (isValid() && isRequired() && UIRichInput.isEmpty(newValue)) {
+ super.validateValue(context, newValue);
+ }
+ UIRichInput.validateInput(context, this, newValue);
+
+ }
+
+ /**
+ * @param context
+ * @param newValue
+ */
+ public static void validateInput(FacesContext context, UIInput component, Object
newValue) {
+ // If our value is valid and not empty, call all validators
+ if (component.isValid()) {
+ Validator[] validators = component.getValidators();
+ if (validators != null) {
+ for (Validator validator : validators) {
+ try {
+ if (validator instanceof NullValueValidator
+ || !isEmpty(newValue)) {
+ validator.validate(context, component, newValue);
+ }
+ } catch (ValidatorException ve) {
+ // If the validator throws an exception, we're
+ // invalid, and we need to add a message
+ component.setValid(false);
+ FacesMessage message;
+ String validatorMessageString = component.getValidatorMessage();
+
+ if (null != validatorMessageString) {
+ message = new FacesMessage(
+ FacesMessage.SEVERITY_ERROR,
+ validatorMessageString,
+ validatorMessageString);
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ } else {
+ message = ve.getFacesMessage();
+ }
+ if (message != null) {
+ context.addMessage(component.getClientId(context), message);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public static boolean isEmpty(Object value) {
+
+ if (value == null) {
+ return (true);
+ } else if ((value instanceof String) && (((String) value).length() < 1)) {
+ return (true);
+ } else if (value.getClass().isArray()) {
+ if (0 == java.lang.reflect.Array.getLength(value)) {
+ return (true);
+ }
+ } else if (value instanceof List) {
+ if (((List) value).isEmpty()) {
+ return (true);
+ }
+ }
+ return (false);
+ }
+
+}
Modified:
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/component/html/HtmlInputSecret.java
===================================================================
---
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/component/html/HtmlInputSecret.java 2009-12-02
21:59:42 UTC (rev 16043)
+++
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/component/html/HtmlInputSecret.java 2009-12-03
00:07:13 UTC (rev 16044)
@@ -27,7 +27,9 @@
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
+import org.richfaces.component.UIRichInput;
import org.richfaces.validator.FacesBeanValidator;
+import org.richfaces.validator.NullValueValidator;
/**
* @author Alex.Kolonitsky
@@ -35,62 +37,13 @@
* */
public class HtmlInputSecret extends javax.faces.component.html.HtmlInputSecret {
- @Override
- protected void validateValue(FacesContext context, Object newValue) {
- // If our value is valid, enforce the required property if present
- if (isValid() && isRequired() && isEmpty(newValue)) {
- super.validateValue(context, newValue);
- }
- // If our value is valid and not empty, call all validators
- if (isValid()) {
- Validator[] validators = this.getValidators();
- if (validators != null) {
- for (Validator validator : validators) {
- try {
- if (validator instanceof FacesBeanValidator
- || !isEmpty(newValue)) {
- validator.validate(context, this, newValue);
- }
- } catch (ValidatorException ve) {
- // If the validator throws an exception, we're
- // invalid, and we need to add a message
- setValid(false);
- FacesMessage message;
- String validatorMessageString = getValidatorMessage();
+ @Override
+ protected void validateValue(FacesContext context, Object newValue) {
+ // If our value is valid, enforce the required property if present
+ if (isValid() && isRequired() && UIRichInput.isEmpty(newValue)) {
+ super.validateValue(context, newValue);
+ }
+ UIRichInput.validateInput(context, this, newValue);
- if (null != validatorMessageString) {
- message = new FacesMessage(
- FacesMessage.SEVERITY_ERROR,
- validatorMessageString,
- validatorMessageString);
- message.setSeverity(FacesMessage.SEVERITY_ERROR);
- } else {
- message = ve.getFacesMessage();
- }
- if (message != null) {
- context.addMessage(getClientId(context), message);
- }
- }
- }
- }
- }
- }
-
- public static boolean isEmpty(Object value) {
-
- if (value == null) {
- return true;
- } else if ((value instanceof String) && (((String) value).length() <
1)) {
- return true;
- } else if (value.getClass().isArray()) {
- if (0 == java.lang.reflect.Array.getLength(value)) {
- return true;
- }
- } else if (value instanceof List) {
- if (((List<?>) value).isEmpty()) {
- return true;
- }
- }
- return false;
- }
+ }
}
Modified:
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/component/html/HtmlInputText.java
===================================================================
---
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/component/html/HtmlInputText.java 2009-12-02
21:59:42 UTC (rev 16043)
+++
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/component/html/HtmlInputText.java 2009-12-03
00:07:13 UTC (rev 16044)
@@ -27,7 +27,9 @@
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
+import org.richfaces.component.UIRichInput;
import org.richfaces.validator.FacesBeanValidator;
+import org.richfaces.validator.NullValueValidator;
/**
* @author asmirnov
@@ -38,61 +40,11 @@
@Override
protected void validateValue(FacesContext context, Object newValue) {
// If our value is valid, enforce the required property if present
- if (isValid() && isRequired() && isEmpty(newValue)) {
+ if (isValid() && isRequired() && UIRichInput.isEmpty(newValue)) {
super.validateValue(context, newValue);
}
- // If our value is valid and not empty, call all validators
- if (isValid()) {
- Validator[] validators = this.getValidators();
- if (validators != null) {
- for (Validator validator : validators) {
- try {
- if (validator instanceof FacesBeanValidator
- || !isEmpty(newValue)) {
- validator.validate(context, this, newValue);
- }
- } catch (ValidatorException ve) {
- // If the validator throws an exception, we're
- // invalid, and we need to add a message
- setValid(false);
- FacesMessage message;
- String validatorMessageString = getValidatorMessage();
+ UIRichInput.validateInput(context, this, newValue);
- if (null != validatorMessageString) {
- message = new FacesMessage(
- FacesMessage.SEVERITY_ERROR,
- validatorMessageString,
- validatorMessageString);
- message.setSeverity(FacesMessage.SEVERITY_ERROR);
- } else {
- message = ve.getFacesMessage();
- }
- if (message != null) {
- context.addMessage(getClientId(context), message);
- }
- }
- }
- }
- }
-
}
- public static boolean isEmpty(Object value) {
-
- if (value == null) {
- return true;
- } else if ((value instanceof String) && (((String) value).length() < 1)) {
- return true;
- } else if (value.getClass().isArray()) {
- if (0 == java.lang.reflect.Array.getLength(value)) {
- return true;
- }
- } else if (value instanceof List) {
- if (((List<?>) value).isEmpty()) {
- return true;
- }
- }
- return false;
- }
-
}
Modified:
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/component/html/HtmlInputTextarea.java
===================================================================
---
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/component/html/HtmlInputTextarea.java 2009-12-02
21:59:42 UTC (rev 16043)
+++
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/component/html/HtmlInputTextarea.java 2009-12-03
00:07:13 UTC (rev 16044)
@@ -27,7 +27,9 @@
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
+import org.richfaces.component.UIRichInput;
import org.richfaces.validator.FacesBeanValidator;
+import org.richfaces.validator.NullValueValidator;
/**
* @author asmirnov
@@ -38,61 +40,12 @@
@Override
protected void validateValue(FacesContext context, Object newValue) {
// If our value is valid, enforce the required property if present
- if (isValid() && isRequired() && isEmpty(newValue)) {
+ if (isValid() && isRequired() && UIRichInput.isEmpty(newValue)) {
super.validateValue(context, newValue);
}
- // If our value is valid and not empty, call all validators
- if (isValid()) {
- Validator[] validators = this.getValidators();
- if (validators != null) {
- for (Validator validator : validators) {
- try {
- if (validator instanceof FacesBeanValidator
- || !isEmpty(newValue)) {
- validator.validate(context, this, newValue);
- }
- } catch (ValidatorException ve) {
- // If the validator throws an exception, we're
- // invalid, and we need to add a message
- setValid(false);
- FacesMessage message;
- String validatorMessageString = getValidatorMessage();
+ UIRichInput.validateInput(context, this, newValue);
- if (null != validatorMessageString) {
- message = new FacesMessage(
- FacesMessage.SEVERITY_ERROR,
- validatorMessageString,
- validatorMessageString);
- message.setSeverity(FacesMessage.SEVERITY_ERROR);
- } else {
- message = ve.getFacesMessage();
- }
- if (message != null) {
- context.addMessage(getClientId(context), message);
- }
- }
- }
- }
- }
-
}
- public static boolean isEmpty(Object value) {
- if (value == null) {
- return (true);
- } else if ((value instanceof String) && (((String) value).length() < 1)) {
- return (true);
- } else if (value.getClass().isArray()) {
- if (0 == java.lang.reflect.Array.getLength(value)) {
- return (true);
- }
- } else if (value instanceof List) {
- if (((List) value).isEmpty()) {
- return (true);
- }
- }
- return (false);
- }
-
}
Modified:
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/validator/FacesBeanValidator.java
===================================================================
---
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/validator/FacesBeanValidator.java 2009-12-02
21:59:42 UTC (rev 16043)
+++
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/validator/FacesBeanValidator.java 2009-12-03
00:07:13 UTC (rev 16044)
@@ -44,7 +44,7 @@
* @author asmirnov
*
*/
-public class FacesBeanValidator implements Validator,Serializable, GraphValidator {
+public class FacesBeanValidator implements NullValueValidator,Serializable,
GraphValidator {
/**
*
Deleted:
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/validator/GraphValidator.java
===================================================================
---
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/validator/GraphValidator.java 2009-12-02
21:59:42 UTC (rev 16043)
+++
tags/3.3.3.BETA1/ui/beanValidator/src/main/java/org/richfaces/validator/GraphValidator.java 2009-12-03
00:07:13 UTC (rev 16044)
@@ -1,24 +0,0 @@
-/**
- *
- */
-package org.richfaces.validator;
-
-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 String[] validateGraph(FacesContext context, UIComponent component, Object
value,
- Object profiles) throws ValidatorException ;
-
-}
Modified:
tags/3.3.3.BETA1/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
===================================================================
---
tags/3.3.3.BETA1/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2009-12-02
21:59:42 UTC (rev 16043)
+++
tags/3.3.3.BETA1/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2009-12-03
00:07:13 UTC (rev 16044)
@@ -64,7 +64,7 @@
* JSF component class
*
*/
-public abstract class UICalendar extends UIInput implements AjaxComponent {
+public abstract class UICalendar extends UIRichInput implements AjaxComponent {
/**
* firstWeekDay
Modified:
tags/3.3.3.BETA1/ui/combobox/src/main/java/org/richfaces/component/UIComboBox.java
===================================================================
---
tags/3.3.3.BETA1/ui/combobox/src/main/java/org/richfaces/component/UIComboBox.java 2009-12-02
21:59:42 UTC (rev 16043)
+++
tags/3.3.3.BETA1/ui/combobox/src/main/java/org/richfaces/component/UIComboBox.java 2009-12-03
00:07:13 UTC (rev 16044)
@@ -29,7 +29,7 @@
*/
-public abstract class UIComboBox extends UIInput {
+public abstract class UIComboBox extends UIRichInput {
public abstract Object getSuggestionValues();
public abstract void setSuggestionValues(Object value);
Modified:
tags/3.3.3.BETA1/ui/inplaceInput/src/main/java/org/richfaces/component/UIInplaceInput.java
===================================================================
---
tags/3.3.3.BETA1/ui/inplaceInput/src/main/java/org/richfaces/component/UIInplaceInput.java 2009-12-02
21:59:42 UTC (rev 16043)
+++
tags/3.3.3.BETA1/ui/inplaceInput/src/main/java/org/richfaces/component/UIInplaceInput.java 2009-12-03
00:07:13 UTC (rev 16044)
@@ -29,7 +29,7 @@
*/
-public abstract class UIInplaceInput extends UIInput {
+public abstract class UIInplaceInput extends UIRichInput {
/**
* <p>The standard component type for this component.</p>
Modified:
tags/3.3.3.BETA1/ui/inplaceSelect/src/main/java/org/richfaces/component/UIInplaceSelect.java
===================================================================
---
tags/3.3.3.BETA1/ui/inplaceSelect/src/main/java/org/richfaces/component/UIInplaceSelect.java 2009-12-02
21:59:42 UTC (rev 16043)
+++
tags/3.3.3.BETA1/ui/inplaceSelect/src/main/java/org/richfaces/component/UIInplaceSelect.java 2009-12-03
00:07:13 UTC (rev 16044)
@@ -21,6 +21,7 @@
package org.richfaces.component;
import javax.faces.component.UISelectOne;
+import javax.faces.context.FacesContext;
/**
* UI implementation of InplaceSelect component
@@ -34,4 +35,12 @@
public static final String COMPONENT_FAMILY =
"org.richfaces.InplaceSelect";
public abstract boolean isShowValueInView();
public abstract void setShowValueInView(boolean showValueInView);
+
+ @Override
+ protected void validateValue(FacesContext context, Object value) {
+ if(UIRichInput.isEmpty(value)){
+ UIRichInput.validateInput(context, this, value);
+ }
+ super.validateValue(context, value);
+ }
}
Modified:
tags/3.3.3.BETA1/ui/pickList/src/main/java/org/richfaces/component/UIPickList.java
===================================================================
---
tags/3.3.3.BETA1/ui/pickList/src/main/java/org/richfaces/component/UIPickList.java 2009-12-02
21:59:42 UTC (rev 16043)
+++
tags/3.3.3.BETA1/ui/pickList/src/main/java/org/richfaces/component/UIPickList.java 2009-12-03
00:07:13 UTC (rev 16044)
@@ -75,6 +75,15 @@
return converter;
}
+ @Override
+ protected void validateValue(FacesContext context, Object value) {
+ if(UIRichInput.isEmpty(value)){
+ UIRichInput.validateInput(context, this, value);
+ }
+ super.validateValue(context, value);
+ }
+
+
private Converter getConverterForType(FacesContext context, Class <?> type) {
if (!Object.class.equals(type) && type != null) {