From 2e0d13cbe40f8450b28a4d97a7e6296fda769c93 Mon Sep 17 00:00:00 2001 From: Jeremy Grelle Date: Thu, 16 Aug 2007 13:20:33 +0000 Subject: [PATCH] Cleaning up formatting --- .../faces/ui/ClientDateValidator.java | 452 +++++++-------- .../faces/ui/ClientNumberValidator.java | 362 ++++++------ .../faces/ui/ClientTextValidator.java | 546 +++++++++--------- .../springframework/faces/ui/ExtAdvisor.java | 454 +++++++-------- .../faces/ui/ExtAdvisorRenderer.java | 104 ++-- .../faces/ui/ExtJsComponent.java | 78 +-- .../faces/ui/ExtJsRenderer.java | 26 +- .../faces/ui/ExtValidateAllRenderer.java | 46 +- 8 files changed, 1034 insertions(+), 1034 deletions(-) diff --git a/spring-webflow/src/main/java/org/springframework/faces/ui/ClientDateValidator.java b/spring-webflow/src/main/java/org/springframework/faces/ui/ClientDateValidator.java index 4dc283a2..202f0107 100644 --- a/spring-webflow/src/main/java/org/springframework/faces/ui/ClientDateValidator.java +++ b/spring-webflow/src/main/java/org/springframework/faces/ui/ClientDateValidator.java @@ -5,254 +5,254 @@ import javax.faces.el.ValueBinding; public class ClientDateValidator extends ClientTextValidator { - private static final String EXT_COMPONENT_TYPE = "Ext.form.DateField"; + private static final String EXT_COMPONENT_TYPE = "Ext.form.DateField"; - private static final String[] EXT_ATTRS_INTERNAL = new String[] { "altFormats", "disabledDates", - "disabledDatesText", "disabledDays", "disabledDaysText", "format", "maxText", "maxValue", "minText", - "minValue", "triggerClass" }; + private static final String[] EXT_ATTRS_INTERNAL = new String[] { "altFormats", "disabledDates", + "disabledDatesText", "disabledDays", "disabledDaysText", "format", "maxText", "maxValue", "minText", + "minValue", "triggerClass" }; - protected static final String[] EXT_ATTRS; + protected static final String[] EXT_ATTRS; - static { - EXT_ATTRS = new String[ClientTextValidator.EXT_ATTRS.length + EXT_ATTRS_INTERNAL.length]; - System.arraycopy(ClientTextValidator.EXT_ATTRS, 0, EXT_ATTRS, 0, ClientTextValidator.EXT_ATTRS.length); - System.arraycopy(EXT_ATTRS_INTERNAL, 0, EXT_ATTRS, ClientTextValidator.EXT_ATTRS.length, - EXT_ATTRS_INTERNAL.length); - } - - /** - * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined - * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d'). - */ - private String altFormats; - - /** - * An array of "dates" to disable, as strings. These strings will be used to build a dynamic regular expression so - * they are very powerful. Some examples: - * - * ["03/08/2003", "09/16/2003"] would disable those exact dates ["03/08", "09/16"] would disable those days for - * every year ["^03/08"] would only match the beginning (useful if you are using short years) ["03/../2006"] would - * disable every day in March 2006 ["^03"] would disable every day in every March - * - * In order to support regular expressions, if you are using a date format that has "." in it, you will have to - * escape the dot when restricting dates. For example: ["03\\.08\\.03"]. - */ - private String disabledDates; - - /** - * The tooltip text to display when the date falls on a disabled date (defaults to 'Disabled') - */ - private String disabledDatesText; - - /** - * An array of days to disable, 0 based. For example, [0, 6] disables Sunday and Saturday (defaults to null). - */ - private String disabledDays; - - /** - * The tooltip to display when the date falls on a disabled day (defaults to 'Disabled') - */ - private String disabledDaysText; - - /** - * The default date format string which can be overriden for localization support. The format must be valid - * according to Date.parseDate (defaults to 'm/d/y'). - */ - private String format; - - /** - * The error text to display when the date in the field is invalid (defaults to '{value} is not a valid date - it - * must be in the format {format}'). - */ - private String invalidText; - - /** - * The error text to display when the date in the cell is after maxValue (defaults to 'The date in this field must - * be before {maxValue}'). - */ - private String maxText; - - /** - * The maximum allowed date. Can be either a Javascript date object or a string date in a valid format (defaults to - * null). - */ - private String maxValue; - - /** - * The error text to display when the date in the cell is before minValue (defaults to 'The date in this field must - * be after {minValue}'). - */ - private String minText; - - /** - * The minimum allowed date. Can be either a Javascript date object or a string date in a valid format (defaults to - * null). - */ - private String minValue; - - /** - * An additional CSS class used to style the trigger button. The trigger will always get the class 'x-form-trigger' - * and triggerClass will be appended if specified (defaults to 'x-form-date-trigger' which displays a calendar - * icon). - */ - private String triggerClass; - - public String getAltFormats() { - return altFormats; - } - - public void setAltFormats(String altFormats) { - this.altFormats = altFormats; - } - - public String getDisabledDates() { - return disabledDates; - } - - public void setDisabledDates(String disabledDates) { - this.disabledDates = disabledDates; - } - - public String getDisabledDatesText() { - if (disabledDatesText != null) { - return disabledDatesText; + static { + EXT_ATTRS = new String[ClientTextValidator.EXT_ATTRS.length + EXT_ATTRS_INTERNAL.length]; + System.arraycopy(ClientTextValidator.EXT_ATTRS, 0, EXT_ATTRS, 0, ClientTextValidator.EXT_ATTRS.length); + System.arraycopy(EXT_ATTRS_INTERNAL, 0, EXT_ATTRS, ClientTextValidator.EXT_ATTRS.length, + EXT_ATTRS_INTERNAL.length); } - ValueBinding vb = getValueBinding("disabledDatesText"); - return vb != null ? (String) vb.getValue(getFacesContext()) : null; - } - public void setDisabledDatesText(String disabledDatesText) { - this.disabledDatesText = disabledDatesText; - } + /** + * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined + * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d'). + */ + private String altFormats; - public String getDisabledDays() { - return disabledDays; - } + /** + * An array of "dates" to disable, as strings. These strings will be used to build a dynamic regular expression so + * they are very powerful. Some examples: + * + * ["03/08/2003", "09/16/2003"] would disable those exact dates ["03/08", "09/16"] would disable those days for + * every year ["^03/08"] would only match the beginning (useful if you are using short years) ["03/../2006"] would + * disable every day in March 2006 ["^03"] would disable every day in every March + * + * In order to support regular expressions, if you are using a date format that has "." in it, you will have to + * escape the dot when restricting dates. For example: ["03\\.08\\.03"]. + */ + private String disabledDates; - public void setDisabledDays(String disabledDays) { - this.disabledDays = disabledDays; - } + /** + * The tooltip text to display when the date falls on a disabled date (defaults to 'Disabled') + */ + private String disabledDatesText; - public String getDisabledDaysText() { - if (disabledDaysText != null) { - return disabledDaysText; + /** + * An array of days to disable, 0 based. For example, [0, 6] disables Sunday and Saturday (defaults to null). + */ + private String disabledDays; + + /** + * The tooltip to display when the date falls on a disabled day (defaults to 'Disabled') + */ + private String disabledDaysText; + + /** + * The default date format string which can be overriden for localization support. The format must be valid + * according to Date.parseDate (defaults to 'm/d/y'). + */ + private String format; + + /** + * The error text to display when the date in the field is invalid (defaults to '{value} is not a valid date - it + * must be in the format {format}'). + */ + private String invalidText; + + /** + * The error text to display when the date in the cell is after maxValue (defaults to 'The date in this field must + * be before {maxValue}'). + */ + private String maxText; + + /** + * The maximum allowed date. Can be either a Javascript date object or a string date in a valid format (defaults to + * null). + */ + private String maxValue; + + /** + * The error text to display when the date in the cell is before minValue (defaults to 'The date in this field must + * be after {minValue}'). + */ + private String minText; + + /** + * The minimum allowed date. Can be either a Javascript date object or a string date in a valid format (defaults to + * null). + */ + private String minValue; + + /** + * An additional CSS class used to style the trigger button. The trigger will always get the class 'x-form-trigger' + * and triggerClass will be appended if specified (defaults to 'x-form-date-trigger' which displays a calendar + * icon). + */ + private String triggerClass; + + public String getAltFormats() { + return altFormats; } - ValueBinding vb = getValueBinding("disabledDaysText"); - return vb != null ? (String) vb.getValue(getFacesContext()) : null; - } - public void setDisabledDaysText(String disabledDaysText) { - this.disabledDaysText = disabledDaysText; - } - - public String getFormat() { - return format; - } - - public void setFormat(String format) { - this.format = format; - } - - public String getInvalidText() { - if (invalidText != null) { - return invalidText; + public void setAltFormats(String altFormats) { + this.altFormats = altFormats; } - ValueBinding vb = getValueBinding("invalidText"); - return vb != null ? (String) vb.getValue(getFacesContext()) : null; - } - public void setInvalidText(String invalidText) { - this.invalidText = invalidText; - } - - public String getMaxText() { - if (maxText != null) { - return maxText; + public String getDisabledDates() { + return disabledDates; } - ValueBinding vb = getValueBinding("maxText"); - return vb != null ? (String) vb.getValue(getFacesContext()) : null; - } - public void setMaxText(String maxText) { - this.maxText = maxText; - } - - public String getMaxValue() { - return maxValue; - } - - public void setMaxValue(String maxValue) { - this.maxValue = maxValue; - } - - public String getMinText() { - if (minText != null) { - return minText; + public void setDisabledDates(String disabledDates) { + this.disabledDates = disabledDates; } - ValueBinding vb = getValueBinding("minText"); - return vb != null ? (String) vb.getValue(getFacesContext()) : null; - } - public void setMinText(String minText) { - this.minText = minText; - } + public String getDisabledDatesText() { + if (disabledDatesText != null) { + return disabledDatesText; + } + ValueBinding vb = getValueBinding("disabledDatesText"); + return vb != null ? (String) vb.getValue(getFacesContext()) : null; + } - public String getMinValue() { - return minValue; - } + public void setDisabledDatesText(String disabledDatesText) { + this.disabledDatesText = disabledDatesText; + } - public void setMinValue(String minValue) { - this.minValue = minValue; - } + public String getDisabledDays() { + return disabledDays; + } - public String getTriggerClass() { - return triggerClass; - } + public void setDisabledDays(String disabledDays) { + this.disabledDays = disabledDays; + } - public void setTriggerClass(String triggerClass) { - this.triggerClass = triggerClass; - } + public String getDisabledDaysText() { + if (disabledDaysText != null) { + return disabledDaysText; + } + ValueBinding vb = getValueBinding("disabledDaysText"); + return vb != null ? (String) vb.getValue(getFacesContext()) : null; + } - protected String[] getExtAttributes() { - return EXT_ATTRS; - } + public void setDisabledDaysText(String disabledDaysText) { + this.disabledDaysText = disabledDaysText; + } - public String getExtComponentType() { - return EXT_COMPONENT_TYPE; - } + public String getFormat() { + return format; + } - public Object saveState(FacesContext context) { - Object[] values = new Object[13]; - values[0] = super.saveState(context); - values[1] = altFormats; - values[2] = disabledDates; - values[3] = disabledDatesText; - values[4] = disabledDays; - values[5] = disabledDaysText; - values[6] = format; - values[7] = invalidText; - values[8] = maxText; - values[9] = maxValue; - values[10] = minText; - values[11] = minValue; - values[12] = triggerClass; - return values; - } + public void setFormat(String format) { + this.format = format; + } - public void restoreState(FacesContext context, Object state) { - Object values[] = (Object[]) state; - super.restoreState(context, values[0]); - altFormats = (String) values[1]; - disabledDates = (String) values[2]; - disabledDatesText = (String) values[3]; - disabledDays = (String) values[4]; - disabledDaysText = (String) values[5]; - format = (String) values[6]; - invalidText = (String) values[7]; - maxText = (String) values[8]; - maxValue = (String) values[9]; - minText = (String) values[10]; - minValue = (String) values[11]; - triggerClass = (String) values[12]; - } + public String getInvalidText() { + if (invalidText != null) { + return invalidText; + } + ValueBinding vb = getValueBinding("invalidText"); + return vb != null ? (String) vb.getValue(getFacesContext()) : null; + } + + public void setInvalidText(String invalidText) { + this.invalidText = invalidText; + } + + public String getMaxText() { + if (maxText != null) { + return maxText; + } + ValueBinding vb = getValueBinding("maxText"); + return vb != null ? (String) vb.getValue(getFacesContext()) : null; + } + + public void setMaxText(String maxText) { + this.maxText = maxText; + } + + public String getMaxValue() { + return maxValue; + } + + public void setMaxValue(String maxValue) { + this.maxValue = maxValue; + } + + public String getMinText() { + if (minText != null) { + return minText; + } + ValueBinding vb = getValueBinding("minText"); + return vb != null ? (String) vb.getValue(getFacesContext()) : null; + } + + public void setMinText(String minText) { + this.minText = minText; + } + + public String getMinValue() { + return minValue; + } + + public void setMinValue(String minValue) { + this.minValue = minValue; + } + + public String getTriggerClass() { + return triggerClass; + } + + public void setTriggerClass(String triggerClass) { + this.triggerClass = triggerClass; + } + + protected String[] getExtAttributes() { + return EXT_ATTRS; + } + + public String getExtComponentType() { + return EXT_COMPONENT_TYPE; + } + + public Object saveState(FacesContext context) { + Object[] values = new Object[13]; + values[0] = super.saveState(context); + values[1] = altFormats; + values[2] = disabledDates; + values[3] = disabledDatesText; + values[4] = disabledDays; + values[5] = disabledDaysText; + values[6] = format; + values[7] = invalidText; + values[8] = maxText; + values[9] = maxValue; + values[10] = minText; + values[11] = minValue; + values[12] = triggerClass; + return values; + } + + public void restoreState(FacesContext context, Object state) { + Object values[] = (Object[]) state; + super.restoreState(context, values[0]); + altFormats = (String) values[1]; + disabledDates = (String) values[2]; + disabledDatesText = (String) values[3]; + disabledDays = (String) values[4]; + disabledDaysText = (String) values[5]; + format = (String) values[6]; + invalidText = (String) values[7]; + maxText = (String) values[8]; + maxValue = (String) values[9]; + minText = (String) values[10]; + minValue = (String) values[11]; + triggerClass = (String) values[12]; + } } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/faces/ui/ClientNumberValidator.java b/spring-webflow/src/main/java/org/springframework/faces/ui/ClientNumberValidator.java index d7692bfc..0478adda 100644 --- a/spring-webflow/src/main/java/org/springframework/faces/ui/ClientNumberValidator.java +++ b/spring-webflow/src/main/java/org/springframework/faces/ui/ClientNumberValidator.java @@ -5,202 +5,202 @@ import javax.faces.el.ValueBinding; public class ClientNumberValidator extends ClientTextValidator { - private static final String EXT_COMPONENT_TYPE = "Ext.form.NumberField"; + private static final String EXT_COMPONENT_TYPE = "Ext.form.NumberField"; - private static final String[] EXT_ATTRS_INTERNAL = new String[] { "allowDecimals", "allowNegative", - "decimalPrecision", "decimalSeparator", "maxText", "maxValue", "minText", "minValue", "nanText" }; + private static final String[] EXT_ATTRS_INTERNAL = new String[] { "allowDecimals", "allowNegative", + "decimalPrecision", "decimalSeparator", "maxText", "maxValue", "minText", "minValue", "nanText" }; - protected static final String[] EXT_ATTRS; + protected static final String[] EXT_ATTRS; - static { - EXT_ATTRS = new String[ClientTextValidator.EXT_ATTRS.length + EXT_ATTRS_INTERNAL.length]; - System.arraycopy(ClientTextValidator.EXT_ATTRS, 0, EXT_ATTRS, 0, ClientTextValidator.EXT_ATTRS.length); - System.arraycopy(EXT_ATTRS_INTERNAL, 0, EXT_ATTRS, ClientTextValidator.EXT_ATTRS.length, - EXT_ATTRS_INTERNAL.length); - } - - /** - * False to disallow decimal values (defaults to true) - */ - private Boolean allowDecimals; - - /** - * False to prevent entering a negative sign (defaults to true) - */ - private Boolean allowNegative; - - /** - * The maximum precision to display after the decimal separator (defaults to 2) - */ - private Integer decimalPrecision; - - /** - * Character(s) to allow as the decimal separator (defaults to '.') - */ - private String decimalSeparator; - - /** - * The default CSS class for the field (defaults to "x-form-field x-form-num-field") - */ - private String fieldClass; - - /** - * Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is - * {maxValue}") - */ - private String maxText; - - /** - * The maximum allowed value (defaults to Number.MAX_VALUE) - */ - private Integer maxValue; - - /** - * Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is - * {minValue}") - */ - private String minText; - - /** - * The minimum allowed value (defaults to Number.NEGATIVE_INFINITY) - */ - private Integer minValue; - - /** - * Error text to display if the value is not a valid number. For example, this can happen if a valid character like - * '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number") - */ - private String nanText; - - public Boolean getAllowDecimals() { - return allowDecimals; - } - - public void setAllowDecimals(Boolean allowDecimals) { - this.allowDecimals = allowDecimals; - } - - public Boolean getAllowNegative() { - return allowNegative; - } - - public void setAllowNegative(Boolean allowNegative) { - this.allowNegative = allowNegative; - } - - public Integer getDecimalPrecision() { - return decimalPrecision; - } - - public void setDecimalPrecision(Integer decimalPrecision) { - this.decimalPrecision = decimalPrecision; - } - - public String getDecimalSeparator() { - return decimalSeparator; - } - - public void setDecimalSeparator(String decimalSeparator) { - this.decimalSeparator = decimalSeparator; - } - - public String getFieldClass() { - return fieldClass; - } - - public void setFieldClass(String fieldClass) { - this.fieldClass = fieldClass; - } - - public String getMaxText() { - if (maxText != null) { - return maxText; + static { + EXT_ATTRS = new String[ClientTextValidator.EXT_ATTRS.length + EXT_ATTRS_INTERNAL.length]; + System.arraycopy(ClientTextValidator.EXT_ATTRS, 0, EXT_ATTRS, 0, ClientTextValidator.EXT_ATTRS.length); + System.arraycopy(EXT_ATTRS_INTERNAL, 0, EXT_ATTRS, ClientTextValidator.EXT_ATTRS.length, + EXT_ATTRS_INTERNAL.length); } - ValueBinding vb = getValueBinding("maxText"); - return vb != null ? (String) vb.getValue(getFacesContext()) : null; - } - public void setMaxText(String maxText) { - this.maxText = maxText; - } + /** + * False to disallow decimal values (defaults to true) + */ + private Boolean allowDecimals; - public Integer getMaxValue() { - return maxValue; - } + /** + * False to prevent entering a negative sign (defaults to true) + */ + private Boolean allowNegative; - public void setMaxValue(Integer maxValue) { - this.maxValue = maxValue; - } + /** + * The maximum precision to display after the decimal separator (defaults to 2) + */ + private Integer decimalPrecision; - public String getMinText() { - if (minText != null) { - return minText; + /** + * Character(s) to allow as the decimal separator (defaults to '.') + */ + private String decimalSeparator; + + /** + * The default CSS class for the field (defaults to "x-form-field x-form-num-field") + */ + private String fieldClass; + + /** + * Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is + * {maxValue}") + */ + private String maxText; + + /** + * The maximum allowed value (defaults to Number.MAX_VALUE) + */ + private Integer maxValue; + + /** + * Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is + * {minValue}") + */ + private String minText; + + /** + * The minimum allowed value (defaults to Number.NEGATIVE_INFINITY) + */ + private Integer minValue; + + /** + * Error text to display if the value is not a valid number. For example, this can happen if a valid character like + * '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number") + */ + private String nanText; + + public Boolean getAllowDecimals() { + return allowDecimals; } - ValueBinding vb = getValueBinding("minText"); - return vb != null ? (String) vb.getValue(getFacesContext()) : null; - } - public void setMinText(String minText) { - this.minText = minText; - } - - public Integer getMinValue() { - return minValue; - } - - public void setMinValue(Integer minValue) { - this.minValue = minValue; - } - - public String getNanText() { - if (nanText != null) { - return nanText; + public void setAllowDecimals(Boolean allowDecimals) { + this.allowDecimals = allowDecimals; } - ValueBinding vb = getValueBinding("nanText"); - return vb != null ? (String) vb.getValue(getFacesContext()) : null; - } - public void setNanText(String nanText) { - this.nanText = nanText; - } + public Boolean getAllowNegative() { + return allowNegative; + } - protected String[] getExtAttributes() { - return EXT_ATTRS; - } + public void setAllowNegative(Boolean allowNegative) { + this.allowNegative = allowNegative; + } - public String getExtComponentType() { - return EXT_COMPONENT_TYPE; - } + public Integer getDecimalPrecision() { + return decimalPrecision; + } - public Object saveState(FacesContext context) { - Object[] values = new Object[11]; - values[0] = super.saveState(context); - values[1] = allowDecimals; - values[2] = allowNegative; - values[3] = decimalPrecision; - values[4] = decimalSeparator; - values[5] = fieldClass; - values[6] = maxText; - values[7] = maxValue; - values[8] = minText; - values[9] = minValue; - values[10] = nanText; - return values; - } + public void setDecimalPrecision(Integer decimalPrecision) { + this.decimalPrecision = decimalPrecision; + } - public void restoreState(FacesContext context, Object state) { - Object values[] = (Object[]) state; - super.restoreState(context, values[0]); - allowDecimals = (Boolean) values[1]; - allowNegative = (Boolean) values[2]; - decimalPrecision = (Integer) values[3]; - decimalSeparator = (String) values[4]; - fieldClass = (String) values[5]; - maxText = (String) values[6]; - maxValue = (Integer) values[7]; - minText = (String) values[8]; - minValue = (Integer) values[9]; - nanText = (String) values[10]; - } + public String getDecimalSeparator() { + return decimalSeparator; + } + + public void setDecimalSeparator(String decimalSeparator) { + this.decimalSeparator = decimalSeparator; + } + + public String getFieldClass() { + return fieldClass; + } + + public void setFieldClass(String fieldClass) { + this.fieldClass = fieldClass; + } + + public String getMaxText() { + if (maxText != null) { + return maxText; + } + ValueBinding vb = getValueBinding("maxText"); + return vb != null ? (String) vb.getValue(getFacesContext()) : null; + } + + public void setMaxText(String maxText) { + this.maxText = maxText; + } + + public Integer getMaxValue() { + return maxValue; + } + + public void setMaxValue(Integer maxValue) { + this.maxValue = maxValue; + } + + public String getMinText() { + if (minText != null) { + return minText; + } + ValueBinding vb = getValueBinding("minText"); + return vb != null ? (String) vb.getValue(getFacesContext()) : null; + } + + public void setMinText(String minText) { + this.minText = minText; + } + + public Integer getMinValue() { + return minValue; + } + + public void setMinValue(Integer minValue) { + this.minValue = minValue; + } + + public String getNanText() { + if (nanText != null) { + return nanText; + } + ValueBinding vb = getValueBinding("nanText"); + return vb != null ? (String) vb.getValue(getFacesContext()) : null; + } + + public void setNanText(String nanText) { + this.nanText = nanText; + } + + protected String[] getExtAttributes() { + return EXT_ATTRS; + } + + public String getExtComponentType() { + return EXT_COMPONENT_TYPE; + } + + public Object saveState(FacesContext context) { + Object[] values = new Object[11]; + values[0] = super.saveState(context); + values[1] = allowDecimals; + values[2] = allowNegative; + values[3] = decimalPrecision; + values[4] = decimalSeparator; + values[5] = fieldClass; + values[6] = maxText; + values[7] = maxValue; + values[8] = minText; + values[9] = minValue; + values[10] = nanText; + return values; + } + + public void restoreState(FacesContext context, Object state) { + Object values[] = (Object[]) state; + super.restoreState(context, values[0]); + allowDecimals = (Boolean) values[1]; + allowNegative = (Boolean) values[2]; + decimalPrecision = (Integer) values[3]; + decimalSeparator = (String) values[4]; + fieldClass = (String) values[5]; + maxText = (String) values[6]; + maxValue = (Integer) values[7]; + minText = (String) values[8]; + minValue = (Integer) values[9]; + nanText = (String) values[10]; + } } diff --git a/spring-webflow/src/main/java/org/springframework/faces/ui/ClientTextValidator.java b/spring-webflow/src/main/java/org/springframework/faces/ui/ClientTextValidator.java index eb629795..752759b4 100644 --- a/spring-webflow/src/main/java/org/springframework/faces/ui/ClientTextValidator.java +++ b/spring-webflow/src/main/java/org/springframework/faces/ui/ClientTextValidator.java @@ -5,302 +5,302 @@ import javax.faces.el.ValueBinding; public class ClientTextValidator extends ExtAdvisor { - private static final String EXT_COMPONENT_TYPE = "Ext.form.TextField"; + private static final String EXT_COMPONENT_TYPE = "Ext.form.TextField"; - private static final String[] EXT_ATTRS_INTERNAL = new String[] { "allowBlank", "blankText", "disableKeyFilter", - "emptyClass", "emptyText", "grow", "growMax", "growMin", "maskRe", "maxLength", "maxLengthText", - "minLength", "minLengthText", "regex", "regexText", "selectOnFocus" }; + private static final String[] EXT_ATTRS_INTERNAL = new String[] { "allowBlank", "blankText", "disableKeyFilter", + "emptyClass", "emptyText", "grow", "growMax", "growMin", "maskRe", "maxLength", "maxLengthText", + "minLength", "minLengthText", "regex", "regexText", "selectOnFocus" }; - protected static final String[] EXT_ATTRS; + protected static final String[] EXT_ATTRS; - static { - EXT_ATTRS = new String[ExtAdvisor.EXT_ATTRS.length + EXT_ATTRS_INTERNAL.length]; - System.arraycopy(ExtAdvisor.EXT_ATTRS, 0, EXT_ATTRS, 0, ExtAdvisor.EXT_ATTRS.length); - System.arraycopy(EXT_ATTRS_INTERNAL, 0, EXT_ATTRS, ExtAdvisor.EXT_ATTRS.length, EXT_ATTRS_INTERNAL.length); - } - - /** - * False to validate that the value length > 0 (defaults to true) - */ - private Boolean allowBlank; - - /** - * Error text to display if the allow blank validation fails (defaults to "This field is required") - */ - private String blankText; - - /** - * True to disable input keystroke filtering (defaults to false) - */ - private Boolean disableKeyFilter; - - /** - * The CSS class to apply to an empty field to style the emptyText (defaults to 'x-form-empty-field'). This class is - * automatically added and removed as needed depending on the current field value. - */ - private String emptyClass; - - /** - * The default text to display in an empty field (defaults to null). - */ - private String emptyText; - - /** - * True if this field should automatically grow and shrink to its content - */ - private Boolean grow; - - /** - * The maximum width to allow when grow = true (defaults to 800) - */ - private Integer growMax; - - /** - * The minimum width to allow when grow = true (defaults to 30) - */ - private Integer growMin; - - /** - * An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null) - */ - private String maskRe; - - /** - * Maximum input field length allowed (defaults to Number.MAX_VALUE) - */ - private Integer maxLength; - - /** - * Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is - * {maxLength}") - */ - private String maxLengthText; - - /** - * Minimum input field length required (defaults to 0) - */ - private Integer minLength; - - /** - * Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is - * {minLength}") - */ - private String minLengthText; - - /** - * A JavaScript RegExp object to be tested against the field value during validation (defaults to null). If - * available, this regex will be evaluated only after the basic validators all return true, and will be passed the - * current field value. If the test fails, the field will be marked invalid using regexText. - */ - private String regex; - - /** - * The error text to display if regex is used and the test fails during validation (defaults to "") - */ - private String regexText; - - /** - * True to automatically select any existing field text when the field receives input focus (defaults to false) - */ - private Boolean selectOnFocus; - - public Boolean getAllowBlank() { - return allowBlank; - } - - public void setAllowBlank(Boolean allowBlank) { - this.allowBlank = allowBlank; - } - - public String getBlankText() { - if (blankText != null) { - return blankText; + static { + EXT_ATTRS = new String[ExtAdvisor.EXT_ATTRS.length + EXT_ATTRS_INTERNAL.length]; + System.arraycopy(ExtAdvisor.EXT_ATTRS, 0, EXT_ATTRS, 0, ExtAdvisor.EXT_ATTRS.length); + System.arraycopy(EXT_ATTRS_INTERNAL, 0, EXT_ATTRS, ExtAdvisor.EXT_ATTRS.length, EXT_ATTRS_INTERNAL.length); } - ValueBinding vb = getValueBinding("blankText"); - return vb != null ? (String) vb.getValue(getFacesContext()) : null; - } - public void setBlankText(String blankText) { - this.blankText = blankText; - } + /** + * False to validate that the value length > 0 (defaults to true) + */ + private Boolean allowBlank; - public Boolean getDisableKeyFilter() { - return disableKeyFilter; - } + /** + * Error text to display if the allow blank validation fails (defaults to "This field is required") + */ + private String blankText; - public void setDisableKeyFilter(Boolean disableKeyFilter) { - this.disableKeyFilter = disableKeyFilter; - } + /** + * True to disable input keystroke filtering (defaults to false) + */ + private Boolean disableKeyFilter; - public String getEmptyClass() { - return emptyClass; - } + /** + * The CSS class to apply to an empty field to style the emptyText (defaults to 'x-form-empty-field'). This class is + * automatically added and removed as needed depending on the current field value. + */ + private String emptyClass; - public void setEmptyClass(String emptyClass) { - this.emptyClass = emptyClass; - } + /** + * The default text to display in an empty field (defaults to null). + */ + private String emptyText; - public String getEmptyText() { - if (emptyText != null) { - return emptyText; + /** + * True if this field should automatically grow and shrink to its content + */ + private Boolean grow; + + /** + * The maximum width to allow when grow = true (defaults to 800) + */ + private Integer growMax; + + /** + * The minimum width to allow when grow = true (defaults to 30) + */ + private Integer growMin; + + /** + * An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null) + */ + private String maskRe; + + /** + * Maximum input field length allowed (defaults to Number.MAX_VALUE) + */ + private Integer maxLength; + + /** + * Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is + * {maxLength}") + */ + private String maxLengthText; + + /** + * Minimum input field length required (defaults to 0) + */ + private Integer minLength; + + /** + * Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is + * {minLength}") + */ + private String minLengthText; + + /** + * A JavaScript RegExp object to be tested against the field value during validation (defaults to null). If + * available, this regex will be evaluated only after the basic validators all return true, and will be passed the + * current field value. If the test fails, the field will be marked invalid using regexText. + */ + private String regex; + + /** + * The error text to display if regex is used and the test fails during validation (defaults to "") + */ + private String regexText; + + /** + * True to automatically select any existing field text when the field receives input focus (defaults to false) + */ + private Boolean selectOnFocus; + + public Boolean getAllowBlank() { + return allowBlank; } - ValueBinding vb = getValueBinding("emptyText"); - return vb != null ? (String) vb.getValue(getFacesContext()) : null; - } - public void setEmptyText(String emptyText) { - this.emptyText = emptyText; - } - - public Boolean getGrow() { - return grow; - } - - public void setGrow(Boolean grow) { - this.grow = grow; - } - - public Integer getGrowMax() { - return growMax; - } - - public void setGrowMax(Integer growMax) { - this.growMax = growMax; - } - - public Integer getGrowMin() { - return growMin; - } - - public void setGrowMin(Integer growMin) { - this.growMin = growMin; - } - - public String getMaskRe() { - return maskRe; - } - - public void setMaskRe(String maskRe) { - this.maskRe = maskRe; - } - - public Integer getMaxLength() { - return maxLength; - } - - public void setMaxLength(Integer maxLength) { - this.maxLength = maxLength; - } - - public String getMaxLengthText() { - if (maxLengthText != null) { - return maxLengthText; + public void setAllowBlank(Boolean allowBlank) { + this.allowBlank = allowBlank; } - ValueBinding vb = getValueBinding("maxLengthText"); - return vb != null ? (String) vb.getValue(getFacesContext()) : null; - } - public void setMaxLengthText(String maskLengthText) { - this.maxLengthText = maskLengthText; - } - - public Integer getMinLength() { - return minLength; - } - - public void setMinLength(Integer minLength) { - this.minLength = minLength; - } - - public String getMinLengthText() { - if (minLengthText != null) { - return minLengthText; + public String getBlankText() { + if (blankText != null) { + return blankText; + } + ValueBinding vb = getValueBinding("blankText"); + return vb != null ? (String) vb.getValue(getFacesContext()) : null; } - ValueBinding vb = getValueBinding("minLengthText"); - return vb != null ? (String) vb.getValue(getFacesContext()) : null; - } - public void setMinLengthText(String minLengthText) { - this.minLengthText = minLengthText; - } - - public String getRegex() { - return regex; - } - - public void setRegex(String regex) { - this.regex = regex; - } - - public String getRegexText() { - if (regexText != null) { - return regexText; + public void setBlankText(String blankText) { + this.blankText = blankText; } - ValueBinding vb = getValueBinding("regexText"); - return vb != null ? (String) vb.getValue(getFacesContext()) : null; - } - public void setRegexText(String regexText) { - this.regexText = regexText; - } + public Boolean getDisableKeyFilter() { + return disableKeyFilter; + } - public Boolean getSelectOnFocus() { - return selectOnFocus; - } + public void setDisableKeyFilter(Boolean disableKeyFilter) { + this.disableKeyFilter = disableKeyFilter; + } - public void setSelectOnFocus(Boolean selectOnFocus) { - this.selectOnFocus = selectOnFocus; - } + public String getEmptyClass() { + return emptyClass; + } - protected String[] getExtAttributes() { - return EXT_ATTRS; - } + public void setEmptyClass(String emptyClass) { + this.emptyClass = emptyClass; + } - public String getExtComponentType() { - return EXT_COMPONENT_TYPE; - } + public String getEmptyText() { + if (emptyText != null) { + return emptyText; + } + ValueBinding vb = getValueBinding("emptyText"); + return vb != null ? (String) vb.getValue(getFacesContext()) : null; + } - public Object saveState(FacesContext context) { - Object[] values = new Object[17]; - values[0] = super.saveState(context); - values[1] = allowBlank; - values[2] = blankText; - values[3] = disableKeyFilter; - values[4] = emptyClass; - values[5] = emptyText; - values[6] = grow; - values[7] = growMax; - values[8] = growMin; - values[9] = maskRe; - values[10] = maxLength; - values[11] = maxLengthText; - values[12] = minLength; - values[13] = minLengthText; - values[14] = regex; - values[15] = regexText; - values[16] = selectOnFocus; - return values; - } + public void setEmptyText(String emptyText) { + this.emptyText = emptyText; + } - public void restoreState(FacesContext context, Object state) { - Object values[] = (Object[]) state; - super.restoreState(context, values[0]); - allowBlank = (Boolean) values[1]; - blankText = (String) values[2]; - disableKeyFilter = (Boolean) values[3]; - emptyClass = (String) values[4]; - emptyText = (String) values[5]; - grow = (Boolean) values[6]; - growMax = (Integer) values[7]; - growMin = (Integer) values[8]; - maskRe = (String) values[9]; - maxLength = (Integer) values[10]; - maxLengthText = (String) values[11]; - minLength = (Integer) values[12]; - minLengthText = (String) values[13]; - regex = (String) values[14]; - regexText = (String) values[15]; - selectOnFocus = (Boolean) values[16]; - } + public Boolean getGrow() { + return grow; + } + + public void setGrow(Boolean grow) { + this.grow = grow; + } + + public Integer getGrowMax() { + return growMax; + } + + public void setGrowMax(Integer growMax) { + this.growMax = growMax; + } + + public Integer getGrowMin() { + return growMin; + } + + public void setGrowMin(Integer growMin) { + this.growMin = growMin; + } + + public String getMaskRe() { + return maskRe; + } + + public void setMaskRe(String maskRe) { + this.maskRe = maskRe; + } + + public Integer getMaxLength() { + return maxLength; + } + + public void setMaxLength(Integer maxLength) { + this.maxLength = maxLength; + } + + public String getMaxLengthText() { + if (maxLengthText != null) { + return maxLengthText; + } + ValueBinding vb = getValueBinding("maxLengthText"); + return vb != null ? (String) vb.getValue(getFacesContext()) : null; + } + + public void setMaxLengthText(String maskLengthText) { + this.maxLengthText = maskLengthText; + } + + public Integer getMinLength() { + return minLength; + } + + public void setMinLength(Integer minLength) { + this.minLength = minLength; + } + + public String getMinLengthText() { + if (minLengthText != null) { + return minLengthText; + } + ValueBinding vb = getValueBinding("minLengthText"); + return vb != null ? (String) vb.getValue(getFacesContext()) : null; + } + + public void setMinLengthText(String minLengthText) { + this.minLengthText = minLengthText; + } + + public String getRegex() { + return regex; + } + + public void setRegex(String regex) { + this.regex = regex; + } + + public String getRegexText() { + if (regexText != null) { + return regexText; + } + ValueBinding vb = getValueBinding("regexText"); + return vb != null ? (String) vb.getValue(getFacesContext()) : null; + } + + public void setRegexText(String regexText) { + this.regexText = regexText; + } + + public Boolean getSelectOnFocus() { + return selectOnFocus; + } + + public void setSelectOnFocus(Boolean selectOnFocus) { + this.selectOnFocus = selectOnFocus; + } + + protected String[] getExtAttributes() { + return EXT_ATTRS; + } + + public String getExtComponentType() { + return EXT_COMPONENT_TYPE; + } + + public Object saveState(FacesContext context) { + Object[] values = new Object[17]; + values[0] = super.saveState(context); + values[1] = allowBlank; + values[2] = blankText; + values[3] = disableKeyFilter; + values[4] = emptyClass; + values[5] = emptyText; + values[6] = grow; + values[7] = growMax; + values[8] = growMin; + values[9] = maskRe; + values[10] = maxLength; + values[11] = maxLengthText; + values[12] = minLength; + values[13] = minLengthText; + values[14] = regex; + values[15] = regexText; + values[16] = selectOnFocus; + return values; + } + + public void restoreState(FacesContext context, Object state) { + Object values[] = (Object[]) state; + super.restoreState(context, values[0]); + allowBlank = (Boolean) values[1]; + blankText = (String) values[2]; + disableKeyFilter = (Boolean) values[3]; + emptyClass = (String) values[4]; + emptyText = (String) values[5]; + grow = (Boolean) values[6]; + growMax = (Integer) values[7]; + growMin = (Integer) values[8]; + maskRe = (String) values[9]; + maxLength = (Integer) values[10]; + maxLengthText = (String) values[11]; + minLength = (Integer) values[12]; + minLengthText = (String) values[13]; + regex = (String) values[14]; + regexText = (String) values[15]; + selectOnFocus = (Boolean) values[16]; + } } diff --git a/spring-webflow/src/main/java/org/springframework/faces/ui/ExtAdvisor.java b/spring-webflow/src/main/java/org/springframework/faces/ui/ExtAdvisor.java index 305e6078..fbe2a86f 100644 --- a/spring-webflow/src/main/java/org/springframework/faces/ui/ExtAdvisor.java +++ b/spring-webflow/src/main/java/org/springframework/faces/ui/ExtAdvisor.java @@ -5,267 +5,267 @@ import javax.faces.el.ValueBinding; public abstract class ExtAdvisor extends ExtJsComponent { - protected static final String[] EXT_ATTRS = new String[] { "cls", "disableClass", "disabled", "fieldClass", - "focusClass", "hideMode", "invalidClass", "invalidText", "msgDisplay", "readOnly", "validateOnBlur", - "validationDelay", "validationEvent", "width" }; + protected static final String[] EXT_ATTRS = new String[] { "cls", "disableClass", "disabled", "fieldClass", + "focusClass", "hideMode", "invalidClass", "invalidText", "msgDisplay", "readOnly", "validateOnBlur", + "validationDelay", "validationEvent", "width" }; - /** - * A CSS class to apply to the field's underlying element. - */ - private String cls; + /** + * A CSS class to apply to the field's underlying element. + */ + private String cls; - /** - * CSS class added to the component when it is disabled (defaults to "x-item-disabled"). - */ - private String disableClass; + /** + * CSS class added to the component when it is disabled (defaults to "x-item-disabled"). + */ + private String disableClass; - /** - * True to disable the field (defaults to false). - */ - private Boolean disabled; + /** + * True to disable the field (defaults to false). + */ + private Boolean disabled; - /** - * The default CSS class for the field (defaults to "x-form-field") - */ - private String fieldClass; + /** + * The default CSS class for the field (defaults to "x-form-field") + */ + private String fieldClass; - /** - * The CSS class to use when the field receives focus (defaults to "x-form-focus") - */ - private String focusClass; + /** + * The CSS class to use when the field receives focus (defaults to "x-form-focus") + */ + private String focusClass; - /** - * How this component should hidden. Supported values are "visibility" (css visibility), "offsets" (negative offset - * position) and "display" (css display) - defaults to "display". - */ - private String hideMode; + /** + * How this component should hidden. Supported values are "visibility" (css visibility), "offsets" (negative offset + * position) and "display" (css display) - defaults to "display". + */ + private String hideMode; - /** - * The CSS class to use when marking a field invalid (defaults to "x-form-invalid") - */ - private String invalidClass; + /** + * The CSS class to use when marking a field invalid (defaults to "x-form-invalid") + */ + private String invalidClass; - /** - * The error text to use when marking a field invalid and no message is provided (defaults to "The value in this - * field is invalid") - */ - private String invalidText; + /** + * The error text to use when marking a field invalid and no message is provided (defaults to "The value in this + * field is invalid") + */ + private String invalidText; - /** - * The CSS class to be applied to the message div when displaying validation messages - */ - private String msgClass; + /** + * The CSS class to be applied to the message div when displaying validation messages + */ + private String msgClass; - /** - * The 'display' style to be applied to the message div when displaying validation messages. - */ - private String msgDisplay; + /** + * The 'display' style to be applied to the message div when displaying validation messages. + */ + private String msgDisplay; - /** - * True to mark the field as readOnly in HTML (defaults to false) -- Note: this only sets the element's readOnly DOM - * attribute. - */ - private Boolean readOnly; + /** + * True to mark the field as readOnly in HTML (defaults to false) -- Note: this only sets the element's readOnly DOM + * attribute. + */ + private Boolean readOnly; - /** - * Whether the field should validate when it loses focus (defaults to true). - */ - private Boolean validateOnBlur; + /** + * Whether the field should validate when it loses focus (defaults to true). + */ + private Boolean validateOnBlur; - /** - * The length of time in milliseconds after user input begins until validation is initiated (defaults to 250) - */ - private Integer validationDelay; + /** + * The length of time in milliseconds after user input begins until validation is initiated (defaults to 250) + */ + private Integer validationDelay; - /** - * The event that should initiate field validation. Set to false to disable automatic validation (defaults to - * "keyup"). - */ - private String validationEvent; + /** + * The event that should initiate field validation. Set to false to disable automatic validation (defaults to + * "keyup"). + */ + private String validationEvent; - /** - * The width to be applied to the field - */ - private Integer width; + /** + * The width to be applied to the field + */ + private Integer width; - public String getCls() { - return cls; - } - - public void setCls(String cls) { - this.cls = cls; - } - - public String getDisableClass() { - return disableClass; - } - - public void setDisableClass(String disableClass) { - this.disableClass = disableClass; - } - - public Boolean getDisabled() { - if (disabled != null) { - return disabled; + public String getCls() { + return cls; } - ValueBinding vb = getValueBinding("disabled"); - return vb != null ? (Boolean) vb.getValue(getFacesContext()) : null; - } - public void setDisabled(Boolean disabled) { - this.disabled = disabled; - } - - public String getFieldClass() { - return fieldClass; - } - - public void setFieldClass(String fieldClass) { - this.fieldClass = fieldClass; - } - - public String getFocusClass() { - return focusClass; - } - - public void setFocusClass(String focusClass) { - this.focusClass = focusClass; - } - - public String getHideMode() { - return hideMode; - } - - public void setHideMode(String hideMode) { - this.hideMode = hideMode; - } - - public String getInvalidClass() { - return invalidClass; - } - - public void setInvalidClass(String invalidClass) { - this.invalidClass = invalidClass; - } - - public String getInvalidText() { - if (invalidText != null) { - return invalidText; + public void setCls(String cls) { + this.cls = cls; } - ValueBinding vb = getValueBinding("invalidText"); - return vb != null ? (String) vb.getValue(getFacesContext()) : null; - } - public void setInvalidText(String invalidText) { - this.invalidText = invalidText; - } - - public String getMsgClass() { - if (msgClass != null) { - return msgClass; + public String getDisableClass() { + return disableClass; } - ValueBinding vb = getValueBinding("msgClass"); - return vb != null ? (String) vb.getValue(getFacesContext()) : null; - } - public void setMsgClass(String msgClass) { - this.msgClass = msgClass; - } - - public String getMsgDisplay() { - return msgDisplay; - } - - public void setMsgDisplay(String msgDisplay) { - this.msgDisplay = msgDisplay; - } - - public Boolean getReadOnly() { - if (readOnly != null) { - return readOnly; + public void setDisableClass(String disableClass) { + this.disableClass = disableClass; } - ValueBinding vb = getValueBinding("readOnly"); - return vb != null ? (Boolean) vb.getValue(getFacesContext()) : null; - } - public void setReadOnly(boolean readOnly) { - this.readOnly = new Boolean(readOnly); - } + public Boolean getDisabled() { + if (disabled != null) { + return disabled; + } + ValueBinding vb = getValueBinding("disabled"); + return vb != null ? (Boolean) vb.getValue(getFacesContext()) : null; + } - public Boolean getValidateOnBlur() { - return validateOnBlur; - } + public void setDisabled(Boolean disabled) { + this.disabled = disabled; + } - public void setValidateOnBlur(Boolean validateOnBlur) { - this.validateOnBlur = validateOnBlur; - } + public String getFieldClass() { + return fieldClass; + } - public Integer getValidationDelay() { - return validationDelay; - } + public void setFieldClass(String fieldClass) { + this.fieldClass = fieldClass; + } - public void setValidationDelay(Integer validationDelay) { - this.validationDelay = validationDelay; - } + public String getFocusClass() { + return focusClass; + } - public String getValidationEvent() { - return validationEvent; - } + public void setFocusClass(String focusClass) { + this.focusClass = focusClass; + } - public void setValidationEvent(String validationEvent) { - this.validationEvent = validationEvent; - } + public String getHideMode() { + return hideMode; + } - public Integer getWidth() { - return width; - } + public void setHideMode(String hideMode) { + this.hideMode = hideMode; + } - public void setWidth(Integer width) { - this.width = width; - } + public String getInvalidClass() { + return invalidClass; + } - protected abstract String[] getExtAttributes(); + public void setInvalidClass(String invalidClass) { + this.invalidClass = invalidClass; + } - public abstract String getExtComponentType(); + public String getInvalidText() { + if (invalidText != null) { + return invalidText; + } + ValueBinding vb = getValueBinding("invalidText"); + return vb != null ? (String) vb.getValue(getFacesContext()) : null; + } - public Object saveState(FacesContext context) { - Object[] values = new Object[16]; - values[0] = super.saveState(context); - values[1] = cls; - values[2] = disableClass; - values[3] = disabled; - values[4] = fieldClass; - values[5] = focusClass; - values[6] = hideMode; - values[7] = invalidClass; - values[8] = invalidText; - values[9] = msgClass; - values[10] = msgDisplay; - values[11] = readOnly; - values[12] = validateOnBlur; - values[13] = validationDelay; - values[14] = validationEvent; - values[15] = width; - return values; - } + public void setInvalidText(String invalidText) { + this.invalidText = invalidText; + } - public void restoreState(FacesContext context, Object state) { - Object values[] = (Object[]) state; - super.restoreState(context, values[0]); - cls = (String) values[1]; - disableClass = (String) values[2]; - disabled = (Boolean) values[3]; - fieldClass = (String) values[4]; - focusClass = (String) values[5]; - hideMode = (String) values[6]; - invalidClass = (String) values[7]; - invalidText = (String) values[8]; - msgClass = (String) values[9]; - msgDisplay = (String) values[10]; - readOnly = (Boolean) values[11]; - validateOnBlur = (Boolean) values[12]; - validationDelay = (Integer) values[13]; - validationEvent = (String) values[14]; - width = (Integer) values[15]; - } + public String getMsgClass() { + if (msgClass != null) { + return msgClass; + } + ValueBinding vb = getValueBinding("msgClass"); + return vb != null ? (String) vb.getValue(getFacesContext()) : null; + } + + public void setMsgClass(String msgClass) { + this.msgClass = msgClass; + } + + public String getMsgDisplay() { + return msgDisplay; + } + + public void setMsgDisplay(String msgDisplay) { + this.msgDisplay = msgDisplay; + } + + public Boolean getReadOnly() { + if (readOnly != null) { + return readOnly; + } + ValueBinding vb = getValueBinding("readOnly"); + return vb != null ? (Boolean) vb.getValue(getFacesContext()) : null; + } + + public void setReadOnly(boolean readOnly) { + this.readOnly = new Boolean(readOnly); + } + + public Boolean getValidateOnBlur() { + return validateOnBlur; + } + + public void setValidateOnBlur(Boolean validateOnBlur) { + this.validateOnBlur = validateOnBlur; + } + + public Integer getValidationDelay() { + return validationDelay; + } + + public void setValidationDelay(Integer validationDelay) { + this.validationDelay = validationDelay; + } + + public String getValidationEvent() { + return validationEvent; + } + + public void setValidationEvent(String validationEvent) { + this.validationEvent = validationEvent; + } + + public Integer getWidth() { + return width; + } + + public void setWidth(Integer width) { + this.width = width; + } + + protected abstract String[] getExtAttributes(); + + public abstract String getExtComponentType(); + + public Object saveState(FacesContext context) { + Object[] values = new Object[16]; + values[0] = super.saveState(context); + values[1] = cls; + values[2] = disableClass; + values[3] = disabled; + values[4] = fieldClass; + values[5] = focusClass; + values[6] = hideMode; + values[7] = invalidClass; + values[8] = invalidText; + values[9] = msgClass; + values[10] = msgDisplay; + values[11] = readOnly; + values[12] = validateOnBlur; + values[13] = validationDelay; + values[14] = validationEvent; + values[15] = width; + return values; + } + + public void restoreState(FacesContext context, Object state) { + Object values[] = (Object[]) state; + super.restoreState(context, values[0]); + cls = (String) values[1]; + disableClass = (String) values[2]; + disabled = (Boolean) values[3]; + fieldClass = (String) values[4]; + focusClass = (String) values[5]; + hideMode = (String) values[6]; + invalidClass = (String) values[7]; + invalidText = (String) values[8]; + msgClass = (String) values[9]; + msgDisplay = (String) values[10]; + readOnly = (Boolean) values[11]; + validateOnBlur = (Boolean) values[12]; + validationDelay = (Integer) values[13]; + validationEvent = (String) values[14]; + width = (Integer) values[15]; + } } diff --git a/spring-webflow/src/main/java/org/springframework/faces/ui/ExtAdvisorRenderer.java b/spring-webflow/src/main/java/org/springframework/faces/ui/ExtAdvisorRenderer.java index 765cfb9d..c8747b5a 100644 --- a/spring-webflow/src/main/java/org/springframework/faces/ui/ExtAdvisorRenderer.java +++ b/spring-webflow/src/main/java/org/springframework/faces/ui/ExtAdvisorRenderer.java @@ -15,69 +15,69 @@ import javax.faces.context.ResponseWriter; */ public class ExtAdvisorRenderer extends ExtJsRenderer { - private static final String CLASS_ATTR = "class"; + private static final String CLASS_ATTR = "class"; - private static final String ID_ATTR = "id"; + private static final String ID_ATTR = "id"; - private static final String SCRIPT_ELEMENT = "script"; + private static final String SCRIPT_ELEMENT = "script"; - private static final String DIV_ELEMENT = "div"; + private static final String DIV_ELEMENT = "div"; - public void encodeEnd(FacesContext context, UIComponent component) throws IOException { + public void encodeEnd(FacesContext context, UIComponent component) throws IOException { - ResponseWriter writer = context.getResponseWriter(); + ResponseWriter writer = context.getResponseWriter(); - if (component.getChildCount() == 0) - throw new FacesException("A Spring Faces advisor expects to have at least one child component."); + if (component.getChildCount() == 0) + throw new FacesException("A Spring Faces advisor expects to have at least one child component."); - UIComponent advisedChild = (UIComponent) component.getChildren().get(0); + UIComponent advisedChild = (UIComponent) component.getChildren().get(0); - writer.startElement(DIV_ELEMENT, component); - writer.writeAttribute(ID_ATTR, advisedChild.getClientId(context) + ":msg", null); - writer.writeAttribute(CLASS_ATTR, ((ExtAdvisor) component).getMsgClass(), null); - writer.endElement(DIV_ELEMENT); + writer.startElement(DIV_ELEMENT, component); + writer.writeAttribute(ID_ATTR, advisedChild.getClientId(context) + ":msg", null); + writer.writeAttribute(CLASS_ATTR, ((ExtAdvisor) component).getMsgClass(), null); + writer.endElement(DIV_ELEMENT); - writer.startElement(SCRIPT_ELEMENT, component); - StringBuffer script = new StringBuffer(); - script.append(" SpringFaces.advisors.push(new SpringFaces.ExtGenericFieldAdvisor({ "); - script.append(" targetElId : '" + advisedChild.getClientId(context) + "', "); - script.append(" msgElId : '" + advisedChild.getClientId(context) + ":msg', "); - script.append(" decoratorType : '" + ((ExtAdvisor) component).getExtComponentType() + "', "); - script.append(" decoratorAttrs : \"{ "); + writer.startElement(SCRIPT_ELEMENT, component); + StringBuffer script = new StringBuffer(); + script.append(" SpringFaces.advisors.push(new SpringFaces.ExtGenericFieldAdvisor({ "); + script.append(" targetElId : '" + advisedChild.getClientId(context) + "', "); + script.append(" msgElId : '" + advisedChild.getClientId(context) + ":msg', "); + script.append(" decoratorType : '" + ((ExtAdvisor) component).getExtComponentType() + "', "); + script.append(" decoratorAttrs : \"{ "); - script.append(getExtAttributesAsString(context, component)); + script.append(getExtAttributesAsString(context, component)); - script.append(" }\"})); "); + script.append(" }\"})); "); - writer.writeText(script, null); - writer.endElement(SCRIPT_ELEMENT); - } - - protected String getExtAttributesAsString(FacesContext context, UIComponent component) { - - ExtAdvisor advisor = (ExtAdvisor) component; - StringBuffer attrs = new StringBuffer(); - - for (int i = 0; i < advisor.getExtAttributes().length; i++) { - - String key = advisor.getExtAttributes()[i]; - Object value = advisor.getAttributes().get(key); - - if (value != null) { - - if (attrs.length() > 0) - attrs.append(", "); - - attrs.append(key + " : "); - - if (value instanceof String) { - attrs.append("'" + value + "'"); - } else { - attrs.append(value); - } - - } + writer.writeText(script, null); + writer.endElement(SCRIPT_ELEMENT); + } + + protected String getExtAttributesAsString(FacesContext context, UIComponent component) { + + ExtAdvisor advisor = (ExtAdvisor) component; + StringBuffer attrs = new StringBuffer(); + + for (int i = 0; i < advisor.getExtAttributes().length; i++) { + + String key = advisor.getExtAttributes()[i]; + Object value = advisor.getAttributes().get(key); + + if (value != null) { + + if (attrs.length() > 0) + attrs.append(", "); + + attrs.append(key + " : "); + + if (value instanceof String) { + attrs.append("'" + value + "'"); + } else { + attrs.append(value); + } + + } + } + return attrs.toString(); } - return attrs.toString(); - } } diff --git a/spring-webflow/src/main/java/org/springframework/faces/ui/ExtJsComponent.java b/spring-webflow/src/main/java/org/springframework/faces/ui/ExtJsComponent.java index dcedc521..bff9916f 100644 --- a/spring-webflow/src/main/java/org/springframework/faces/ui/ExtJsComponent.java +++ b/spring-webflow/src/main/java/org/springframework/faces/ui/ExtJsComponent.java @@ -5,53 +5,53 @@ import javax.faces.context.FacesContext; public class ExtJsComponent extends UIComponentBase { - /** - * The component will render the default ExtJs css resources by default. This may be set to false if the page - * developer wants to include their own stylesheet. - */ - private Boolean includeExtStyles = new Boolean(true); + /** + * The component will render the default ExtJs css resources by default. This may be set to false if the page + * developer wants to include their own stylesheet. + */ + private Boolean includeExtStyles = new Boolean(true); - /** - * The component will render an optimized version of the ExtJs javascript that contains only the pieces of the - * library used by SpringFaces. This may be set to false if the page developer wants to include their own ExtJs - * resources. - */ - private Boolean includeExtScript = new Boolean(true); + /** + * The component will render an optimized version of the ExtJs javascript that contains only the pieces of the + * library used by SpringFaces. This may be set to false if the page developer wants to include their own ExtJs + * resources. + */ + private Boolean includeExtScript = new Boolean(true); - public String getFamily() { + public String getFamily() { - return "spring.faces.ExtAdvisor"; - } + return "spring.faces.ExtAdvisor"; + } - public Boolean getIncludeExtStyles() { - return includeExtStyles; - } + public Boolean getIncludeExtStyles() { + return includeExtStyles; + } - public void setIncludeExtStyles(Boolean includeExtStyles) { - this.includeExtStyles = includeExtStyles; - } + public void setIncludeExtStyles(Boolean includeExtStyles) { + this.includeExtStyles = includeExtStyles; + } - public Boolean getIncludeExtScript() { - return includeExtScript; - } + public Boolean getIncludeExtScript() { + return includeExtScript; + } - public void setIncludeExtScript(Boolean includeExtScript) { - this.includeExtScript = includeExtScript; - } + public void setIncludeExtScript(Boolean includeExtScript) { + this.includeExtScript = includeExtScript; + } - public Object saveState(FacesContext context) { - Object[] values = new Object[3]; - values[0] = super.saveState(context); - values[1] = includeExtScript; - values[2] = includeExtStyles; - return values; - } + public Object saveState(FacesContext context) { + Object[] values = new Object[3]; + values[0] = super.saveState(context); + values[1] = includeExtScript; + values[2] = includeExtStyles; + return values; + } - public void restoreState(FacesContext context, Object state) { - Object values[] = (Object[]) state; - super.restoreState(context, values[0]); - includeExtScript = (Boolean) values[1]; - includeExtStyles = (Boolean) values[2]; - } + public void restoreState(FacesContext context, Object state) { + Object values[] = (Object[]) state; + super.restoreState(context, values[0]); + includeExtScript = (Boolean) values[1]; + includeExtStyles = (Boolean) values[2]; + } } diff --git a/spring-webflow/src/main/java/org/springframework/faces/ui/ExtJsRenderer.java b/spring-webflow/src/main/java/org/springframework/faces/ui/ExtJsRenderer.java index c89a5774..94c460e9 100644 --- a/spring-webflow/src/main/java/org/springframework/faces/ui/ExtJsRenderer.java +++ b/spring-webflow/src/main/java/org/springframework/faces/ui/ExtJsRenderer.java @@ -12,26 +12,26 @@ import org.apache.shale.remoting.XhtmlHelper; public class ExtJsRenderer extends Renderer { - private static final String EXT_CSS = "/org/springframework/faces/ui/ext/resources/css/ext-all.css"; + private static final String EXT_CSS = "/org/springframework/faces/ui/ext/resources/css/ext-all.css"; - private static final String EXT_SCRIPT = "/org/springframework/faces/ui/ext/ext.js"; + private static final String EXT_SCRIPT = "/org/springframework/faces/ui/ext/ext.js"; - private static final String SPRING_FACES_SCRIPT = "/org/springframework/faces/ui/SpringFaces.js"; + private static final String SPRING_FACES_SCRIPT = "/org/springframework/faces/ui/SpringFaces.js"; - private XhtmlHelper resourceHelper = new XhtmlHelper(); + private XhtmlHelper resourceHelper = new XhtmlHelper(); - public void encodeBegin(FacesContext context, UIComponent component) throws IOException { + public void encodeBegin(FacesContext context, UIComponent component) throws IOException { - ExtJsComponent extJsComponent = (ExtJsComponent) component; + ExtJsComponent extJsComponent = (ExtJsComponent) component; - ResponseWriter writer = context.getResponseWriter(); + ResponseWriter writer = context.getResponseWriter(); - if (extJsComponent.getIncludeExtStyles().equals(Boolean.TRUE)) - resourceHelper.linkStylesheet(context, extJsComponent, writer, Mechanism.CLASS_RESOURCE, EXT_CSS); + if (extJsComponent.getIncludeExtStyles().equals(Boolean.TRUE)) + resourceHelper.linkStylesheet(context, extJsComponent, writer, Mechanism.CLASS_RESOURCE, EXT_CSS); - if (extJsComponent.getIncludeExtScript().equals(Boolean.TRUE)) - resourceHelper.linkJavascript(context, extJsComponent, writer, Mechanism.CLASS_RESOURCE, EXT_SCRIPT); + if (extJsComponent.getIncludeExtScript().equals(Boolean.TRUE)) + resourceHelper.linkJavascript(context, extJsComponent, writer, Mechanism.CLASS_RESOURCE, EXT_SCRIPT); - resourceHelper.linkJavascript(context, extJsComponent, writer, Mechanism.CLASS_RESOURCE, SPRING_FACES_SCRIPT); - } + resourceHelper.linkJavascript(context, extJsComponent, writer, Mechanism.CLASS_RESOURCE, SPRING_FACES_SCRIPT); + } } diff --git a/spring-webflow/src/main/java/org/springframework/faces/ui/ExtValidateAllRenderer.java b/spring-webflow/src/main/java/org/springframework/faces/ui/ExtValidateAllRenderer.java index 7ff1b214..8f2fe2aa 100644 --- a/spring-webflow/src/main/java/org/springframework/faces/ui/ExtValidateAllRenderer.java +++ b/spring-webflow/src/main/java/org/springframework/faces/ui/ExtValidateAllRenderer.java @@ -10,35 +10,35 @@ import javax.faces.context.ResponseWriter; public class ExtValidateAllRenderer extends ExtJsRenderer { - private static final String SCRIPT_ELEMENT = "script"; + private static final String SCRIPT_ELEMENT = "script"; - public void encodeEnd(FacesContext context, UIComponent component) throws IOException { + public void encodeEnd(FacesContext context, UIComponent component) throws IOException { - ResponseWriter writer = context.getResponseWriter(); + ResponseWriter writer = context.getResponseWriter(); - if (component.getChildCount() == 0) - throw new FacesException("A Spring Faces advisor expects to have at least one child component."); + if (component.getChildCount() == 0) + throw new FacesException("A Spring Faces advisor expects to have at least one child component."); - if (!(component.getChildren().get(0) instanceof UICommand)) - throw new FacesException("ValidateAll expects to have a child of type UICommand."); + if (!(component.getChildren().get(0) instanceof UICommand)) + throw new FacesException("ValidateAll expects to have a child of type UICommand."); - UIComponent advisedChild = (UIComponent) component.getChildren().get(0); + UIComponent advisedChild = (UIComponent) component.getChildren().get(0); - String elementVar = advisedChild.getClientId(context).replaceAll(":", "_") + "_element"; - String handlerVar = advisedChild.getClientId(context).replaceAll(":", "_") + "_handler"; + String elementVar = advisedChild.getClientId(context).replaceAll(":", "_") + "_element"; + String handlerVar = advisedChild.getClientId(context).replaceAll(":", "_") + "_handler"; - writer.startElement(SCRIPT_ELEMENT, component); - StringBuffer script = new StringBuffer(); - script - .append(" var " + elementVar + " = document.getElementById('" + advisedChild.getClientId(context) - + "');"); - script.append(" var " + handlerVar + " = " + elementVar + ".onclick;"); - script.append(elementVar + ".onclick" + " = function(){"); - script.append(" if(!SpringFaces.validateAll()) return false; "); - script.append(handlerVar + "();"); - script.append("};"); + writer.startElement(SCRIPT_ELEMENT, component); + StringBuffer script = new StringBuffer(); + script + .append(" var " + elementVar + " = document.getElementById('" + advisedChild.getClientId(context) + + "');"); + script.append(" var " + handlerVar + " = " + elementVar + ".onclick;"); + script.append(elementVar + ".onclick" + " = function(){"); + script.append(" if(!SpringFaces.validateAll()) return false; "); + script.append(handlerVar + "();"); + script.append("};"); - writer.writeText(script, null); - writer.endElement(SCRIPT_ELEMENT); - } + writer.writeText(script, null); + writer.endElement(SCRIPT_ELEMENT); + } }