<?xml version="1.0"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<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>Sample form</title>
  <content>
    <wt:form-template action="${cocoon.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>
            

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

      <!-- It's possible to access repeater rows using jx like this: -->
      <jx:forEach varStatus="loop" begin="0" end="${contacts.length - 1}">
          <jx:set var="row" value="${contacts.getRow(loop.index)}"/>
          <!-- do something with row... -->
      </jx:forEach>

      <!-- 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>
      <!-- 
           You can access properties you set on the form or other widgets 
           using jx: 
      -->
      <input type="submit" value="${buttonName}"/>
     </td></tr>
    </table>
    </wt:form-template>
  </content>
</page>
