@Override public int getMinLength() { TextAttributeValidationRules validationRule = (TextAttributeValidationRules) this.getValidationRules(); if (null != validationRule && null != validationRule.getMinLength()) { return validationRule.getMinLength(); } return -1; }
@Override public int getMinLength() { TextAttributeValidationRules validationRule = (TextAttributeValidationRules) this.getValidationRules(); if (null != validationRule && null != validationRule.getMinLength()) { return validationRule.getMinLength(); } return -1; }
@Override public boolean isEmpty() { return (super.isEmpty() && (null == this.getMaxLength() || this.getMaxLength() < 0) && (null == this.getMinLength() || this.getMinLength() < 0) && (null == this.getRegexp() || this.getRegexp().trim().length() == 0)); }
@Override public boolean isEmpty() { return (super.isEmpty() && (null == this.getMaxLength() || this.getMaxLength() < 0) && (null == this.getMinLength() || this.getMinLength() < 0) && (null == this.getRegexp() || this.getRegexp().trim().length() == 0)); }
protected void checkTextLengths(AttributeInterface attribute, AttributeTracer tracer, Lang lang, List<AttributeFieldError> errors) { Integer maxLength = this.getMaxLength(); Integer minLength = this.getMinLength(); if ((null != maxLength && maxLength > -1) || (null != minLength && minLength > -1)) { String text = this.getTextForCheckLength(attribute, lang); if (text != null && text.trim().length() > 0) { text = text.trim(); if ((null != maxLength && maxLength > -1) && text.length() > maxLength) { AttributeFieldError error = new AttributeFieldError(attribute, FieldError.INVALID_MAX_LENGTH, tracer); error.setMessage("Lang '" + lang.getDescr() + "' - length " + text.length() + " upper than " + maxLength); errors.add(error); } if ((null != minLength && minLength > -1) && text.length() < minLength) { AttributeFieldError error = new AttributeFieldError(attribute, FieldError.INVALID_MIN_LENGTH, tracer); error.setMessage("Lang '" + lang.getDescr() + "' - length " + text.length() + " lower than " + minLength); errors.add(error); } } } }
protected void checkTextLengths(AttributeInterface attribute, AttributeTracer tracer, Lang lang, List<AttributeFieldError> errors) { Integer maxLength = this.getMaxLength(); Integer minLength = this.getMinLength(); if ((null != maxLength && maxLength > -1) || (null != minLength && minLength > -1)) { String text = this.getTextForCheckLength(attribute, lang); if (text != null && text.trim().length() > 0) { text = text.trim(); if ((null != maxLength && maxLength > -1) && text.length() > maxLength) { AttributeFieldError error = new AttributeFieldError(attribute, FieldError.INVALID_MAX_LENGTH, tracer); error.setMessage("Lang '" + lang.getDescr() + "' - length " + text.length() + " upper than " + maxLength); errors.add(error); } if ((null != minLength && minLength > -1) && text.length() < minLength) { AttributeFieldError error = new AttributeFieldError(attribute, FieldError.INVALID_MIN_LENGTH, tracer); error.setMessage("Lang '" + lang.getDescr() + "' - length " + text.length() + " lower than " + minLength); errors.add(error); } } } }
@Override protected String getCustomAttributeErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) { AttributeInterface attribute = attributeFieldError.getAttribute(); TextAttributeValidationRules valRules = (TextAttributeValidationRules) attribute.getValidationRules(); if (null != valRules) { ITextAttribute textAttribute = (ITextAttribute) attribute; String text = textAttribute.getTextForLang(null); String errorCode = attributeFieldError.getErrorCode(); if (errorCode.equals(FieldError.INVALID_MIN_LENGTH)) { String[] args = {String.valueOf(text.length()), String.valueOf(valRules.getMinLength())}; return action.getText("MonotextAttribute.fieldError.invalidMinLength", args); } else if (errorCode.equals(FieldError.INVALID_MAX_LENGTH)) { String[] args = {String.valueOf(text.length()), String.valueOf(valRules.getMaxLength())}; return action.getText("MonotextAttribute.fieldError.invalidMaxLength", args); } else if (errorCode.equals(FieldError.INVALID_FORMAT)) { return action.getText("MonotextAttribute.fieldError.invalidInsertedText"); } } return action.getText(this.getInvalidAttributeMessage()); }
@Override protected String getCustomAttributeErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) { AttributeInterface attribute = attributeFieldError.getAttribute(); TextAttributeValidationRules valRules = (TextAttributeValidationRules) attribute.getValidationRules(); if (null != valRules) { ITextAttribute textAttribute = (ITextAttribute) attribute; String text = textAttribute.getTextForLang(null); String errorCode = attributeFieldError.getErrorCode(); if (errorCode.equals(FieldError.INVALID_MIN_LENGTH)) { String[] args = {String.valueOf(text.length()), String.valueOf(valRules.getMinLength())}; return action.getText("MonotextAttribute.fieldError.invalidMinLength", args); } else if (errorCode.equals(FieldError.INVALID_MAX_LENGTH)) { String[] args = {String.valueOf(text.length()), String.valueOf(valRules.getMaxLength())}; return action.getText("MonotextAttribute.fieldError.invalidMaxLength", args); } else if (errorCode.equals(FieldError.INVALID_FORMAT)) { return action.getText("MonotextAttribute.fieldError.invalidInsertedText"); } } return action.getText(this.getInvalidAttributeMessage()); }
@Override protected String getCustomAttributeErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) { AttributeInterface attribute = attributeFieldError.getAttribute(); TextAttributeValidationRules valRules = (TextAttributeValidationRules) attribute.getValidationRules(); if (null != valRules) { ITextAttribute textAttribute = (ITextAttribute) attribute; String text = textAttribute.getTextForLang(null); String errorCode = attributeFieldError.getErrorCode(); if (errorCode.equals(FieldError.INVALID_MIN_LENGTH)) { String[] args = {String.valueOf(text.length()), String.valueOf(valRules.getMinLength())}; return action.getText("MonotextAttribute.fieldError.invalidMinLength", args); } else if (errorCode.equals(FieldError.INVALID_MAX_LENGTH)) { String[] args = {String.valueOf(text.length()), String.valueOf(valRules.getMaxLength())}; return action.getText("MonotextAttribute.fieldError.invalidMaxLength", args); } else if (errorCode.equals(FieldError.INVALID_FORMAT)) { return action.getText("MonotextAttribute.fieldError.invalidInsertedText"); } } return action.getText(this.getInvalidAttributeMessage()); }
@Override protected void fillJDOMConfigElement(Element configElement) { super.fillJDOMConfigElement(configElement); if (null != this.getMinLength() && this.getMinLength() > -1) { Element element = new Element("minlength"); element.setText(String.valueOf(this.getMinLength())); configElement.addContent(element); } if (null != this.getMaxLength() && this.getMaxLength() > -1) { Element element = new Element("maxlength"); element.setText(String.valueOf(this.getMaxLength())); configElement.addContent(element); } if (null != this.getRegexp() && this.getRegexp().trim().length() > 0) { Element regexpElem = new Element("regexp"); CDATA cdata = new CDATA(this.getRegexp()); regexpElem.addContent(cdata); configElement.addContent(regexpElem); } String toStringEqualValue = (this.getValue() != null) ? String.valueOf(this.getValue()) : null; this.insertJDOMConfigElement("value", this.getValueAttribute(), toStringEqualValue, configElement); String toStringStartValue = (this.getRangeStart() != null) ? String.valueOf(this.getRangeStart()) : null; this.insertJDOMConfigElement("rangestart", this.getRangeStartAttribute(), toStringStartValue, configElement); String toStringEndValue = (this.getRangeEnd() != null) ? String.valueOf(this.getRangeEnd()) : null; this.insertJDOMConfigElement("rangeend", this.getRangeEndAttribute(), toStringEndValue, configElement); }
@Override protected void fillJDOMConfigElement(Element configElement) { super.fillJDOMConfigElement(configElement); if (null != this.getMinLength() && this.getMinLength() > -1) { Element element = new Element("minlength"); element.setText(String.valueOf(this.getMinLength())); configElement.addContent(element); } if (null != this.getMaxLength() && this.getMaxLength() > -1) { Element element = new Element("maxlength"); element.setText(String.valueOf(this.getMaxLength())); configElement.addContent(element); } if (null != this.getRegexp() && this.getRegexp().trim().length() > 0) { Element regexpElem = new Element("regexp"); CDATA cdata = new CDATA(this.getRegexp()); regexpElem.addContent(cdata); configElement.addContent(regexpElem); } String toStringEqualValue = (this.getValue() != null) ? String.valueOf(this.getValue()) : null; this.insertJDOMConfigElement("value", this.getValueAttribute(), toStringEqualValue, configElement); String toStringStartValue = (this.getRangeStart() != null) ? String.valueOf(this.getRangeStart()) : null; this.insertJDOMConfigElement("rangestart", this.getRangeStartAttribute(), toStringStartValue, configElement); String toStringEndValue = (this.getRangeEnd() != null) ? String.valueOf(this.getRangeEnd()) : null; this.insertJDOMConfigElement("rangeend", this.getRangeEndAttribute(), toStringEndValue, configElement); }
@Override protected String getCustomAttributeErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) { AttributeInterface attribute = attributeFieldError.getAttribute(); TextAttributeValidationRules valRules = (TextAttributeValidationRules) attribute.getValidationRules(); if (null != valRules) { ITextAttribute textAttribute = (ITextAttribute) attribute; Lang lang = attributeFieldError.getTracer().getLang(); String langCode = (null != lang) ? lang.getCode() : null; String text = textAttribute.getTextForLang(langCode); String errorCode = attributeFieldError.getErrorCode(); if (errorCode.equals(FieldError.INVALID_MIN_LENGTH)) { String[] args = {String.valueOf(text.length()), String.valueOf(valRules.getMinLength()), lang.getDescr()}; return action.getText("TextAttribute.fieldError.invalidMinLength", args); } else if (errorCode.equals(FieldError.INVALID_MAX_LENGTH)) { String[] args = {String.valueOf(text.length()), String.valueOf(valRules.getMaxLength()), lang.getDescr()}; return action.getText("TextAttribute.fieldError.invalidMaxLength", args); } else if (errorCode.equals(FieldError.INVALID_FORMAT)) { String[] args = {lang.getDescr()}; return action.getText("TextAttribute.fieldError.invalidInsertedText", args); } } return action.getText(this.getInvalidAttributeMessage()); }
@Override protected String getCustomAttributeErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) { AttributeInterface attribute = attributeFieldError.getAttribute(); TextAttributeValidationRules valRules = (TextAttributeValidationRules) attribute.getValidationRules(); if (null != valRules) { ITextAttribute textAttribute = (ITextAttribute) attribute; Lang lang = attributeFieldError.getTracer().getLang(); String langCode = (null != lang) ? lang.getCode() : null; String text = textAttribute.getTextForLang(langCode); String errorCode = attributeFieldError.getErrorCode(); if (errorCode.equals(FieldError.INVALID_MIN_LENGTH)) { String[] args = {String.valueOf(text.length()), String.valueOf(valRules.getMinLength()), lang.getDescr()}; return action.getText("TextAttribute.fieldError.invalidMinLength", args); } else if (errorCode.equals(FieldError.INVALID_MAX_LENGTH)) { String[] args = {String.valueOf(text.length()), String.valueOf(valRules.getMaxLength()), lang.getDescr()}; return action.getText("TextAttribute.fieldError.invalidMaxLength", args); } else if (errorCode.equals(FieldError.INVALID_FORMAT)) { String[] args = {lang.getDescr()}; return action.getText("TextAttribute.fieldError.invalidInsertedText", args); } } return action.getText(this.getInvalidAttributeMessage()); }
@Override protected String getCustomAttributeErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) { AttributeInterface attribute = attributeFieldError.getAttribute(); TextAttributeValidationRules valRules = (TextAttributeValidationRules) attribute.getValidationRules(); if (null != valRules) { ITextAttribute textAttribute = (ITextAttribute) attribute; Lang lang = attributeFieldError.getTracer().getLang(); String langCode = (null != lang) ? lang.getCode() : null; String text = textAttribute.getTextForLang(langCode); String errorCode = attributeFieldError.getErrorCode(); if (errorCode.equals(FieldError.INVALID_MIN_LENGTH)) { String[] args = {String.valueOf(text.length()), String.valueOf(valRules.getMinLength()), lang.getDescr()}; return action.getText("TextAttribute.fieldError.invalidMinLength", args); } else if (errorCode.equals(FieldError.INVALID_MAX_LENGTH)) { String[] args = {String.valueOf(text.length()), String.valueOf(valRules.getMaxLength()), lang.getDescr()}; return action.getText("TextAttribute.fieldError.invalidMaxLength", args); } else if (errorCode.equals(FieldError.INVALID_FORMAT)) { String[] args = {lang.getDescr()}; return action.getText("TextAttribute.fieldError.invalidInsertedText", args); } } return action.getText(this.getInvalidAttributeMessage()); }
@Override public IAttributeValidationRules clone() { TextAttributeValidationRules clone = (TextAttributeValidationRules) super.clone(); clone.setMaxLength(this.getMaxLength()); clone.setMinLength(this.getMinLength()); clone.setRegexp(this.getRegexp()); return clone; }
@Override public IAttributeValidationRules clone() { TextAttributeValidationRules clone = (TextAttributeValidationRules) super.clone(); clone.setMaxLength(this.getMaxLength()); clone.setMinLength(this.getMinLength()); clone.setRegexp(this.getRegexp()); return clone; }
this.setMaxLength(textValRule.getMaxLength()); if (null != textValRule.getMinLength() && textValRule.getMinLength() > -1) { this.setMinLength(textValRule.getMinLength());
this.setMaxLength(textValRule.getMaxLength()); if (null != textValRule.getMinLength() && textValRule.getMinLength() > -1) { this.setMinLength(textValRule.getMinLength());
this.setMaxLength(textValRule.getMaxLength()); if (null != textValRule.getMinLength() && textValRule.getMinLength() > -1) { this.setMinLength(textValRule.getMinLength());
this.setMaxLength(textValRule.getMaxLength()); if (null != textValRule.getMinLength() && textValRule.getMinLength() > -1) { this.setMinLength(textValRule.getMinLength());