cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim O'Leary <TOle...@civica.com.au>
Subject Re: Cforms, Binding & Cross-Referenced data
Date Thu, 29 Jul 2004 00:01:29 GMT
Original message from Timur Izhbulatov
Ben Pope писал(а): 

Try the following approach. 

In sitemap you use xinclude transformer. Each room element contains
<xi:include href="#xpointer(some_XPath)"/> elements.
  <rooms>
     <room id="0">
        <name>Lounge</name>
        <xi:include
          href="#xpointer(/project/people/person[2])"/>
        <xi:include
          href="#xpointer(/project/people/person[3])"/>
     </room>
     <room id="1">
         <name>Kitchen</name>
        <xi:include
          href="#xpointer(/project/people/person[1])"/>
     </room>
  </rooms> 

Form and binding may be like this (I don't if it works):
<fd:form
xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
<fd:repeater id="people">
    <fd:widgets>
      <fd:output id="id">
        <fd:datatype base="long"/>
      </fd:output>
      <fd:output id="href">
        <fd:datatype base="string"/>
      </fd:output>
      <fd:booleanfield id="select">
        <fd:label>Select</fd:label>
      </fd:booleanfield>
    </fd:widgets>
  </fd:repeater> 

  <fd:repeater-action id="addperson" action-command="add-row"
repeater="contacts">
    <fd:label>Add</fd:label>
  </fd:repeater-action> 

  <fd:repeater-action id="removeperson" action-command="delete-rows"
repeater="contacts" select="select">
    <fd:label>Remove</fd:label>
  </fd:repeater-action>
</fd:widgets>
</fd:form> 

<fb:context
          xmlns:fb="http://apache.org/cocoon/forms/1.0#binding"
          xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
          xmlns:xi="http://www.w3.org/2001/XInclude"
          path="/project/rooms/room[1]" > <fb:repeater id="people"
             parent-path="people"
             row-path="xi:include"> 

  <fb:identity>
    <fb:value id="id" path="@id">
      <fd:convertor datatype="long" />
    </fb:value>
  </fb:identity> 

  <fb:on-bind>
      <fb:value id="href" path="@href" />
  </fb:on-bind> 

  <fb:on-delete-row>
    <fb:delete-node />
  </fb:on-delete-row> 

  <fb:on-insert-row>
    <fb:insert-node>
      <xi:xinclude id="" href=""/>
      </contact>
    </fb:insert-node>
  </fb:on-insert-row>
</fb:repeater> 

</fb:context> 

> Hi,
> 
> I don't seem to be able to get my head around binding cross-referenced 
> data
> - the example below will be clearer than I can explain it in words:  
> 
> Say I want to store some information about who is in what room, I 
> might have a data file that looks like this:
> 
> <project>
>    <people>
>       <person id="0">
>          <name>Me</name>
>          <mentalAge>9</mentalAge>
>       </person>
>       <person id="1">
>          <name>You</name>
>       </person>
>       <person id="2">
>          <name>Him</name>
>       </person>
>    </people>
>    <rooms>
>       <room id="0">
>          <name>Lounge</name>
>          <person idref="0"/>
>          <person idref="1"/>
>       </room>
>       <room id="1">
>           <name>Kitchen</name>
>           <person idref="2"/>
>       </room>
>    </rooms>
> </project>
> 
> 
> Now each room has a person reference that references the person id.  
> So "You" and "Me" are in the Lounge and "Him" is in the Kitchen 
> (hopefully making some food 'cos this is making me hungry!).
> 
> I'd like to do this:  
> 
> http://localhost/cocoon/rooms/room?room=0
> 
> And be able to get back a form with a repeater over all the people in 
> that room.
> 
> The definition for said form might look like this:  
> 
> <?xml version="1.0"?>
> <fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
>    <fd:widgets>
>       <fd:field id="roomName" required="true"/>
>       <fd:repeater id="people">
>          <fd:widgets>
>             <fd:field id="personName" required="true"/>
>             <fd:booleanfield id="select"/>
>          </fd:widgets>
>       </fd:repeater>
>       <fd:repeater-action id="addPerson" repeater="people"
> action-command="add-row"/>
>       <fd:repeater-action id="removePeople" repeater="people"
> action-command="delete-rows" select="select"/>
>    </fd:widgets>
> </fd:form>
> 
> So I would like to be able to add and remove people from a particular 
> room - it's safe to assume that the person already exists, so I 
> wouldn't be adding a people/person at any time, only a room/person.  
> But I would like to be able to manipulate their name.
> 
> I can't establish what the binding file would look like given the 
> above data file with the cross-referencing.
> 
> Should I be running an XSLT over the data so that for room 0 I end up
with:
> <room id="0">
>    <name>Lounge</name>
>    <person id="0">
>       <name>Me</name>
>    </person>
>    <person id="1">
>       <name>You</name>
>    </person>
> </room>
> 
> Which would be much easier (with my mind, at least) to create a 
> binding file for.
> 
> If so... How do I fit that back into the old data file, retaining the 
> room/person idrefs and updating the people/person elements?
> 
> Or can it be done "in place"?  
> 
> This is all a new paradigm of thinking for me, I clearly haven't had 
> that click moment, if I keep plugging at it and seeing the solutions 
> to my problems it will click, I know it.
> 
> Any help is much appreciated.  
> 
> Ben
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
 


Timur

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

--------------------------------------------------------------------- 
This email is from Civica Pty Limited and it, together with any attachments,
is confidential to the intended recipient(s) and the contents may be legally
privileged or contain proprietary and private information. It is intended
solely for the person to whom it is addressed. If you are not an intended
recipient, you may not review, copy or distribute this email. If received in
error, please notify the sender and delete the message from your system
immediately. 
Any views or opinions expressed in this email and any files transmitted with
it are those of the author only and may not necessarily reflect the views of
Civica and do not create any legally binding rights or obligations
whatsoever. Unless otherwise pre-agreed by exchange of hard copy documents
signed by duly authorised representatives, contracts may not be concluded on
behalf of Civica by email. 
Please note that neither Civica nor the sender accepts any responsibility
for any viruses and it is your responsibility to scan the email and the
attachments (if any). All email received and sent by Civica may be monitored
to protect the business interests of Civica. 
--------------------------------------------------------------------- 


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


Mime
View raw message