struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <tn...@bellsouth.net>
Subject Re: Re: Reference Struts HTML tags from within a custom tag? *Please help!*
Date Thu, 01 Jan 1970 00:00:00 GMT
John,

If you want to create your own tag and still leverage the existing BaseTag, HtmlTag or anyone
of the strut tags, you can create a reference to them by doing the following in you tag:

public class YourTag extends TagSupport {

    protected org.apache.struts.tag.ib.html.BaseTag baseTag = new org.apache.struts.tablib.html.BaseTag();
    
    protected org.apache.struts.tag.ib.html.HtmlTag htmlTag = new org.apache.struts.tablib.html.HtmlTag();


    public int doStartTag() throws JspException {
        //standard struts html tag
        htmlTag.doStartTag();

        //your code here

        baseTag.doStartTag();
        baseTag.doEndTag();

        //any additional code

        
        return (EVAL_PAGE);
    }

    public int doEndTag() throws JspException {
        //your code here
        htmlTag.doEndTag();
        
        return (EVAL_PAGE);
    }

    public void release() {
        // release any resources you allocate
        
        // release resources from standard struts tags
        htmlTag.release();
        baseTag.release();
    }

    // ....other methods

} // ---- End Class ----

Hope this helps.

Regards,
Todd G. Nist

