Date: 2005-03-08T11:02:26
Editor: ReinhardPoetz
Wiki: Cocoon Wiki
Page: WhiteBoardCocoonForms
URL: http://wiki.apache.org/cocoon/WhiteBoardCocoonForms
no comment
Change Log:
------------------------------------------------------------------------------
@@ -22,10 +22,10 @@
All aspects of these features (syntax, implementation, etc.)
are subject to discussion and change.
-== Macro library support ==
+== Macro library and field extensions support ==
*Define - Creates a reusable macro definition.
*Expand - Creates an instance of a macro definition.
- *Macros - Defines a reusable macro library.
+ *Library - Defines a reusable macro library.
*Import - Brings a macro library into scope.
The syntax and examples below are written assuming use of
@@ -33,7 +33,7 @@
also present for the form binding and the form template,
using the respective name spaces.
-=== Define ===
+=== Define a macro ===
Creates a reusable macro definition.
{{{
Syntax:
@@ -80,22 +80,23 @@
}}}
=== Macros ===
-Defines a reusable macro library.
+Defines a reusable library.
{{{
Syntax:
- <fd:macros>
+ <fd:library>
<!-- Macro definitions -->
- </fd:macros>
+ <!-- Reusable field definitions -->
+ </fd:library>
Note:
- The "fd:macros" element must be the root of the document.
+ The "fd:library" element must be the root of the document and contains
macros and fields.
Example:
- <fd:macros>
+ <fd:library>
<fd:macro define="product">
<fd:field id="name">
<fd:label>Name</fd:label>
@@ -106,11 +107,29 @@
<fd:datatype base="decimal"/>
</fd:field>
</fd:macro>
- </fd:macros>
+
+ <fd:field id="email">
+ <fd:label>email</fd:label>
+ <fd:datatype base="string"/>
+ <fd:validation>
+ <fd:email/>
+ </fd:validation>
+ </fd:field>
+
+ <fd:field id="customer-number">
+ <fd:label>customer number</fd:label>
+ <fd:datatype base="string"/>
+ <fd:validation>
+ <fd:length exact="16"/>
+ </fd:validation>
+ </fd:field>
+
+
+ </fd:library>
}}}
-=== Import ===
-Brings a macro library into scope.
+=== Import (using the library's elements) ===
+Bring library elements into scope.
{{{
Syntax:
@@ -118,8 +137,15 @@
Example:
- <fd:import prefix="my-macros" uri="cocoon:/custom-fd-macros.xml"/>
- <fd:macro expand="my-macros:product"/>
+ <fd:import prefix="my-library" uri="cocoon:/custom-fd-library.xml"/>
+ <fd:macro expand="my-library:product"/>
+ <fd:field id="customer-email" extends="my-library:email">
+ <fd:label>customer's email</fd:label>
+ <fd:validation>
+ <fd:length exact="30"/>
+ </fd:validation>
+ </fd:field>
+ <fd:field id="cust" extends="my-library:customer-number"/>
Effective result:
@@ -131,6 +157,23 @@
<fd:label>Price</fd:label>
<fd:datatype base="decimal"/>
</fd:field>
+
+ <fd:field id="customer-email">
+ <fd:label>customer's email</fd:label>
+ <fd:validation>
+ <fd:length exact="30"/>
+ <fd:email/>
+ </fd:validation>
+ </fd:field>
+
+ <fd:field id="cust">
+ <fd:label>customer number</fd:label>
+ <fd:datatype base="string"/>
+ <fd:validation>
+ <fd:length exact="16"/>
+ </fd:validation>
+ </fd:field>
+
}}}
The "prefix" is a user-defined string used when expanding
@@ -139,6 +182,8 @@
The "uri" identifies the source for the macro library.
Any protocol understood by Cocoon may be used.
+
+Note that single fields don't need to be defined within an {{{fd:macro}}}
element. This (global) definitions can be reused in the custom form definition
using the {{{extends}}} attribut.
=== Additional Notes ===