cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reinhard Poetz <reinh...@apache.org>
Subject Whiteboard Forms - Reusable form definitions (imports)
Date Tue, 08 Mar 2005 08:01:59 GMT
I was looking at http://wiki.apache.org/cocoon/WhiteBoardCocoonForms and I liked 
what I saw.

This document defines reusable macro libraries. I'm sure this is useful for some 
usecases (e.g. editors) but I have a simpler one that goes into the direction of 
reusable form definitions.
In many of my forms date widgets are used: birthdate, start date, end date, ... 
Definining those widgets is nearly always the same, except the label. IMO it 
would make sense not only to have reusable macro libraries but also reusable 
widget libraries (renamed fd:macros to fd:library):

<fd:library>

   <!-- reusable macros -->
   <fd:macro define="product">
     <fd:field id="name">
       <fd:label>Name</fd:label>
       <fd:datatype base="string"/>
     </fd:field>
     <fd:field id="price">
       <fd:label>Price</fd:label>
       <fd:datatype base="decimal"/>
     </fd:field>
     </fd:macro>

    <!-- reusable widgets -->
    <fd:field name="project-date">
       <fd:datatype base="date">
         <fd:convertor>
           <fd:patterns>
             <fd:pattern>dd/MM/yyyy</fd:pattern>
           </fd:patterns>
         </fd:convertor>
       </fd:datatype>
    </fd:field>

</fd:library>


Syntax:

   <fd:import prefix="..." uri="..."/>

Example:

   <fd:import prefix="my-macros" uri="cocoon:/custom-fd-macros.xml"/>
   <fd:field name="birthdate" extends="my-macros:project-date">
     <fd:label>birthdate</fd:label>
   </fd:field>

Effective result:

    <fd:field name="project-date">
      <fd:label>birthdate</fd:label>
      <fd:datatype base="date">
        <fd:convertor>
          <fd:patterns>
            <fd:pattern>dd/MM/yyyy</fd:pattern>
          </fd:patterns>
        </fd:convertor>
      </fd:datatype>
    </fd:field>

WDYT?

-- 
Reinhard Pötz           Independant Consultant, Trainer & (IT)-Coach 

{Software Engineering, Open Source, Web Applications, Apache Cocoon}

                                        web(log): http://www.poetz.cc
--------------------------------------------------------------------

Mime
View raw message