TextTag enhancement, nameprefix, nameproperty, doErrorsExist()
--------------------------------------------------------------
Key: STR-3155
URL: https://issues.apache.org/struts/browse/STR-3155
Project: Struts 1
Issue Type: Improvement
Components: Tag Libraries
Reporter: Mark Stricker
Priority: Minor
This issue depends on the following issue:
https://issues.apache.org/jira/browse/VALIDATOR-265
As I want to use the errorStyle attribute for the text tag I wrote my own
TextTag class and enhanced it with the two variables nameprefix and
nameproperty. If both exist i build the name with concatenating the two values,
otherwise i call the prepareName() method.
<pc:text errorStyle="..." errorKey="..." name="name" property="mobile"
nameprefix="sms_" nameproperty="email" />
protected String prepareNamePlusPrefix() throws JspException {
String res = null;
if (this.nameprefix == null || 0 == this.nameprefix.trim().length()) {
res = super.prepareName();
} else {
res = this.nameprefix.trim();
if (this.nameproperty != null) {
Object valueName = TagUtils.getInstance().lookup(pageContext, name,
this.nameproperty, null);
res += valueName.toString();
} else {
res += super.prepareName();
}
}
return res;
}
When validation fails and I add an Error with property "sms_email" this
property also has to be checked in the doErrosExist() method:
protected boolean doErrorsExist() throws JspException {
boolean errorsExist = false;
if ((getErrorStyleId() != null) || (getErrorStyle() != null) ||
(getErrorStyleClass() != null)) {
if (this.nameprefix == null || 0 == this.nameprefix.trim().length()) {
return super.doErrorsExist();
}
String actualName = prepareNamePlusPrefix();
if (actualName != null) {
ActionMessages errors =
TagUtils.getInstance().getActionMessages(pageContext,
GUIConstants.ERRORS_KEY + GUIConstants.PREV);
errorsExist = ((errors != null) && (errors.size(actualName) > 0));
}
}
return errorsExist;
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.