You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by lt...@pfs.com on 2002/01/03 16:15:31 UTC

Custom tag performance

For a workflow system, I've created a custom tag (extending the struts
BaseInputTag) that combines the functionality of the following struts tags

<html:text>
<bean:message>
<messages:present>

The custom tag has a property attribute and a key attribute (for the field
label), and I modified the base tag readonly attribute so that it outputs
the value in a span element if readonly is true, and an input element if
readonly is false. 

The tag looks like this:

 <ims:tradefield readonly="true" width="85"
key="trade.securityinfo.instrumenttype" property="instrumenttype"/>

and produces output like this:

<tr><td class="label" align="right">Instrument Type</td><td><span
class="val" style="width:85;">EQUITY</span></td></tr>


In addition, the tag checks the ActionMessages collection to see if there is
a message relating to this field, and if there is, it outputs the label in
red.

The tag works great; the problem is that my form has about 60 fields on it,
and it's a bit slow.

It seems like the custom tag approach produces a *lot* or repeated code. For
instance, it looks like the ActionMessages collection is created anew for
each tag. Ditto with the Action.MESSAGES_KEY bundle. Is there any way to
create these things once at the top of the .jsp page, then just call them
from the custom tag? 

Any other performance enhancing suggestions?