coliver     2004/01/28 10:32:33

  Modified:    src/blocks/woody/samples welcome.xml sitemap.xmap
  Added:       src/blocks/woody/samples/v2 a-choices.xml car-db.xml
                        carselector_form.xml carselector_success.xsp
                        carselector_template.xml form1.xml
                        form1_template.xml sitemap.xmap
                        woody_flow_example.js
  Log:
  Experimental improvements to Woody Flowscript API
  
  Revision  Changes    Path
  1.13      +6 -0      cocoon-2.1/src/blocks/woody/samples/welcome.xml
  
  Index: welcome.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/welcome.xml,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- welcome.xml       30 Dec 2003 17:27:31 -0000      1.12
  +++ welcome.xml       28 Jan 2004 18:32:32 -0000      1.13
  @@ -53,5 +53,11 @@
     <sample name="Flowscript" href="form1.flow?locale=de-DE">Germany</sample>
     <sample name="Flowscript" href="form1.flow?locale=nl-BE">Belgium 
(dutch)</sample>
    </group>
  + <group name="Experimental Woody Flowscript API">
  +  <note>
  +    The sample below demonstrates a proposal for a new Flowscript API, 
including a multipage form with a back button.
  +  </note>
  +  <sample name="New Flowscript API example" 
href="v2/example">example</sample>
  + </group>
   
   </samples>
  
  
  
  1.34      +8 -0      cocoon-2.1/src/blocks/woody/samples/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/sitemap.xmap,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- sitemap.xmap      30 Dec 2003 17:27:31 -0000      1.33
  +++ sitemap.xmap      28 Jan 2004 18:32:32 -0000      1.34
  @@ -361,6 +361,14 @@
          <map:serialize />
        </map:match>
   
  +    <map:match pattern="*">
  +        <map:redirect-to uri="{1}/"/>
  +    </map:match>
  +
  +    <map:match pattern="*/**">
  +     <map:mount check-reload="yes" src="{1}/" uri-prefix="{1}"/>
  +   </map:match>
  +
      </map:pipeline>
    </map:pipelines>
   
  
  
  
  1.1                  cocoon-2.1/src/blocks/woody/samples/v2/a-choices.xml
  
  Index: a-choices.xml
  ===================================================================
  <wd:selection-list xmlns:wd="http://apache.org/cocoon/woody/definition/1.0";>
    <wd:item value="a"/>
    <wd:item value="aa"/>
    <wd:item value="aaa"/>
    <wd:item value="aaaa"/>
    <wd:item value="aaaaa"/>
  </wd:selection-list>
  
  
  
  1.1                  cocoon-2.1/src/blocks/woody/samples/v2/car-db.xml
  
  Index: car-db.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  <cars>
    <!-- Enhancements to this list are welcome !
         Types with no models will automatically be filled with dumb values. -->
         
    <make name="Audi">
      <!-- found on http://www.audi.fr/ -->
      <type name="A2">
        <model name="1.4 75"/>
        <model name="1.4 TDI"/>
        <model name="1.4 75 Pack"/>
        <model name="1.4 TDI Pack"/>
        <model name="1.6 FSI 110 Pack"/>
        <model name="1.4 75 Pack Plus"/>
        <model name="1.6 FSI 110 Pack Plus"/>
      </type>
      <type name="A3">
        <model name="1.6 Attration 102"/>
        <model name="2.0 FSI Attractin 150"/>
        <model name="1.6 Ambiente 102"/>
        <model name="2.0 FSI Ambiente 150"/>
        <model name="2.0 FSI Ambiente 150 tiptronic"/>
        <model name="1.6 Ambition 102"/>
        <model name="2.0 FSI Ambition 150"/>
        <model name="2.0 FSI Ambition 150 tiptronic"/>
        <model name="2.0 FSI Ambition Luxe 150"/>
      </type>
      <type name="A4">
        <model name="Berline 1.9 TDI 101"/>
        <model name="Berline 2.5 TDI 163"/>
        <model name="Berline 2.5 TDI 163 multitronic"/>
        <model name="Berline 2.5 TDI 180 quattro"/>
        <model name="Berline 2.5 TDI 180 quattro tiptronic"/>
        <model name="Avant 1.9 TDI 101"/>
        <model name="Avant 1.9 TDI 130"/>
        <model name="Avant 2.5 TDI 163"/>
        <model name="Avant 2.5 TDI 163 multitronic"/>
        <model name="Avant 2.5 TDI 180 quattro"/>
        <model name="Avant 2.5 TDI 180 tiptronic quattro"/>
      </type>
      <type name="A6">
      </type>
      <type name="A8">
      </type>
      <type name="TT">
      </type>
      <type name="Allroad Quattro">
      </type>
    </make>
    <make name="Volkswagen">
      <type name="Golf">
      </type>
      <type name="Passat">
      </type>
      <type name="Bora">
      </type>
    </make>
    <make name="Mercedes">
      <type name="CLK">
      </type>
      <type name="SLK">
      </type>
    </make>
    <make name="Renault">
      <type name="Twingo">
      </type>
      <type name="Scenic">
      </type>
      <type name="Espace">
      </type>
    </make>
    <make name="Maserati">
      <type name="Quattroporte">
      </type>
      <type name="Coupe">
      </type>
      <type name="Spyder">
      </type>
    </make>
  </cars>
  
  
  
  1.1                  
