diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/ExtAdvisor.java b/spring-faces/src/main/java/org/springframework/faces/ui/ExtAdvisor.java deleted file mode 100644 index 089fc689..00000000 --- a/spring-faces/src/main/java/org/springframework/faces/ui/ExtAdvisor.java +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.faces.ui; - -import javax.faces.context.FacesContext; -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" }; - - /** - * 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; - - /** - * 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 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; - - /** - * 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 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; - - /** - * 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; - - /** - * 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 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; - } - ValueBinding exp = getValueBinding("disabled"); - return exp != null ? (Boolean) exp.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; - } - ValueBinding exp = getValueBinding("invalidText"); - return exp != null ? (String) exp.getValue(getFacesContext()) : null; - } - - public void setInvalidText(String invalidText) { - this.invalidText = invalidText; - } - - public String getMsgClass() { - if (msgClass != null) { - return msgClass; - } - ValueBinding exp = getValueBinding("msgClass"); - return exp != null ? (String) exp.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 exp = getValueBinding("readOnly"); - return exp != null ? (Boolean) exp.getValue(getFacesContext()) : null; - } - - public void setReadOnly(Boolean readOnly) { - this.readOnly = 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-faces/src/main/java/org/springframework/faces/ui/ExtAdvisorRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/ExtAdvisorRenderer.java deleted file mode 100644 index 3db16bc2..00000000 --- a/spring-faces/src/main/java/org/springframework/faces/ui/ExtAdvisorRenderer.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.faces.ui; - -import java.io.IOException; - -import javax.faces.FacesException; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.context.ResponseWriter; - -/** - * A base implementation for use in rendering Ext based components that enhance existing DOM elements. - * - * @author Jeremy Grelle - * - */ -public class ExtAdvisorRenderer extends ExtJsRenderer { - - private static final String CLASS_ATTR = "class"; - - private static final String ID_ATTR = "id"; - - private static final String SCRIPT_ELEMENT = "script"; - - private static final String DIV_ELEMENT = "div"; - - public void encodeEnd(FacesContext context, UIComponent component) throws IOException { - - ResponseWriter writer = context.getResponseWriter(); - - 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); - - 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(" Spring.advisors.push(new Spring.ValidatingFieldAdvisor({ "); - 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(" }\"})); "); - - 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(); - } -} diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/ExtClientDateValidator.java b/spring-faces/src/main/java/org/springframework/faces/ui/ExtClientDateValidator.java deleted file mode 100644 index f7780925..00000000 --- a/spring-faces/src/main/java/org/springframework/faces/ui/ExtClientDateValidator.java +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.faces.ui; - -import javax.faces.context.FacesContext; -import javax.faces.el.ValueBinding; - -public class ExtClientDateValidator extends ExtClientTextValidator { - - 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" }; - - protected static final String[] EXT_ATTRS; - - static { - EXT_ATTRS = new String[ExtClientTextValidator.EXT_ATTRS.length + EXT_ATTRS_INTERNAL.length]; - System.arraycopy(ExtClientTextValidator.EXT_ATTRS, 0, EXT_ATTRS, 0, ExtClientTextValidator.EXT_ATTRS.length); - System.arraycopy(EXT_ATTRS_INTERNAL, 0, EXT_ATTRS, ExtClientTextValidator.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; - } - ValueBinding vb = getValueBinding("disabledDatesText"); - return vb != null ? (String) vb.getValue(getFacesContext()) : null; - } - - public void setDisabledDatesText(String disabledDatesText) { - this.disabledDatesText = disabledDatesText; - } - - public String getDisabledDays() { - return disabledDays; - } - - public void setDisabledDays(String disabledDays) { - this.disabledDays = disabledDays; - } - - public String getDisabledDaysText() { - if (disabledDaysText != null) { - return disabledDaysText; - } - 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; - } - 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-faces/src/main/java/org/springframework/faces/ui/ExtClientNumberValidator.java b/spring-faces/src/main/java/org/springframework/faces/ui/ExtClientNumberValidator.java deleted file mode 100644 index 1c69cd0a..00000000 --- a/spring-faces/src/main/java/org/springframework/faces/ui/ExtClientNumberValidator.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.faces.ui; - -import javax.faces.context.FacesContext; -import javax.faces.el.ValueBinding; - -public class ExtClientNumberValidator extends ExtClientTextValidator { - - 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" }; - - protected static final String[] EXT_ATTRS; - - static { - EXT_ATTRS = new String[ExtClientTextValidator.EXT_ATTRS.length + EXT_ATTRS_INTERNAL.length]; - System.arraycopy(ExtClientTextValidator.EXT_ATTRS, 0, EXT_ATTRS, 0, ExtClientTextValidator.EXT_ATTRS.length); - System.arraycopy(EXT_ATTRS_INTERNAL, 0, EXT_ATTRS, ExtClientTextValidator.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; - } - 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-faces/src/main/java/org/springframework/faces/ui/ExtClientTextValidator.java b/spring-faces/src/main/java/org/springframework/faces/ui/ExtClientTextValidator.java deleted file mode 100644 index bbd798a4..00000000 --- a/spring-faces/src/main/java/org/springframework/faces/ui/ExtClientTextValidator.java +++ /dev/null @@ -1,321 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.faces.ui; - -import javax.faces.context.FacesContext; -import javax.faces.el.ValueBinding; - -public class ExtClientTextValidator extends ExtAdvisor { - - 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" }; - - 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; - } - ValueBinding vb = getValueBinding("blankText"); - return vb != null ? (String) vb.getValue(getFacesContext()) : null; - } - - public void setBlankText(String blankText) { - this.blankText = blankText; - } - - public Boolean getDisableKeyFilter() { - return disableKeyFilter; - } - - public void setDisableKeyFilter(Boolean disableKeyFilter) { - this.disableKeyFilter = disableKeyFilter; - } - - public String getEmptyClass() { - return emptyClass; - } - - public void setEmptyClass(String emptyClass) { - this.emptyClass = emptyClass; - } - - public String getEmptyText() { - if (emptyText != null) { - return emptyText; - } - 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; - } - 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-faces/src/main/java/org/springframework/faces/ui/ExtJsComponent.java b/spring-faces/src/main/java/org/springframework/faces/ui/ExtJsComponent.java deleted file mode 100644 index 15b29ca0..00000000 --- a/spring-faces/src/main/java/org/springframework/faces/ui/ExtJsComponent.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.faces.ui; - -import javax.faces.component.UIComponentBase; -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 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() { - - return "spring.faces.Advisor"; - } - - public Boolean getIncludeExtStyles() { - return includeExtStyles; - } - - public void setIncludeExtStyles(Boolean includeExtStyles) { - this.includeExtStyles = includeExtStyles; - } - - public Boolean getIncludeExtScript() { - return 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 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-faces/src/main/java/org/springframework/faces/ui/ExtJsRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/ExtJsRenderer.java deleted file mode 100644 index 3f0c0580..00000000 --- a/spring-faces/src/main/java/org/springframework/faces/ui/ExtJsRenderer.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2004-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.faces.ui; - -import java.io.IOException; - -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; - -import org.springframework.faces.ui.resource.ResourceHelper; - -public class ExtJsRenderer extends SpringFacesRenderer { - - private static final String EXT_CSS = "/ext/resources/css/ext-all.css"; - - private static final String EXT_SCRIPT = "/ext/ext.js"; - - private static final String SPRING_EXT_SCRIPT = "/spring/Spring-Ext.js"; - - private ResourceHelper resourceHelper = new ResourceHelper(); - - public void encodeBegin(FacesContext context, UIComponent component) throws IOException { - - super.encodeBegin(context, component); - - ExtJsComponent extJsComponent = (ExtJsComponent) component; - - if (extJsComponent.getIncludeExtStyles().equals(Boolean.TRUE)) { - resourceHelper.renderStyleLink(context, EXT_CSS); - } - - if (extJsComponent.getIncludeExtScript().equals(Boolean.TRUE)) { - resourceHelper.renderScriptLink(context, EXT_SCRIPT); - } - - resourceHelper.renderScriptLink(context, SPRING_EXT_SCRIPT); - } -} diff --git a/spring-faces/src/main/resources/META-INF/faces-config.xml b/spring-faces/src/main/resources/META-INF/faces-config.xml index d21b45af..18ceb947 100644 --- a/spring-faces/src/main/resources/META-INF/faces-config.xml +++ b/spring-faces/src/main/resources/META-INF/faces-config.xml @@ -77,21 +77,6 @@ org.springframework.faces.ui.DojoClientDateValidator - - spring.faces.ExtClientTextValidator - org.springframework.faces.ui.ExtClientTextValidator - - - - spring.faces.ExtClientNumberValidator - org.springframework.faces.ui.ExtClientNumberValidator - - - - spring.faces.ExtClientDateValidator - org.springframework.faces.ui.ExtClientDateValidator - - spring.faces.ValidateAll org.springframework.faces.ui.ValidateAll @@ -118,12 +103,6 @@ org.springframework.faces.ui.AjaxEventInterceptorRenderer - - spring.faces.Advisor - spring.faces.ExtAdvisor - org.springframework.faces.ui.ExtAdvisorRenderer - - spring.faces.Advisor spring.faces.DojoAdvisor diff --git a/spring-faces/src/main/resources/META-INF/springfaces-ext.taglib.xml b/spring-faces/src/main/resources/META-INF/springfaces-ext.taglib.xml deleted file mode 100644 index 2a02423e..00000000 --- a/spring-faces/src/main/resources/META-INF/springfaces-ext.taglib.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - http://www.springframework.org/tags/faces-ext - - - clientTextValidator - - spring.faces.ExtClientTextValidator - spring.faces.ExtAdvisor - - - - - clientNumberValidator - - spring.faces.ExtClientNumberValidator - spring.faces.ExtAdvisor - - - - - clientDateValidator - - spring.faces.ExtClientDateValidator - spring.faces.ExtAdvisor - - - - \ No newline at end of file