I've defined a message in my resource bundle like this:
required.icon=<span class="required">*</span>

and I output it like this <fmt:message key="required.icon/> next
to my field names.

Alternatively, you could use standard <label> elements and apply a style to them so they show up in red or bold (i.e. <label for="username" class="required">).

Both these approaches don't require tag subclasses.

David






From: "Hohlen, John" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: "Struts-User (E-mail)" <[EMAIL PROTECTED]>
Subject: JSTL or Struts Tags: Required Field Indication
Date: Mon, 25 Nov 2002 14:19:01 -0600

My team extended the Struts <bean:message> custom tag to accept an
additional attribute called "required". If this optional attribute is set
to true, then a red asterisk is appended to the text corresponding to the
key. For example, the following tag:

<abc:beanMessage key="login.userId" required="true"/>

would produce the following:

User ID*

Obviously, placing the code to generate the required field marker in the tag
creates a single isolation point for future changes. For example, if it
desired to make the asterisk blue instead of red, or to place the asterisk
at the beginning of the label instead of the end. Otherwise, if this wasn't
part of the tag, then every JSP with a required field would have to be
changed. More specifically, JSPs would contain the following:

<bean:message key="login.userId"/><font color="red">*</font>

Are others extending the Struts tags to generate the required field marker?
My team is also interested in using JSTL and the "Struts-EL" subproject. Is
there an existing tag in either of these libraries that could be used?
Unlike the Struts tags, the JSTL tags can't really be extended since you
don't have access to the JSTL implementation (source), correct? I realize I
could extend the JSTL tags provided via the Jakarta implementation (since
the source is available), but my extensions most likely wouldn't work once I
started using my container's implementation, correct?

Thanks,

JOHN


--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail


--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to