blob: bba3bbaa666bbc693ba2e470669df911f99c6824 [file] [log] [blame]
<?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.
-->
<!--+
| CVS $Id$
+-->
<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"/>
<!-- new-style validation, outside of the datatype -->
<wd:validation>
<wd:email/>
</wd:validation>
<wd:label>Enter an <b>email</b> address:</wd:label>
<wd:help>
An email address must be in <i>[name]@[domain].[tld]</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:selection-list src="forms/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:on-value-changed>
<javascript>
java.lang.System.err.println("Was here!");
var newValue = event.source.value;
if (newValue != null) {
var number2 = event.source.parent.getWidget("number2");
if (number2.value == null) {
number2.setValue(new java.lang.Long(newValue.intValue() + 1));
}
}
</javascript>
</wd:on-value-changed>
</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: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: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:datatype base="string"/>
<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: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:datatype>
<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: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:validation>
<!-- This demonstrates validating a repeater: we check here if all contacts are distinct.
A validator cannot itself display a validation error, and therefore sets a validation
error on a field in the offenting row. -->
<wd:javascript>
var list = new java.util.ArrayList();
var success = true;
// Iterate on all rows
for (var i = 0; i &lt; widget.size; i++) {
// Get the row
var row = widget.getRow(i);
// Compute a key combining the first and last name
var key = row.getWidget("firstname").value + "/" + row.getWidget("lastname").value;
if (list.contains(key)) {
// already in the list
row.getWidget("firstname").setValidationError(new Packages.org.apache.cocoon.woody.validation.ValidationError("Duplicate contact name", false));
success = false;
break; // no need to continue
}
// Add the current row's key to the list
list.add(key);
}
// Must return true/false
return success;
</wd:javascript>
</wd:validation>
<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: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:widgets>
</wd:form>