blob: a528fb0af700a9af3ee323109f8de4411c8a2257 [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.
-->
<!-- form used to illustrate activate/invisible state widget on ajax forms. -->
<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
<fd:widgets>
<fd:field id="field_1" required="true">
<fd:label>Simple widget</fd:label>
<fd:hint>field_1</fd:hint>
<fd:help>field_1</fd:help>
<fd:datatype base="string"/>
</fd:field>
<fd:field id="field_2" required="true">
<fd:label>Date Widget</fd:label>
<fd:hint>field_2</fd:hint>
<fd:help>field_2</fd:help>
<fd:datatype base="date"/>
</fd:field>
<fd:field id="field_3" required="true" state="invisible">
<fd:label>Combo Box Widget</fd:label>
<fd:hint>field_3</fd:hint>
<fd:help>field_3</fd:help>
<fd:datatype base="string"/>
<fd:selection-list>
<fd:item value=""/>
<fd:item value="1"/>
<fd:item value="2"/>
<fd:item value="3"/>
<fd:item value="4"/>
<fd:item value="5"/>
</fd:selection-list>
</fd:field>
<fd:field id="field_4" required="true" state="invisible">
<fd:label>List Box Widget</fd:label>
<fd:hint>field_4</fd:hint>
<fd:help>field_4</fd:help>
<fd:datatype base="string"/>
<fd:selection-list>
<fd:item value=""/>
<fd:item value="1"/>
<fd:item value="2"/>
<fd:item value="3"/>
<fd:item value="4"/>
<fd:item value="5"/>
</fd:selection-list>
</fd:field>
<fd:multivaluefield id="field_5" required="true">
<fd:label>Multivalue Widget</fd:label>
<fd:hint>field_5</fd:hint>
<fd:help>field_5</fd:help>
<fd:datatype base="string"/>
<fd:validation>
<fd:value-count exact="2"/>
</fd:validation>
<fd:selection-list>
<fd:item value="1"/>
<fd:item value="2"/>
<fd:item value="3"/>
<fd:item value="4"/>
<fd:item value="5"/>
</fd:selection-list>
</fd:multivaluefield>
<fd:field id="field_6" required="true">
<fd:label>Radio button List Widget</fd:label>
<fd:hint>field_6</fd:hint>
<fd:help>field_6</fd:help>
<fd:datatype base="string"/>
<fd:selection-list>
<fd:item value=""/>
<fd:item value="1"/>
<fd:item value="2"/>
<fd:item value="3"/>
<fd:item value="4"/>
<fd:item value="5"/>
</fd:selection-list>
</fd:field>
<fd:booleanfield id="field_7" required="true">
<fd:label>Boolean Field</fd:label>
<fd:hint>field_7</fd:hint>
<fd:help>field_7</fd:help>
</fd:booleanfield>
<fd:field id="field_8" required="true">
<fd:label>Radio button List Widget</fd:label>
<fd:hint>field_8</fd:hint>
<fd:help>field_8</fd:help>
<fd:datatype base="string"/>
<fd:selection-list>
<fd:item value=""/>
<fd:item value="1"/>
<fd:item value="2"/>
<fd:item value="3"/>
<fd:item value="4"/>
<fd:item value="5"/>
</fd:selection-list>
</fd:field>
<fd:field id="field_9" required="true">
<fd:label>Text Area widget</fd:label>
<fd:hint>field_9</fd:hint>
<fd:help>field_9</fd:help>
<fd:datatype base="string"/>
</fd:field>
<fd:multivaluefield id="field_10" required="true">
<fd:label>Multivalue Widget</fd:label>
<fd:hint>field_10</fd:hint>
<fd:help>field_10</fd:help>
<fd:datatype base="string"/>
<fd:validation>
<fd:value-count exact="2"/>
</fd:validation>
<fd:selection-list>
<fd:item value="1"/>
<fd:item value="2"/>
<fd:item value="3"/>
<fd:item value="4"/>
<fd:item value="5"/>
</fd:selection-list>
</fd:multivaluefield>
<fd:multivaluefield id="field_11" required="true">
<fd:label>Multivalue Widget</fd:label>
<fd:hint>field_11</fd:hint>
<fd:help>field_11</fd:help>
<fd:datatype base="string"/>
</fd:multivaluefield>
<fd:aggregatefield id="field_12" required="true">
<fd:label>Enter your (16-digit) visa number (without spaces)
<br/>Your credit card will be billed.
<br/><small>Valid test number is: 4111111111111111</small>
</fd:label>
<fd:help>Use a fake number if <a href="http://cocoon.apache.org">Cocoon</a> is not running on your local computer</fd:help>
<fd:hint>field_12</fd:hint>
<fd:datatype base="string"/>
<fd:split pattern="([0-9]{4})([0-9]{4})([0-9]{4})([0-9]{4})">
<fd:map group="1" field="part1"/>
<fd:map group="2" field="part2"/>
<fd:map group="3" field="part3"/>
<fd:map group="4" field="part4"/>
<fd:failmessage>Not a valid 16-digit visa number.</fd:failmessage>
</fd:split>
<fd:combine expression='Concat(part1,part2,part3,part4)'/>
<fd:widgets>
<fd:field id="part1">
<fd:datatype base="string"/>
</fd:field>
<fd:field id="part2">
<fd:datatype base="string"/>
</fd:field>
<fd:field id="part3">
<fd:datatype base="string"/>
</fd:field>
<fd:field id="part4">
<fd:datatype base="string"/>
</fd:field>
</fd:widgets>
<fd:validation>
<fd:mod10>
<fd:failmessage>Invalid credit card number.</fd:failmessage>
</fd:mod10>
</fd:validation>
</fd:aggregatefield>
<fd:field id="field_13">
<fd:label>Suggestion Widget</fd:label>
<fd:hint>field_13</fd:hint>
<fd:help>field_13</fd:help>
<fd:datatype base="integer"/>
<fd:initial-value>16</fd:initial-value>
<fd:suggestion-list type="javascript">
<![CDATA[
function addSuggestion(bean) {
suggestions.push({value: bean.value, label: bean.label});
}
function personList() {
return [
{value: 1, label: "Donald Ball"},
{value: 2, label: "Sylvain Wallez"},
{value: 3, label: "Carsten Ziegeler"},
{value: 4, label: "Torsten Curdt"},
{value: 5, label: "Marcus Crafter"},
{value: 6, label: "Ovidiu Predescu"},
{value: 7, label: "Christian Haul"},
{value: 8, label: "Jeremy Quinn"},
{value: 9, label: "Stefano Mazzocchi"},
{value: 10, label: "Pierpaolo Fumagalli"},
{value: 11, label: "Davanum Srinivas"},
{value: 12, label: "Antonio Gallardo"},
{value: 13, label: "Ugo Cei"},
{value: 14, label: "David Crossley"},
{value: 15, label: "Bertrand Delacrétaz"},
{value: 16, label: "Bruno Dumon"},
{value: 17, label: "Daniel Fagerstrom"},
{value: 18, label: "Leszek Gawron"},
{value: 19, label: "Ralph Goers"},
{value: 20, label: "Vadim Gritsenko"},
{value: 21, label: "Jorg Heymans"},
{value: 22, label: "Jörg Heinicke"},
{value: 23, label: "Jean-Baptiste Quenot"}
];
}
function startsWith(string1, string2) {
return (new java.lang.String(string1.toLowerCase())).startsWith(string2.toLowerCase());
}
function searchByString() {
for (var i = 0; i < list.length; i++) {
if (startsWith(list[i].label, filter)) {
addSuggestion(list[i]);
}
}
}
function searchById() {
for (var i = 0; i < list.length; i++) {
if (list[i].value == parseInt(filter)) {
addSuggestion(list[i]);
}
}
}
var suggestions = [];
var list = personList();
if (filter) {
var phase = cocoon.request.getParameter("phase");
if (phase && phase.equals("init")) {
if (!isNaN(parseInt(filter))) {
searchById();
} else {
cocoon.log.error("The filter: '" + filter + "' must be a number.");
}
} else {
searchByString();
}
} else {
suggestions = list;
}
return suggestions;
]]>
</fd:suggestion-list>
</fd:field>
<fd:multivaluefield id="field_14">
<fd:label>Multivalue with Suggestion Widget</fd:label>
<fd:hint>field_14</fd:hint>
<fd:help>field_14</fd:help>
<fd:datatype base="long" />
</fd:multivaluefield>
<fd:multivaluefield id="field_15">
<fd:label><b>Multivalue dojo widget:</b></fd:label>
<fd:hint>double-list multivalue dojo widget</fd:hint>
<fd:help>double-list multivalue dojo widget</fd:help>
<fd:datatype base="string"/>
<fd:selection-list>
<fd:item value="1"/>
<fd:item value="2"/>
<fd:item value="3"/>
<fd:item value="4"/>
<fd:item value="5"/>
<fd:item value="6"/>
</fd:selection-list>
</fd:multivaluefield>
<fd:repeater id="contacts">
<fd:widgets>
<fd:field id="firstname">
<fd:label>Firstname</fd:label>
<fd:datatype base="string"/>
</fd:field>
<fd:field id="lastname">
<fd:label>Lastname</fd:label>
<fd:datatype base="string"/>
</fd:field>
<fd:booleanfield id="select">
<fd:label>Select</fd:label>
</fd:booleanfield>
</fd:widgets>
</fd:repeater>
<fd:repeater-action id="addcontact" command="add-row" repeater="contacts">
<fd:label>Add contact</fd:label>
</fd:repeater-action>
<fd:repeater-action id="removecontacts" command="delete-rows" repeater="contacts" select="select">
<fd:label>Remove selected contacts</fd:label>
</fd:repeater-action>
<fd:repeater id="contacts2">
<fd:widgets>
<fd:field id="firstname">
<fd:label>Firstname</fd:label>
<fd:datatype base="string"/>
</fd:field>
<fd:field id="lastname">
<fd:label>Lastname</fd:label>
<fd:datatype base="string"/>
</fd:field>
<fd:booleanfield id="select">
<fd:label>Select</fd:label>
</fd:booleanfield>
</fd:widgets>
</fd:repeater>
<fd:repeater-action id="addcontact2" command="add-row" repeater="contacts2">
<fd:label>Add contact</fd:label>
</fd:repeater-action>
<fd:repeater-action id="removecontacts2" command="delete-rows" repeater="contacts2" select="select">
<fd:label>Remove selected contacts</fd:label>
</fd:repeater-action>
<fd:repeater id="contacts3">
<fd:widgets>
<fd:field id="firstname">
<fd:label>Firstname</fd:label>
<fd:datatype base="string"/>
</fd:field>
<fd:field id="lastname">
<fd:label>Lastname</fd:label>
<fd:datatype base="string"/>
</fd:field>
<fd:booleanfield id="select">
<fd:label>Select</fd:label>
</fd:booleanfield>
</fd:widgets>
</fd:repeater>
<fd:repeater-action id="addcontact3" command="add-row" repeater="contacts3">
<fd:label>Add contact</fd:label>
</fd:repeater-action>
<fd:repeater-action id="removecontacts3" command="delete-rows" repeater="contacts3" select="select">
<fd:label>Remove selected contacts</fd:label>
</fd:repeater-action>
<fd:action id="show">
<fd:label>show/Active ...</fd:label>
<fd:on-action>
<fd:javascript>
var i;
for (i=1; i &lt;= 15; i++) {
widget.getForm().getChild("field_" + i).setState(org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE);
}
</fd:javascript>
</fd:on-action>
</fd:action>
<fd:action id="hide">
<fd:label>hide ...</fd:label>
<fd:on-action>
<fd:javascript>
var i;
for (i=1; i &lt;= 15; i++) {
widget.getForm().getChild("field_" + i).setState(org.apache.cocoon.forms.formmodel.WidgetState.INVISIBLE);
}
</fd:javascript>
</fd:on-action>
</fd:action>
<fd:action id="disabled">
<fd:label>disabled ...</fd:label>
<fd:on-action>
<fd:javascript>
var i;
for (i=1; i &lt;= 15; i++) {
widget.getForm().getChild("field_" + i).setState(org.apache.cocoon.forms.formmodel.WidgetState.DISABLED);
}
</fd:javascript>
</fd:on-action>
</fd:action>
</fd:widgets>
</fd:form>