On Fri, 14 Mar 2003, Renato Romano wrote:
> Date: Fri, 14 Mar 2003 16:26:49 +0100 > From: Renato Romano <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] > To: 'Noureddine Bekrar' <[EMAIL PROTECTED]>, > 'Struts Users Mailing List' <[EMAIL PROTECTED]> > Subject: RE: Tag Extension > > I was looking at that possibility, but, if doing so, my own tag should > redefine all setter property for the original tags: the html:select tag, > for example has a style attribute; If I use it as a private object > inside mine, I have to redefine the getStyle and setStyle methods; this > of course is still valid for all other attributes. > A large number of the standard Struts tag implementations follow the "extend via subclass" approach. For example, many of the HTML tags have a common set of attributes for all the CSS and JavaScript features, and the tag attribute properties for these are defined in a common base class (org.apache.struts.taglib.html.BaseHandlerClass). > It is maybe better to extend one of the tags i want to use, and then add > code, as suggested by Nicolas... > What I don't like in this solution is I don't really reuse code (In the > Nicolas example, code from SelectTag is reused, but for writing a Submit > button I have to copy, or write my own code ...) > When subclassing tag classes, I have found it most convenient to completely re-implement the doStartTag() and doEndTag() methods. The value of the subclass is not having to redo the property getter/setter methods, or the utility methods that are usually in protected scope. Some of the Struts tag implementations split out important stuff into such utility methods (for example, LinkTag splits out the creation of the actual URL into a calculateURL() method), but the factoring could be improved in future versions of the implementations. Craig --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