cocoon-2.1/src/blocks/woody/samples/v2/carselector_form.xml
  
  Index: carselector_form.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  <!-- form used to illustrate programmatic changing of listbox content. -->
  <wd:form
    xmlns:wd="http://apache.org/cocoon/woody/definition/1.0";
    xmlns:i18n="http://apache.org/cocoon/i18n/2.1";>
  
    <wd:widgets>
      <wd:field id="make" required="true">
        <wd:label>Make:</wd:label>
        <wd:datatype base="string"/>
        <wd:selection-list src="cocoon:/cars" dynamic="true"/>
      </wd:field>
    
      <wd:field id="type" required="true">
        <wd:label>Type:</wd:label>
        <wd:datatype base="string"/>
        <wd:selection-list>
          <wd:item value="">
            <wd:label>Select a maker first</wd:label>
          </wd:item>
        </wd:selection-list>
      </wd:field>
      
      <wd:field id="model" required="true">
        <wd:label>Model:</wd:label>
        <wd:datatype base="string"/>
        <wd:selection-list>
          <wd:item value="">
            <wd:label>Select a type first</wd:label>
          </wd:item>
        </wd:selection-list>
      </wd:field>
    
      <wd:output id="message">
        <wd:datatype base="string"/>
      </wd:output>
    
    </wd:widgets>
  
  </wd:form>
  
  
  
  1.1                  
cocoon-2.1/src/blocks/woody/samples/v2/carselector_success.xsp
  
  Index: carselector_success.xsp
  ===================================================================
  <?xml version="1.0"?>
  <xsp:page language="java"
    xmlns:xsp="http://apache.org/xsp";>
  
    <xsp:structure>
      <xsp:include>org.apache.cocoon.woody.formmodel.*</xsp:include>
    </xsp:structure>
  
    <page>
      <title>Car selector result</title>
      <content>
        <xsp:logic>
          // get reference to form and some of the widgets on it
          Form form = (Form)request.getAttribute("carselectorform");
          Field make = (Field)form.getWidget("make");
          Field type = (Field)form.getWidget("type");
          Field model = (Field)form.getWidget("model");
        </xsp:logic>
  
        You selected: maker <xsp:expr>make.getValue()</xsp:expr>,
        type <xsp:expr>type.getValue()</xsp:expr>,
        model <xsp:expr>model.getValue()</xsp:expr>
      </content>
    </page>
  </xsp:page>
  
  
  
  1.1                  
cocoon-2.1/src/blocks/woody/samples/v2/carselector_template.xml
  
  Index: carselector_template.xml
  ===================================================================
  <?xml version="1.0"?>
  <page xmlns:wt="http://apache.org/cocoon/woody/template/1.0"; 
        xmlns:wi="http://apache.org/cocoon/woody/instance/1.0";
        xmlns:jx="http://apache.org/cocoon/templates/jx/1.0";>
    <title>Car selector</title>
    <para>This example illustrates how you can programmatically update the
      content of a selection list.</para>
    <para>
      This sample illustrates event-handling in Woody and how selection lists 
can be changed
      programmatically.
    </para>
    <para>
      Event-handlers are defined in the form definition to update the selection 
lists and set
      the comment text below the table. This requires only a few lines of 
