struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Winterfeldt <>
Subject Custom JSP Tags and Validator
Date Thu, 05 Jul 2001 03:37:07 GMT
I have couple of issues with the best way to handle
the possible incorporation of the validator custom JSP
tags into Struts.  I'll go through each of the issues.

I made two custom jsp tags for errors based off of the
Struts' tags.  One was validator:errors which is the
equivalent of html:errors except it iterates through
the errors instead of just printing them.  This is
necessary to remove the html formatting from the
message resources (for generating error messages in
JavaScript for example).  I also made a header and
footer attribute that are optional so you can specify
a header and footer as something optional instead of
automatically have 'errors.header' and 'errors.footer'
included in the output of the tag if they exist.  I
did some work on making the standard html:errors tag
iterate if an id attribute is used and otherwise work
the way it currently does, but if you have a lot of
jsp pages with html:errors they probably all use
'errors.header' and 'errors.footer' which you wouldn't
want to be printed in a case like Example 1.  I could
make it work like the validator:errors tag with an
optional header and footer attribute if the id
attribute was used so this wasn't an issue.  Anyway
I'm not sure if it is becoming a bit confusing making
so much dual functionality all in one tag and it makes
sense to keep it a separate tag that could go in
'org.apache.struts.taglib.validator'.  I'm leaning
towards adding a separate tag, but I wondered what
others thought.

Example 1 (possible modified Struts Tag):
<html:errors id="error">
   <li><bean:write name="error"/></li>

Example 2:
<validator:errors id="error" header="errors.header"
   <li><bean:write name="error"/></li>

Example 3:
   <bean:message key="errors.header"/>
      <validator:errors id="error">
         <li><bean:write name="error"/></li>

The validator:errorsExist was just a convenient
shorcut not to have to put the key for the errors into
the logic:present tag.  I'm thinking that even though
it seems nice to have, it doesn't belong in the main
Struts' project.

The tag that generates JavaScript is currently
separate from the from html:form.  I have a couple of
ideas.  One is to leave it totally separate like it
already is.  The other is to have a javascript="true"
added to html:form so there wouldn't be an extra tag. 
Another is that it should be placed inside the body of
html:form so it can automatically get the formname,
but leave it so it can be overridden.  

Basic use of tag matching it to the bean of the form
in scope.
<validator:javascript formName="typeForm"/>

This only generates the dynamic JavaScript for this
form so you can make a reference to the static
JavaScript on a separate page to take advantage of
browser caching.
<validator:javascript formName="typeForm"
dynamicJavascript="true" staticJavascript="false"/>

I hope I was clear (especially describing the issue
with the errors tag).  Let me know any thoughts or
other ideas on this.


Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail

View raw message