I'm using Spring 2.0.x. I can't upgrade to 2.5.x on this project.
I'm using validators, and create an error as follows:
In message.properties:Code:String args[] = { "a.second.message.properties.key" }; errors.rejectValue("field", "message.properties.key", args, "default error message.");
I want the error displayed to be "This works really well.", but instead, get "a.second.message.properties.key works really well." I've decided to make a relatively dirty hack around this; put delimiters around that second message properties key, wrap the ErrorsTag, and do the substitution myself.Code:message.properties.key={0} works really well. a.second.message.properties.key=This
Problem is that Spring 2.0 ErrorsTag extends TagSupport; Spring 2.5 ErrorsTag extends BodyTagSupport, which would make this *much* easier. I tried various things, and finally gave up on wrapping BodyTagSupport around ErrorsTag in Java. What I've come to is this:
except that this method doesn't seem to get called.Code:public class HcaErrorsTag extends ErrorsTag { private static final long serialVersionUID = 3L; public HcaErrorsTag() { setCssClass("errors"); setPath("*"); } protected void renderDefaultContent(TagWriter tagWriter) throws JspException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStreamWriter osw = new OutputStreamWriter(baos); TagWriter tempTagWriter = new TagWriter(osw); super.renderDefaultContent(tempTagWriter); try { String contentString = baos.toString(); if (contentString != null) { pageContext.getOut().write(contentString); } } catch (IOException ioe) { throw new JspException(ioe); } } }
What additional debugging steps should I take? Did I go wrong somewhere obvious? Can I go back away from this dirty hack and do the same thing in a much more straightforward manner?


Reply With Quote