server-side JavaScript.
      Selection widgets also have a "submit-on-change" attribute set in the 
form template so that
      changes are considered immediately by the server.
    </para>
    <para>
      See "carselector_form.xml" and "carselector_template.xml" to see how this 
is done.
    </para>
    <content>
      <wt:form-template action="carselector" method="POST">
        <wt:continuation-id/>
        <table border="1">
          <tr>
            <td valign="top"><wt:widget-label id="make"/></td>
            <td valign="top">
              <wt:widget id="make">
                <wi:styling submit-on-change="true"/>
              </wt:widget>
            </td>
          </tr>
          <tr>
            <td valign="top"><wt:widget-label id="type"/></td>
            <td valign="top">
              <wt:widget id="type">
                <wi:styling submit-on-change="true"/>
              </wt:widget>
            </td>
          </tr>
          <tr>
            <td valign="top"><wt:widget-label id="model"/></td>
            <td valign="top">
              <wt:widget id="model">
                <wi:styling submit-on-change="true"/>
              </wt:widget>
            </td>
          </tr>
        </table>
  
        <br/>
        <wt:widget id="message"/>
        <br/>
        <br/>
        <input type="submit" value="Buy it!" 
onClick="document.forms[0].action='#{$cocoon/continuation/id}.continue';document.forms[0].submit()"/>
        <input type="submit" name="prev" value="Back" 
onClick="document.forms[0].action='#{$cocoon/continuation/previousBookmark/id}.continue';document.forms[0].submit()"/>
  
      </wt:form-template>
    </content>
  </page>
  
  
  
  1.1                  cocoon-2.1/src/blocks/woody/samples/v2/form1.xml
  
  Index: form1.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <!--+
      | CVS $Id: form1.xml,v 1.1 2004/01/28 18:32:32 coliver Exp $
      +-->
  
  <wd:form xmlns:wd="http://apache.org/cocoon/woody/definition/1.0";
           xmlns:i18n="http://apache.org/cocoon/i18n/2.1";>
    
    <wd:widgets>
      <wd:field id="tab-state">
        <wd:datatype base="string"/>
      </wd:field>
    
      <wd:field id="email" required="true">
        <wd:datatype base="string">
          <wd:validation>
            <wd:email/>
          </wd:validation>
        </wd:datatype>
        <wd:label>Enter an <b>email</b> address:</wd:label>
        <wd:help>
          An email address must be in <i>[EMAIL PROTECTED]</i> format.
          <br/>
          And if you do not know what <b>email</b> address is, then well, 
chances are
          that you do not have it. However, if you have access to the Internet,
          you can easily get yourself one!
          <br/>
          Choose one of the following options:
          <ul>
            <li><a href='http://mail.yahoo.com/'>Yahoo! Mail</a></li>
            <li><a href='http://www.hotmail.com/'>Hotmail</a></li>
          </ul>
          <small>Anyway, the point of all this was to show a popup help with 
mixed html content.</small>
        </wd:help>
      </wd:field>
    
      <wd:booleanfield id="somebool">
        <wd:label>Put me <em>on</em> or <em>off</em>.</wd:label>
      </wd:booleanfield>
    
      <wd:field id="fourchars">
        <wd:label>Select something that's 4 characters long:</wd:label>
        <wd:datatype base="string">
          <wd:validation>
            <wd:length exact='2*2'/>
          </wd:validation>
        </wd:datatype>
        <wd:selection-list src="a-choices.xml"/>
      </wd:field>
    
      <wd:field id="account">
        <wd:label>Indicate the size of your bank account (in 
m<sup>3</sup>):</wd:label>
        <wd:datatype base="long"/>
        <wd:selection-list>
          <wd:item value="1"/>
          <wd:item value="2"/>
          <wd:item value="3">
            <wd:label>three</wd:label>
          </wd:item>
          <wd:item value="4"/>
          <wd:item value="5"/>
        </wd:selection-list>
      </wd:field>
    
      <wd:field id="cowheight">
        <wd:label>Indicate your height (in cows):</wd:label>
        <wd:datatype base="long"/>
        <wd:selection-list>
          <wd:item value="1"/>
          <wd:item value="2"/>
          <wd:item value="3">
            <wd:label>three</wd:label>
          </wd:item>
          <wd:item value="4"/>
          <wd:item value="5"/>
        </wd:selection-list>
      </wd:field>
    
      <wd:field id="number1" required="true">
        <wd:label>Please enter a number<br/>
        <small>(will automatically set a correct value below if 
needed)</small>:</wd:label>
        <wd:datatype base="long"/>
      </wd:field>
    
      <wd:field id="number2" required="true">
        <wd:label>Enter another number, larger than the other number:</wd:label>
        <wd:datatype base="long">
          <wd:validation>
            <wd:range min="number1 + 1">
              <wd:failmessage>This number should be larger than the first 
