You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Tim Anderson <ti...@intalio.com> on 2002/10/27 04:08:56 UTC

[jelly][PATCH] New tags: extend and super

Hi,
	attached is support for two new tags, <define:extend>
and <define:super>.
The <define:extend> tag allows an inherited dynamic tag to be extended.
The <define:super> tag may be used within a <define:extend> to invoke
the parent tag implementation.

Eg:

// coretags.jelly
...
  <define:taglib uri="jakarta.apache.org/commons/sql/tags">

    ...
    <define:tag name="create-table">
      CREATE TABLE ${table.name} (
        <column-list/>
      <embedded-primary-key />
      <embedded-foreign-keys />
      )
      <eos-spec/>
    </define:tag>
    ....
  <define:taglib>
...

// oracletags.jelly
...
  <j:include uri="coretags.jelly"/>

  <!-- extend the core tag library -->
  <define:taglib uri="jakarta.apache.org/commons/sql/tags" inherit="true">

    <!-- extend the coretag implementation of create-table -->
    <!-- to handle  auto increment columns for oracle      -->
    <define:extend name="create-table">
      <j:choose>
        <j:when test="${table.autoIncrementColumn != null}">
          <create-sequence />
          <define:super/>  <!-- invoke coretags implementation of
create-table -->
          <create-sequence-trigger column="${table.autoIncrementColumn}"/>
        </j:when>
        <j:otherwise>
          <define:super/>
        </j:otherwise>
      </j:choose>
    </define:extend>
   ...


Notes
-----
. <define:extend> replaces the parent taglibs implementation
  of the named tag with its own.
  There may be instances where this is not the desired behaviour?

. <define:extend> can only be used to extend <define:tag> tags
  A possible enhancement would be to allow it to extend
  other non-script based tags

. the ExtendTag behaviour could be rolled into TagTag.
  I've created a separate class to make it explicit that a tag
  is being extended.
  At the moment, using a <define:tag> specifying the same name
  as a parent taglibs <define:tag> generally yields behaviour
  which is probably not the expected one.

Regards,

Tim

Re: [jelly][PATCH] New tags: extend and super

Posted by James Strachan <ja...@yahoo.co.uk>.
From: "Tim Anderson" <ti...@intalio.com>
> Hi,
> attached is support for two new tags, <define:extend>
> and <define:super>.
> The <define:extend> tag allows an inherited dynamic tag to be extended.
> The <define:super> tag may be used within a <define:extend> to invoke
> the parent tag implementation.

Cool stuff! Patch applied, many thanks Tim.

This is kinda cool - it allows the template style and OO styles of scripting
to be merged together in a simple way. Wacky but cool :-)

James
-------
http://radio.weblogs.com/0112098/

>
> Eg:
>
> // coretags.jelly
> ...
>   <define:taglib uri="jakarta.apache.org/commons/sql/tags">
>
>     ...
>     <define:tag name="create-table">
>       CREATE TABLE ${table.name} (
>         <column-list/>
>       <embedded-primary-key />
>       <embedded-foreign-keys />
>       )
>       <eos-spec/>
>     </define:tag>
>     ....
>   <define:taglib>
> ...
>
> // oracletags.jelly
> ...
>   <j:include uri="coretags.jelly"/>
>
>   <!-- extend the core tag library -->
>   <define:taglib uri="jakarta.apache.org/commons/sql/tags" inherit="true">
>
>     <!-- extend the coretag implementation of create-table -->
>     <!-- to handle  auto increment columns for oracle      -->
>     <define:extend name="create-table">
>       <j:choose>
>         <j:when test="${table.autoIncrementColumn != null}">
>           <create-sequence />
>           <define:super/>  <!-- invoke coretags implementation of
> create-table -->
>           <create-sequence-trigger column="${table.autoIncrementColumn}"/>
>         </j:when>
>         <j:otherwise>
>           <define:super/>
>         </j:otherwise>
>       </j:choose>
>     </define:extend>
>    ...
>
>
> Notes
> -----
> . <define:extend> replaces the parent taglibs implementation
>   of the named tag with its own.
>   There may be instances where this is not the desired behaviour?
>
> . <define:extend> can only be used to extend <define:tag> tags
>   A possible enhancement would be to allow it to extend
>   other non-script based tags
>
> . the ExtendTag behaviour could be rolled into TagTag.
>   I've created a separate class to make it explicit that a tag
>   is being extended.
>   At the moment, using a <define:tag> specifying the same name
>   as a parent taglibs <define:tag> generally yields behaviour
>   which is probably not the expected one.
>
> Regards,
>
> Tim
>


----------------------------------------------------------------------------
----


> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>