Custom tags - When does a parent tag know about its child tags?

Discussion in 'Java' started by johkar, Mar 11, 2007.

  1. johkar

    johkar Guest

    Bear with me because I am new at this. Is there a way for the
    beginning <layout:apppage> tag to know what all of its child tags are
    before the child tags are invoked? The leftnav and rightnav tags are
    optional and I need to output HTML differently in the beginning
    apppage tag based on what is present.

    <layout:apppage>
    <layout:leftnav> <!-- code here --> </layout:leftnav>
    <layout:rightnav> <!-- code here --> </layout:rightnav>

    <!-- my app code -->

    </layout:apppage>

    Also, both leftnav and rightnav have child tags of their own, I am
    having trouble figuring out how to save all the HTML they generate and
    output it with the ending apppage tag.

    Thanks
     
    johkar, Mar 11, 2007
    #1
    1. Advertising

  2. johkar

    Dan Andrews Guest

    On Mar 11, 3:47 pm, "johkar" <> wrote:
    > Bear with me because I am new at this. Is there a way for the
    > beginning <layout:apppage> tag to know what all of its child tags are
    > before the child tags are invoked? The leftnav and rightnav tags are
    > optional and I need to output HTML differently in the beginning
    > apppage tag based on what is present.
    >
    > <layout:apppage>
    > <layout:leftnav> <!-- code here --> </layout:leftnav>
    > <layout:rightnav> <!-- code here --> </layout:rightnav>
    >
    > <!-- my app code -->
    >
    > </layout:apppage>
    >
    > Also, both leftnav and rightnav have child tags of their own, I am
    > having trouble figuring out how to save all the HTML they generate and
    > output it with the ending apppage tag.
    >
    > Thanks



    Have a look at the article that Jeff Wilson wrote titled "Take control
    of your JSP pages with custom tags." There is also a good code sample
    there that you can download. Here is the link:
    http://www-128.ibm.com/developerworks/java/library/j-taglib/

    Cheers,

    Dan Andrews
    -------------------
    http://www.ansir.ca
     
    Dan Andrews, Mar 11, 2007
    #2
    1. Advertising

  3. johkar

    Tom Hawtin Guest

    johkar wrote:
    > Bear with me because I am new at this. Is there a way for the
    > beginning <layout:apppage> tag to know what all of its child tags are
    > before the child tags are invoked? The leftnav and rightnav tags are
    > optional and I need to output HTML differently in the beginning
    > apppage tag based on what is present.


    The simple answer is no.

    The possibly more useful answer is that you can evaluate the body, but
    defer from passing on the output. If you buffer the output. then you can
    change the header depending upon how the execution went within the body.

    I've not done this sort of thing for five or six years, so can't
    remember the details of the APIs. Example code is left as an exercise
    for the reader.

    Tom Hawtin
     
    Tom Hawtin, Mar 11, 2007
    #3
  4. johkar

    johkar Guest

    > Have a look at the article that Jeff Wilson wrote titled "Take control
    > of your JSP pages with custom tags." There is also a good code sample
    > there that you can download. Here is the link:http://www-128.ibm.com/developerworks/java/library/j-taglib/
    >
    > Cheers,
    >
    > Dan Andrews



    Thank you, very helpful.
     
    johkar, Mar 13, 2007
    #4
  5. johkar

    johkar Guest

    On Mar 11, 6:11 pm, Tom Hawtin <> wrote:
    > johkarwrote:
    > > Bear with me because I am new at this. Is there a way for the
    > > beginning <layout:apppage> tag to know what all of its child tags are
    > > before the child tags are invoked? The leftnav and rightnav tags are
    > > optional and I need to output HTML differently in the beginning
    > > apppage tag based on what is present.

    >
    > The simple answer is no.
    >
    > The possibly more useful answer is that you can evaluate the body, but
    > defer from passing on the output. If you buffer the output. then you can
    > change the header depending upon how the execution went within the body.
    >
    > I've not done this sort of thing for five or six years, so can't
    > remember the details of the APIs. Example code is left as an exercise
    > for the reader.
    >
    > Tom Hawtin


    Thank you.
     
    johkar, Mar 13, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rp
    Replies:
    4
    Views:
    545
    John C. Bollinger
    Nov 24, 2003
  2. shruds
    Replies:
    1
    Views:
    933
    John C. Bollinger
    Jan 27, 2006
  3. Noel Dolan
    Replies:
    0
    Views:
    274
    Noel Dolan
    Jul 18, 2004
  4. Replies:
    0
    Views:
    164
  5. Bitswapper
    Replies:
    5
    Views:
    182
    Prasad, Ramit
    Aug 27, 2013
Loading...

Share This Page