number.</wd:failmessage>
            </wd:range>
          </wd:validation>
        </wd:datatype>
      </wd:field>
    
      <wd:multivaluefield id="drinks">
        <wd:label>Indicate which 2 of the following drinks you'd like to 
receive:</wd:label>
        <wd:datatype base="string">
          <wd:validation>
            <wd:value-count exact="2"/>
          </wd:validation>
        </wd:datatype>
        <wd:selection-list>
          <wd:item value="Maes"/>
          <wd:item value="Jupiler"/>
          <wd:item value="Leffe"/>
          <wd:item value="Hoegaarden"/>
          <wd:item value="Coca Cola"/>
        </wd:selection-list>
      </wd:multivaluefield>
    
      <wd:aggregatefield id="visa" required="true">
        <wd:label>Enter your (16-digit) visa number (without spaces)
          <br/>Your credit card will be billed.
          <br/><small>Valid test number is: 4111111111111111</small></wd:label>
        <wd:help>Use a fake number if <a 
href="http://cocoon.apache.org";>Cocoon</a> is not running on your local 
computer</wd:help>
        <wd:split pattern="([0-9]{4})([0-9]{4})([0-9]{4})([0-9]{4})">
          <wd:map group="1" field="part1"/>
          <wd:map group="2" field="part2"/>
          <wd:map group="3" field="part3"/>
          <wd:map group="4" field="part4"/>
          <wd:failmessage>Not a valid 16-digit visa number.</wd:failmessage>
        </wd:split>
        <wd:combine expression='Concat(part1,part2,part3,part4)'/>
        <wd:widgets>
          <wd:field id="part1">
            <wd:datatype base="string"/>
          </wd:field>
          <wd:field id="part2">
            <wd:datatype base="string"/>
          </wd:field>
          <wd:field id="part3">
            <wd:datatype base="string"/>
          </wd:field>
          <wd:field id="part4">
            <wd:datatype base="string"/>
          </wd:field>
        </wd:widgets>
        <wd:validation>
          <wd:mod10>
            <wd:failmessage>Invalid credit card number.</wd:failmessage>
          </wd:mod10>
        </wd:validation>
      </wd:aggregatefield>
    
      <wd:field id="ipaddress" required="true">
        <wd:label>Please enter your IP address</wd:label>
        <wd:datatype base="string">
          <wd:validation>
            <wd:regexp 
pattern="^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$">
              <wd:failmessage>Invalid IP address.</wd:failmessage>
            </wd:regexp>
          </wd:validation>
        </wd:datatype>
      </wd:field>
    
      <wd:field id="birthdate" required="true">
        <wd:label>Your birthdate (dd/MM/yyyy):</wd:label>
        <wd:datatype base="date">
          <wd:convertor>
            <wd:patterns>
              <wd:pattern>dd/MM/yyyy</wd:pattern>
              <!-- The above pattern is a non-locale-specific pattern. You can
              also add locale-specific patterns by adding more wd:pattern 
elements
              here, with a locale attribute on them. -->
            </wd:patterns>
          </wd:convertor>
          <wd:validation>
            <wd:range min="Date(1850, 1, 1)" max="Date(2150, 1, 1)">
              <wd:failmessage>Dead and not born yet should not bother filling 
