/** * Determine if there are errors for the component. * @return Whether errors exist. */ protected boolean doErrorsExist() throws JspException { boolean errorsExist = false; if (getErrorStyleId() != null || getErrorStyle() != null || getErrorStyleClass() != null) { String actualName = prepareName(); if (actualName != null) { ActionMessages errors = TagUtils.getInstance() .getActionMessages(pageContext, errorKey); errorsExist = (errors != null && errors.size(actualName) > 0); } } return errorsExist; }
/** * Prepares the style attributes for inclusion in the component's HTML tag. * @return The prepared String for inclusion in the HTML tag. * @exception JspException if invalid attributes are specified */ protected String prepareStyles() throws JspException { StringBuffer styles = new StringBuffer(); boolean errorsExist = doErrorsExist(); if (errorsExist && getErrorStyleId() != null) { prepareAttribute(styles , "id", getErrorStyleId()); } else { prepareAttribute(styles , "id", getStyleId()); } if (errorsExist && getErrorStyle() != null) { prepareAttribute(styles , "style", getErrorStyle()); } else { prepareAttribute(styles , "style", getStyle()); } if (errorsExist && getErrorStyleClass() != null) { prepareAttribute(styles , "class", getErrorStyleClass()); } else { prepareAttribute(styles , "class", getStyleClass()); } prepareAttribute(styles , "title", message(getTitle(), getTitleKey())); prepareAttribute(styles , "alt", message(getAlt(), getAltKey())); return styles.toString(); }