cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Fagerstrom <>
Subject Re: Whiteboard Forms - Reusable form definitions (imports)
Date Tue, 08 Mar 2005 10:09:08 GMT
Reinhard Poetz wrote:

> I was looking at 
> 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):


>    <!-- 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>

The main problem here IMO is that view and model concerns are mixed up. 
If we factor out the convertion part to an own step as discussed in and 
the rest of that thread, there is not that much left to reuse.

> 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> 

Ok, here we see that it was the view aspect, (i.e. the label) of the 
date widget that wasn't reusable. That is quite common in my experience 
and one of the reasons why it is a good idea to separate model and view 
as models tend to be much more reusable than views.

So instead we could have a date model definition:

   <fd:field name="date">
      <fd:datatype base="date"/>

The date conversion pattern "dd/MM/yyyy" is put in a catalog with  
interanationalized date, number etc patterns that are used for all data 
type formating purposes in Cocoon, and you probably don't have to write 
anything at all as we can have standard conversion patterns in the distro.

Then in the template you write:

  <ft:widget name="date">
By placing labels, hints etc in the template (view) instead of in the 
widget definition you get rid of the view info from the "model" and by 
improving SoC it becomes easier for people that are web designers rather 
than programmers to work with on the view aspect of the application.

                                 --- o0o ---

I still think that "macros" can be usable for reusable "model 
definitions" but IMO the problem that you describe is a symptom of 
model/view mixup in widget definitions, and we should start to do 
something about that.


View raw message