this form</wd:failmessage>
            </wd:range>
          </wd:validation>
        </wd:datatype>
      </wd:field>
    
      <wd:field id="altbirthdate" required="true">
        <wd:label>Select a date on which you'd rather had been born:</wd:label>
        <wd:datatype base="date">
          <wd:convertor variant="date" style="full"/>
        </wd:datatype>
        <wd:selection-list>
          <!-- The convertor element here is used to specify how the values
               in the value attributes of the wd:item elements should be
               interpreted. -->
          <wd:convertor type="formatting">
            <wd:patterns>
              <wd:pattern>yyyyMMdd</wd:pattern>
            </wd:patterns>
          </wd:convertor>
          <wd:item value="13020711"/>
          <wd:item value="19120623"/>
          <wd:item value="19690721"/>
          <wd:item value="19700506"/>
          <wd:item value="19781014"/>
          <wd:item value="20010911"/>
        </wd:selection-list>
      </wd:field>
    
      <wd:field id="dieselprice" required="true">
        <wd:label>Price for a liter diesel:</wd:label>
        <wd:datatype base="decimal">
          <wd:convertor variant="number">
            <wd:patterns>
              <wd:pattern>#.00</wd:pattern>
            </wd:patterns>
          </wd:convertor>
        </wd:datatype>
      </wd:field>
    
      <wd:repeater id="contacts">
        <wd:widgets>
          <wd:field id="firstname">
            <wd:label>Firstname</wd:label>
            <wd:datatype base="string"/>
          </wd:field>
          <wd:field id="lastname">
            <wd:label>Lastname</wd:label>
            <wd:datatype base="string"/>
          </wd:field>
          <wd:field id="phone">
            <wd:label>Phone</wd:label>
            <wd:datatype base="string"/>
          </wd:field>
          <wd:field id="email">
            <wd:label>Email</wd:label>
            <wd:datatype base="string">
              <wd:validation>
                <wd:email/>
              </wd:validation>
            </wd:datatype>
          </wd:field>
          <wd:booleanfield id="select">
            <wd:label>Select</wd:label>
          </wd:booleanfield>
        </wd:widgets>
      </wd:repeater>
    
      <!--wd:repeater-action id="addcontact" action-command="add-row" 
repeater="contacts">
        <wd:label>Add contact</wd:label>
      </wd:repeater-action>
    
      <wd:repeater-action id="removecontacts" action-command="delete-rows" 
repeater="contacts" select="select">
        <wd:label>Remove selected contacts</wd:label>
      </wd:repeater-action-->
  
      <wd:action id="addcontact" action-command="x">
        <wd:label>Add contact</wd:label>
      </wd:action>
    
      <wd:action id="removecontacts" action-command="x">
        <wd:label>Remove selected contacts</wd:label>
      </wd:action>
    </wd:widgets>
  
  </wd:form>
  
  
  
  1.1                  cocoon-2.1/src/blocks/woody/samples/v2/form1_template.xml
  
  Index: form1_template.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- The only difference between this file and the form1_template_action.xml
       is the value of the action attribute on the wt:form-template element -->
  <page xmlns:wt="http://apache.org/cocoon/woody/template/1.0"; 
xmlns:wi="http://apache.org/cocoon/woody/instance/1.0";>
    <title>Sample form</title>
    <content>
      <wt:form-template action="#{$continuation/id}.continue" method="POST">
      <table align="center">
       <tr><td>
       
              <!-- group with tabs. Each of the children of <items> will 
constitute a tab -->
              <wi:group>
                <wi:styling type="choice"/>
                <wi:label>Choose a panel: </wi:label>
                <wi:state>
                  <wt:widget id="tab-state"/>
                </wi:state>
                
                <wi:items>
                  <!-- group with automatic two-column layout -->
                  <wi:group>
                    <wi:label>String fields</wi:label>
                    <wi:styling layout="columns"/>
                    <wi:items>
                      <wt:widget id="email"/>
                      <wt:widget id="fourchars">
                        <!-- particular styling for the enumeration -->
                        <wi:styling list-type="listbox" listbox-size="4"/>
                      </wt:widget>
                    </wi:items>
                  </wi:group>
                  
                  <wi:group>
                    <wi:label>Number fields</wi:label>
                    <wi:styling layout="columns"/>
                    <wi:items>
                      <wt:widget id="number1">
                        <wi:styling submit-on-change="true"/>
                      </wt:widget>
                      <wt:widget id="number2"/>
                      <wt:widget id="account"/>
                      <wt:widget id="cowheight">
                        <wi:styling list-type="radio"/>
                      </wt:widget>
                    </wi:items>
                  </wi:group>
                  
                  <wi:group>
                    <wi:styling layout="columns"/>
                    <wi:label>Boolean fields</wi:label>
                    <wi:items>
                      <wt:widget id="somebool"/>
                      <wt:widget id="drinks">
                        <wi:styling list-type="listbox" listbox-size="4"/>
                      </wt:widget>
                    </wi:items>
                  </wi:group>
                </wi:items>
              </wi:group>
              
              <p>Checkout the <a href="form1">form1 action page</a> for another 
