You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by br...@apache.org on 2003/07/23 17:18:22 UTC

cvs commit: cocoon-2.1/src/blocks/woody/samples/forms form2_bind_bean.xml form2_bind_xml.xml form2_jx.xml

bruno       2003/07/23 08:18:22

  Added:       src/blocks/woody/samples/forms form2_bind_bean.xml
                        form2_bind_xml.xml form2_jx.xml
  Log:
  initial commit
  
  Revision  Changes    Path
  1.1                  cocoon-2.1/src/blocks/woody/samples/forms/form2_bind_bean.xml
  
  Index: form2_bind_bean.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- Example to bind form2 form to Form2Bean -->
  <wb:context 
    xmlns:wb="http://apache.org/cocoon/woody/binding/1.0" 
    path="/" >
  
    	<!-- the email value will not be saved because of the @readonly -->
      <wb:field id="email"   path="email"         readonly="true"/>
  		<!-- jxpath binds to nodes as well as to attributes -->
      <!--
      <wb:field id="account" path="account/@size" />
      <wb:field id="number1" path="number"        />
      -->
  
  	  <!-- one entry field in the client maps through aggregate fields -->
      <wb:aggregate id="phone" path="." >
      	<!-- to multiple fields in the XML file -->
        <wb:field id="number" path="phoneNumber"/>
        <wb:field id="zone"   path="phoneZone"/>
        <wb:field id="cntr"   path="phoneCountry"/>
      </wb:aggregate>
      
    
      <wb:field id="ipaddress" path="ipAddress"/>
  
  
    <!-- repeater requires unique identification mechanism of the row-nodes -->
    <wb:repeater id="contacts"
      parent-path="."
      row-path="contacts"
      unique-row-id="id"
      unique-path="@id"
      >
      <!-- important note: the row-path is used inside jxpath-createPath context,
           as a consequence it cannot have dependent children or predicates -->
  
      <wb:on-bind>
      	<!-- executed on updates AND right after the insert -->
        <wb:field id="firstname" path="firstName" />
        <wb:field id="lastname"  path="lastName"  />
        <wb:field id="phone"     path="phone" />
        <wb:field id="email"     path="email"     />
      </wb:on-bind>
  
      <wb:on-delete-row>
      	<!-- chose on of these to test -->
      	<!--
        <wb:set-attribute name="row-state" value="deleted" />
        -->
        <wb:delete-node />
      </wb:on-delete-row>
  
      <wb:on-insert-row>
        <wb:insert-bean
          classname="org.apache.cocoon.woody.samples.Contact"
          addmethod="addContact" />
      </wb:on-insert-row>
    </wb:repeater>
  
  </wb:context>
  
  
  
  1.1                  cocoon-2.1/src/blocks/woody/samples/forms/form2_bind_xml.xml
  
  Index: form2_bind_xml.xml
  ===================================================================
  <?xml version="1.0"?>
  <!--
      | Binding template between 
      |   - form_data file (backend)
      |   - and form_model file
      | Mappings
      |   woody-widget              <> backend-xpath
      |   __________________________________________________
      |   {context}                    /data/wrapper/context
      |   {relative info context}        info  
      |   email                            email
      |   somebool                         - - - - not implemented yet
      |   account                          account/@size
      |   number1                          number
      |   drinks                           - - - - not implemented yet
      |   phone                            phone
      |     cntr                              @cntr
      |     zone                              zone
      |     number                            number
      |
      |   ipaddress                      ipaddress
      
      |   {contacts-repeater}            contacts | each row = contact
      |     firstname                      firstname
      |     lastname                       lastname
      |     email                          email
      |     phone                          phone/@nr
       -->
  <wb:context 
    xmlns:wb="http://apache.org/cocoon/woody/binding/1.0" 
  	path="/data/wrapper/context" >
  
    <wb:context path="info">
    	<!-- the email value will not be saved because of the @readonly -->
      <wb:field id="email"   path="email"         readonly="true"/>
  		<!-- jxpath binds to nodes as well as to attributes -->
      <wb:field id="account" path="account/@size" />
      <wb:field id="number1" path="number"        />
  
  	  <!-- one entry field in the client maps through aggregate fields -->
      <wb:aggregate id="phone" path="phone" >
      	<!-- to multiple fields in the XML file -->
        <wb:field id="number" path="number" />
        <wb:field id="zone"   path="zone"   />
        <wb:field id="cntr"   path="@cntr"  />
      </wb:aggregate>
      
    </wb:context>
    
    
    <wb:field id="ipaddress" path="ipaddress" >
      <wb:on-update>
      	<!-- if the value has changed, the attribute will be set -->
        <wb:set-attribute name="changed" value="true" />
      </wb:on-update>
    </wb:field>
  
  
    <!-- repeater requires unique identification mechanism of the row-nodes -->
    <wb:repeater id="contacts"
      parent-path="contacts"
      row-path="contact"
      unique-row-id="id"
      unique-path="@id"
      >
      <!-- important note: the row-path is used inside jxpath-createPath context,
           as a consequence it cannot have dependent children or predicates -->
  
      <wb:on-bind>
      	<!-- executed on updates AND right after the insert -->
        <wb:field id="firstname" path="firstname" />
        <wb:field id="lastname"  path="lastname"  />
        <wb:field id="phone"     path="phone/@nr" />
        <wb:field id="email"     path="email"     />
      </wb:on-bind>
  
      <wb:on-delete-row>
      	<!-- chose on of these to test -->
      	<!--
        <wb:set-attribute name="row-state" value="deleted" />
        -->
        <wb:delete-node />
      </wb:on-delete-row>
  
      <wb:on-insert-row>
        <wb:insert-node>
        	<!-- template inserted by the binding for new rows (mapping new nodes) -->
          <contact id="" row-state="new">
            <firstname/><lastname/><phone nr=""/><email/>
          </contact>      	
        </wb:insert-node>
      </wb:on-insert-row>
    </wb:repeater>
  
  </wb:context>
  
  
  
  1.1                  cocoon-2.1/src/blocks/woody/samples/forms/form2_jx.xml
  
  Index: form2_jx.xml
  ===================================================================
  <?xml version="1.0"?>
  <html xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
    <body>
      Email: ${form2bean.email}
      <br/>
      Phone: +${form2bean.phoneCountry}-${form2bean.phoneZone}-${form2bean.phoneNumber}
      <br/>
      IP Address: ${form2bean.ipAddress}
  
      <table border="1">
        <tr>
          <th>id</th>
          <th>firstName</th>
          <th>lastName</th>
          <th>phone</th>
          <th>email</th>
        </tr>
        <jx:forEach var="item" items="${form2bean.contacts}">
          <tr>
            <td>${item.id}</td>
            <td>${item.firstName}</td>
            <td>${item.lastName}</td>
            <td>${item.phone}</td>
            <td>${item.email}</td>
          </tr>
        </jx:forEach>
      </table>
    </body>
  </html>