cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <joerg.heini...@gmx.de>
Subject Re: CForms Binding to XML file sample
Date Sat, 03 Jul 2004 12:41:30 GMT
On 03.07.2004 10:48, Colin Paul Adams wrote:

>     Joerg> I would not see the behaviour of the binding as a problem,
>     Joerg> only the result of having not unique ids. I think that was
>     Joerg> let out with intent. It's up to you to do it either after
>     Joerg> form processing or in the binding itself. There is a
>     Joerg> fb:javascript where you can code id generation for
>     Joerg> example.
> 
> How?
> In:
> 
>     <fb:on-insert-row>
>       <!-- The insert-node element contains a piece of template XML to be
>       inserted for new rows. Alternatively, you could also add a "src"
>       attribute on the insert-node element pointing to an external source
>       to retrieve the template from. -->
>       <fb:insert-node>
>         <!-- template inserted by the binding for new rows (mapping new nodes) -->
>         <event xmlns="http://colina.demon.co.uk/onevoice/events" id="" date="" time=""
finish-at="" suppress-recurring="">
>           <title/><location/>
>         </event>
>       </fb:insert-node>
>     </fb:on-insert-row>
> 
> I can't code an fb:javascript element as the value of the id
> attribute.
> So where does it fit in?

IIRC you can add a <fb:on-bind> on the same level as <fb:on-insert> 
where you add the logic for id generation via <fb:javascript>. This 
means <fb:on-insert-row> only adds the nodes, while <fb:on-bind> sets 
the values. form2_bind_xml.xml seems to prove my recall:

   <fb:repeater id="contacts">
     <fb:on-bind>
       <!-- executed on updates AND right after the insert -->
 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>^^^^^^^^^^^^^^^^^^^^^^^^^^
       <fb:value id="phone"     path="phone/@nr" />
 >>> mapping for phone/@nr ^^^^^^^^^^^^^^^^^^^^
     </fb:on-bind>

     <fb:on-insert-row>
       <fb:insert-node>
         <contact id="" row-state="new">
           <firstname/><lastname/><phone nr=""/><email/>
 >>> empty phone/@nr >>>>>>>>>>>>>^^^^^^^^^^^^^^
         </contact>
       </fb:insert-node>
     </fb:on-insert-row>
   </fb:repeater>

Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message