way of formatting panels</p>
  
        <wi:group>
          <wi:styling layout="columns"/>
          <wi:items>
            <wt:widget id="visa"/>
            <wt:widget id="ipaddress"/>
            <wt:widget id="altbirthdate"/>
            <wt:widget id="birthdate"><wi:styling type="date" 
format="dd/MM/yyyy"/></wt:widget>
            <wt:widget id="dieselprice"/>
          </wi:items>
        </wi:group>
  
  
        <!-- manual layout of fieldw, without use of a wi:group -->
        <wt:widget-label id="contacts"/><br/>
        <wt:repeater-size id="contacts"/>
        <table border="1">
          <tr>
            <th><wt:repeater-widget-label id="contacts" 
widget-id="firstname"/></th>
            <th><wt:repeater-widget-label id="contacts" 
widget-id="lastname"/></th>
            <th><wt:repeater-widget-label id="contacts" widget-id="phone"/></th>
            <th><wt:repeater-widget-label id="contacts" widget-id="email"/></th>
            <th><wt:repeater-widget-label id="contacts" 
widget-id="select"/></th>
          </tr>
  
          <!-- The contents of the repeater-widget element is a template that 
will
          be applied to each row in the repeater. -->
          <wt:repeater-widget id="contacts">
            <tr>
              <td><wt:widget id="firstname"/></td>
              <td><wt:widget id="lastname"/></td>
              <td><wt:widget id="phone"/></td>
              <td><wt:widget id="email"/></td>
              <td><wt:widget id="select"/></td>
            </tr>
          </wt:repeater-widget>
  
          <tr>
            <td colspan="4" align="right">
              <wt:widget id="addcontact"/>
              <wt:widget id="removecontacts"/>
            </td>
          </tr>
        </table>
  
        <input type="submit"/>
       </td></tr>
      </table>
      </wt:form-template>
    </content>
  </page>
  
  
  
  1.1                  cocoon-2.1/src/blocks/woody/samples/v2/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  <?xml version="1.0"?>
  
  <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0";>
  
   <map:components>
  
    <map:generators default="file">   
      <map:generator name="woody" 
src="org.apache.cocoon.woody.generation.WoodyGenerator" logger="woody"/>
      <map:generator name="jx" 
src="org.apache.cocoon.generation.JXTemplateGenerator" label="content" 
logger="sitemap.generator.jx"/>
    </map:generators>
  
    <map:transformers default="xalan">    
      <map:transformer name="woody" 
src="org.apache.cocoon.woody.transformation.WoodyTemplateTransformer" 
logger="woody"/>
      <map:transformer name="i18n" 
src="org.apache.cocoon.transformation.I18nTransformer">
        <catalogues default="other">
          <catalogue id="other" name="OtherMessages" location="../messages"/>
          <catalogue id="woody" name="WoodyMessages" location="../messages"/>
        </catalogues>
        <cache-at-startup>true</cache-at-startup>
      </map:transformer>
    </map:transformers>
  
    <map:selectors default="browser">
      <map:selector name="request-method" 
src="org.apache.cocoon.selection.RequestMethodSelector"/>
    </map:selectors>
  
    <map:pipes default="caching">
    </map:pipes>
  
   </map:components>
  
   <map:views>
    <map:view name="content" from-label="content">
     <map:serialize type="xml"/>
    </map:view>
  
    <map:view from-label="content" name="pretty-content">
     <map:transform src="context://stylesheets/system/xml2html.xslt"/>
     <map:serialize type="html"/>
    </map:view>
  
    <map:view name="links" from-position="last">
     <map:serialize type="links"/>
    </map:view>
   </map:views>
   
   <map:resources>
     <!-- this will later become a virtual transformer -->
     <map:resource name="simple-page2html">
       <map:transform 
