commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Anderson" <t...@intalio.com>
Subject [jelly][PATCH] New tags: extend and super
Date Sun, 27 Oct 2002 03:08:56 GMT
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

Mime
View raw message