> 
> From: "John Averty" <john_averty@hotmail.com>
> Date: 2002/09/11 Wed PM 07:59:47 EDT
> To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>, 
> 	<jmitchtx@telocity.com>
> Subject: Re: Reference Struts HTML tags from within a custom tag? *Please help!*
> 
> > Well, honestly, Struts has more to offer than you think.  Since you're new
> > to it, you should at least try reading Chuck Cavaness' chapters on the
> > serverside.com.
> 
> I did read that book. It explains how cool Struts is, but I felt that he
> didn't really explained me HOW do do stuff. Also, what I'm trying to get to
> is not in the book (at least not the chapters that are posted).
> Then, I've also gone thru the tutorial and a bunch of other docs and
> examples, and haven't found any hint on how to achieve the modularity I'm
> looking for.
> 
> I've been playing with Struts a bit, and I'm able to do pretty much anything
> "within the mold". ActionsForms, dynaForms, client and server validation,
> redirects, etc.
> 
> But, I'm still new and are just asking for some pointers of what could be an
> approach to acheive something more out of the box. I hope you gurus guys
> could give me another prospective, before I start digigng in the code (I'm
> on schedule...)
> 
> The closer I got to something was the concept of having an Actionform backed
> by a map, and then insert scriplets in the JSP, but I don't really like this
> approach as I prefer to insert code in the tags instead of the page itself.
> It is a lot more maintenable for programmers and for non-struts engineers
> (aka professional services), and a lot less prone to involuntary sabotage.
> I'm also worried about the performance of the code generated if I want my
> component to be pretty big/powerfull.
> 
> > Word of advice.  If you think "it would be nice if Struts does this".  It
> > has probably already been done or at least spec'd out.
> ... then let me know where or how!!
> 
> If I'm missing something obvious or if there is an approach on how to
> achieve what I'm trying to do, please point me to it instead of sending me a
> rtfm kind of answer.
> Or.. if you don't know or don't see a way, let me know also and I'll respect
> your judgement as you seem to be quite a guru with the stuff.
> 
> > And if not, do it and contribute it back to the community.
> No problem, if I have to build something, I'll contribute... But before, I
> need to figure out how...
> 
> 
> In the mean time, your answer was not helpful at all...
> 
> John.
> 
> 
> ----- Original Message -----
> From: "James Mitchell" <jmitchtx@telocity.com>
> To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
> Sent: Wednesday, September 11, 2002 4:35 PM
> Subject: RE: Reference Struts HTML tags from within a custom tag? *Please
> help!*
> 
> 
> > Well, honestly, Struts has more to offer than you think.  Since you're new
> > to it, you should at least try reading Chuck Cavaness' chapters on the
> > serverside.com.  It's free.  Be sure to setup a decent working environment
> > while you are reading it.  Go through each tutorial/sample and really dig
> > into the code and see what's happening.  Follow the threads from http
> > request through the container into the framework and out to the jsp.
> >
> > Word of advice.  If you think "it would be nice if Struts does this".  It
> > has probably already been done or at least spec'd out.  And if not, do it
> > and contribute it back to the community.
> >
> > Later John!
> >
> >
> > James Mitchell
> > Software Engineer\Struts Evangelist
> > Struts-Atlanta, the "Open Minded Developer Network"
> > http://www.open-tools.org/struts-atlanta
> >
> >
> >
> >
> > > -----Original Message-----
> > > From: John Averty [mailto:john_averty@hotmail.com]
> > > Sent: Wednesday, September 11, 2002 7:07 PM
> > > To: Struts Users Mailing List
> > > Subject: Re: Reference Struts HTML tags from within a custom tag?
> > > *Please help!*
> > >
> > >
> > > > Your best bet is to dig into the source code of the taglibs and see
> what
> > > > names the beans/strings/whatever are being stored under (and the
> proper
> > > > scope as well).  That way you can get a handle on anything you want.
> > >
> > > Even if I get a handle on the tags, what do I do with it to associate
> them
> > > with the ActionForm? Rendering/validation?
> > >
> > > Sorry if the question sounds dumb; I'm a new Struts user, and I
> > > didn't get a
> > > good handle yet.
> > > But I'm hoping to be able to be more dynamic than what the basic use of
> > > Struts allow: my compagny is building an application more than a portal
> > > (permissions, roles, etc.)). I'd like to build dynamic and
> > > configurable (as
> > > of by professional services) components to be able to modify/extend the
> > > fields forms without them needing an understanding of Struts.
> > >
> > > >> Check out the doco as well
> > > doco?
> > >
> > > Thanks,
> > >
> > > John.
> > >
> > >
> > > ----- Original Message -----
> > > From: "James Mitchell" <jmitchtx@telocity.com>
> > > To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>; "John
> > > Averty" <john_averty@hotmail.com>
> > > Sent: Wednesday, September 11, 2002 3:56 PM
> > > Subject: RE: Reference Struts HTML tags from within a custom tag?
> *Please
> > > help!*
> > >
> > >
> > > > Your best bet is to dig into the source code of the taglibs and see
> what
> > > > names the beans/strings/whatever are being stored under (and the
> proper
> > > > scope as well).  That way you can get a handle on anything you want.
> > > >
> > > > Check out the doco as well.  There's plenty info out there.
> > > >
> > > > HTH
> > > >
> > > > James Mitchell
> > > > Software Engineer\Struts Evangelist
> > > > Struts-Atlanta, the "Open Minded Developer Network"
> > > > http://www.open-tools.org/struts-atlanta
> > > >
> > > >
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: John Averty [mailto:john_averty@hotmail.com]
> > > > > Sent: Wednesday, September 11, 2002 5:30 PM
> > > > > To: Struts Users Mailing List
> > > > > Subject: Reference Struts HTML tags from within a custom tag?
> *Please
> > > > > help!*
> > > > >
> > > > >
> > > > > Hi,
> > > > >
> > > > > I'm trying to build a custom tag that would render a (dynamicly
> > > generated)
> > > > > list of fields.
> > > > >
> > > > > Is there a way for me to:
> > > > > - get a reference to Strut's HTML tags from within a custom tag?
> > > (assuming
> > > > > we know which tag to get)
> > > > > - have the html tag handle the rendering?
> > > > > - still be able to use Strut's validation?
> > > > >
> > > > > Any ideas out there on how to do that? Any help would be
> appreciated.
> > > > >
> > > > > John.
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail:
> > > > > <mailto:struts-user-unsubscribe@jakarta.apache.org>
> > > > > For additional commands, e-mail:
> > > > <mailto:struts-user-help@jakarta.apache.org>
> > > >
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > <mailto:struts-user-unsubscribe@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > <mailto:struts-user-help@jakarta.apache.org>
> > > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <mailto:struts-user-unsubscribe@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <mailto:struts-user-help@jakarta.apache.org>
> > >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> <mailto:struts-user-help@jakarta.apache.org>
> >
> 
> --
> To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>
> 
> 


--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message