src="context://samples/common/style/xsl/html/simple-page2html.xsl">
         <map:parameter name="contextPath" value="{request:contextPath}"/>
         <map:parameter name="servletPath" value="{request:servletPath}"/>
         <map:parameter name="sitemapURI" value="{request:sitemapURI}"/>
         <map:parameter name="file" value="{file}"/>
         <map:parameter name="remove" value="{../0}"/>
       </map:transform> 
     </map:resource>
   </map:resources>
  
    <!-- indicates what flowscript to attach to this sitemap -->
    <map:flow language="javascript">
      <map:script src="woody_flow_example.js"/>
    </map:flow>
  
   <map:pipelines>
     <map:pipeline>
  
       <map:match pattern="">
        <map:generate src="welcome.xml"/>
        <map:transform 
src="context://samples/common/style/xsl/html/simple-samples2html.xsl">
           <map:parameter name="contextPath" value="{request:contextPath}"/>
        </map:transform>
        <map:serialize/>
       </map:match>
  
      <!-- Flowscript Sample -->
  
       <map:match pattern="example">
         <map:call function="example"/>
       </map:match>
  
       <map:match pattern="*.continue">
         <map:call continuation="{1}"/>
       </map:match>
  
       <map:match pattern="*-display-pipeline">
         <!-- pipeline to show the form -->
         <map:generate type="jx" src="{1}_template.xml"/>
         <map:transform type="woody"/>
         <map:transform type="i18n">
           <map:parameter name="locale" value="en-US"/>
         </map:transform>
         <map:call resource="simple-page2html">
           <map:parameter name="file" value="{1}_template.xml"/>
         </map:call>
         <map:transform src="../resources/woody-samples-styling.xsl">
           <map:parameter name="resources-uri" value="../resources"/>
          </map:transform>
         <map:serialize/>
       </map:match>
  
       <map:match pattern="*-success-pipeline.xsp">
         <map:generate type="serverpages" src="{1}_success.xsp"/>
         <map:call resource="simple-page2html">
           <map:parameter name="file" value="{1}_template.xsp"/>
         </map:call>
         <map:serialize/>
       </map:match>
  
       <map:match pattern="carselector">
         <map:select type="request-method">
           <map:when test="POST">
             <map:call continuation="{request-param:continuation-id}"/>
           </map:when>
           <map:otherwise>
             <map:call function="selectCar">
               <map:parameter name="defaultMake" value="Maserati"/>
             </map:call>
           </map:otherwise>
         </map:select>
       </map:match>
  
       <map:match pattern="cars">
         <map:generate src="car-db.xml"/>
         <map:transform src="../xsl/carfilter.xsl">
           <map:parameter name="list" value="makes"/>
         </map:transform>
         <map:serialize type="xml"/>
       </map:match>
  
       <map:match pattern="cars/*">
         <map:generate src="car-db.xml"/>
         <map:transform src="../xsl/carfilter.xsl">
           <map:parameter name="list" value="types"/>
           <map:parameter name="make" value="{1}"/>
         </map:transform>
         <map:serialize type="xml"/>
       </map:match>
  
       
       <map:match pattern="cars/*/*">
         <map:generate src="car-db.xml"/>
         <map:transform src="../xsl/carfilter.xsl">
           <map:parameter name="list" value="models"/>
           <map:parameter name="make" value="{1}"/>
           <map:parameter name="type" value="{2}"/>
         </map:transform>
         <map:serialize type="xml"/>
       </map:match>
  
     </map:pipeline>
   </map:pipelines>
  
  </map:sitemap>
  
  
  
  1.1                  
cocoon-2.1/src/blocks/woody/samples/v2/woody_flow_example.js
  
  Index: woody_flow_example.js
  ===================================================================
  /*
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      [EMAIL PROTECTED]
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <[EMAIL PROTECTED]>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/v2/Form.js");
  
  // Multipage Form example
  
  function example() {
      showForm1();
      selectCar();
  }
  
  function showForm1() {
      var form = new Form("form1.xml");
      var locale = determineLocale();
      var wid = form.getWidget();
      //
      // 'wid' is a javascript wrapper of the Woody Form widget.
      //
      // Its subwidgets can be accessed by id.
      //
      // Each widget has a 'value' property to access or modify its value.
      //
      wid.email.value = "[EMAIL PROTECTED]";
      wid.somebool.value = true;
      wid.fourchars.value = "aaaa";
      wid.account.value = 2;
      wid.cowheight.value = 2;
      //
      // A Complex widget allows initialization of its subwidgets by
      // assigning an object containing properties corresponding to its
      // subwidgets and their properties:
      //
      wid.visa.value = {part1: {value: "4111"},
                        part2: {value: "1111"},
                        part3: {value: "1111"},
                        part4: {value: "1111"}};
      wid.number1.value = 1;
      wid.number2.value = 3;
      //
      // A Field Widget can receive ValueChange events through its 'onChange' 
      // property:
      //
      wid.number1.onChange = function(oldValue, newValue) {
          print("number1 changing from " + oldValue + " to " + newValue);
          print("wid="+wid);
          print("wid.number2="+wid.number2);
          wid.number2.value = newValue + 1;
      }
      wid.ipaddress.value = "127.0.0.1";
      wid.ipaddress.onChange = function(oldValue, newValue) {
          print("ipaddress changed from " + oldValue + " to " + newValue);
      }
      wid.dieselprice.value = 2.00;
      wid.birthdate.value = new java.util.Date();
      //
      // The rows of a Repeater widget can be accessed using array syntax:
      //
      wid.contacts[0].firstname.value = "Jules";
      wid.contacts[1].firstname.value =  "Lucien";
      // This also works:
      wid.contacts[2].value = {firstname: {value : "Chris"}};
      //
      // A Repeater also has a 'length' property like an array
      //
      print("contacts.length = " + wid.contacts.length);
      //
      // An Action widget can handle ActionEvents through its 'onClick' property
      //
      wid.addcontact.onClick = function() {
          //
          // You can add a row using the addRow() function of Repeater
          //
          var row = wid.contacts.addRow();
          row.select.onChange = function(oldValue, newValue) {
              if (newValue) {
                  print("you selected: " + row.firstname.value);
              } else {
                  print("you deselected: " + row.firstname.value);
              }
          }
      }
      wid.removecontacts.onClick = function() {
          //
          // You can remove rows using the removeRow() function: the argument
          // may be an integer index, or, as in this example, a function acting
          // as a predicate. Each row that satisfies the predicate will
          // be removed.
          //
          wid.contacts.removeRow(function(row) {return row.select.value});
      }
      //
      // A MultiValue widget can be initialized using an array:
      //
      wid.drinks.value = ["Jupiler", "Coca Cola"];
      //
      // showForm() sends the form to the browser and doesn't return
      // until validation is complete.
      //
      form.showForm("form1-display-pipeline");
      print("cowheight = "+wid.cowheight.value);
  }
  
  function selectCar() {
      var form = new Form("carselector_form.xml");
      var wid = form.getWidget();
      wid.make.value = cocoon.parameters.defaultMake;
      wid.make.onChange = function(oldValue, newValue) {
          print("onChange: oldValue: " + oldValue);
          print("onChange: newValue: " + newValue);
          if (newValue != null) {
              wid.type.setSelectionList("cocoon:/cars/"+newValue);
          } else {
              wid.type.setSelectionList(form.createEmptySelectionList("Select a 
maker first"));
          }
          print("onChange: " + wid.make.value);
          if (wid.make.value == null) {
              wid.message.value = "Yep. Choosing a maker is not that easy...";
          } else {
              if (oldValue == null) {
                  wid.message.value = "Good. " + wid.make.value + " makes good 
cars!";
              } else {
                  wid.message.value = "Why not? " + wid.make.value + " also 
makes good cars!";
              }
          }
      }
      wid.type.onChange = function(oldValue, newValue) {
          if (newValue != null) {
              wid.model.setSelectionList("cocoon:/cars/"+ wid.make.value + "/" 
+ newValue);
          } else {
              wid.model.setSelectionList(form.createEmptySelectionList("Select 
a type first"));
          }
          if (newValue != null) {
              if (oldValue == null) {
                wid.message.value = "A " + wid.make.value + " " + newValue + " 
is a very good choice.";
              } else {
                wid.message.value = "So you prefer a " +  " ?";
              }
          }
      }
      form.showForm("carselector-display-pipeline");
      cocoon.request.setAttribute("carselectorform", form.getWidget().unwrap());
      cocoon.sendPage("carselector-success-pipeline.xsp");
  }
  
  function determineLocale() {
      var localeParam = cocoon.request.get("locale");
      if (localeParam != null && localeParam.length > 0) {
          return 
Packages.org.apache.cocoon.i18n.I18nUtils.parseLocale(localeParam);
      }
      return null;
  }
  
  
  
  

Reply via email to