You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2007/09/27 21:57:38 UTC
svn commit: r580139 [10/28] - in /cocoon/site/site/2.2: ./ blocks/
blocks/ajax/ blocks/ajax/1.0/ blocks/ajax/1.0/apidocs/ blocks/ajax/1.0/css/
blocks/ajax/1.0/images/ blocks/ajax/1.0/images/logos/ blocks/css/
blocks/forms/ blocks/forms/1.0/ blocks/form...
Added: cocoon/site/site/2.2/blocks/forms/1.0/484_1_1.html
URL: http://svn.apache.org/viewvc/cocoon/site/site/2.2/blocks/forms/1.0/484_1_1.html?rev=580139&view=auto
==============================================================================
--- cocoon/site/site/2.2/blocks/forms/1.0/484_1_1.html (added)
+++ cocoon/site/site/2.2/blocks/forms/1.0/484_1_1.html Thu Sep 27 12:56:05 2007
@@ -0,0 +1,628 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!--
+ 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.
+-->
+
+
+
+
+
+
+
+
+
+<html>
+ <head>
+ <title> Cocoon Forms
+ </title>
+ <style type="text/css" media="all">
+ @import url("./css/maven-base.css");
+ @import url("./css/maven-theme.css");
+ @import url("./css/site.css");
+ </style>
+ <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
+ <meta name="author" content="The Cocoon Community" />
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+ </head>
+ <body>
+ <div id="breadtrail">
+ <p><a href="http://www.apache.org">Apache</a> » <a href="../../../../">Cocoon</a> »</p>
+ </div>
+ <div id="top">
+ <div id="header">
+ <div class="projectlogo">
+ <a href="../../../../"><img class="logoImage"
+ src="images/cocoon_logo.jpg"
+ alt="Apache Cocoon" border="0" /></a>
+ </div>
+ <div class="grouplogo">
+ <p class="grouptitle"><a href="../../../../">The Apache Cocoon Project</a><img
+ src="images/apache-logo.jpg" alt="Cocoon Project Logo" /></p>
+ <form class="searchbox" action="http://www.google.com/search" method="get">
+ <input value="cocoon.apache.org" name="sitesearch" type="hidden" />
+ <input onFocus="getBlank (this, 'Search the site with google');" size="25" name="q" id="query" type="text" value="Search the site with google" />
+ <input class="searchboxsubmit" name="Search" value="Search" type="submit" />
+ </form>
+ </div>
+ </div>
+ <div id="projectBar">
+ <p class="cocoonHome"><a href="../../../../"><img
+ src="images/pmc-home.gif"
+ alt="Back to Apache Cocoon homepage"
+ border="0" title="Back to Apache Cocoon homepage" /></a></p>
+ <h1 class="projectTitle"><a href="../../../../"> Cocoon Forms
+ 1.0
+ </a></h1>
+ <ul class="projectList">
+ <li><strong><a href="../../../../2.2/">Cocoon 2.2</a></em></strong></li>
+ <li><a href="../../../../2.2/core-modules/">Core <span class="pl-version-small">2.2</span></a></li>
+ <li><a href="../../../../2.2/blocks/">Blocks <span class="pl-version-small">2.2</span></a></li>
+ <li><a href="../../../../2.2/maven-plugins/">Maven Plugins <span class="pl-version-small">2.2</span></a></li>
+ <li><strong><a href="../../../../subprojects/">Subprojects</a></strong></li>
+ </ul>
+ </div>
+ <div class="projectBarClear"><!-- --></div>
+ </div>
+<!-- end of top -->
+
+ <div id="content">
+ <ul id="menu">
+ <li>
+ Forms
+ <ul>
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="489_1_1.html">Basics</a>
+ </li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="477_1_1.html">Widgets</a>
+ </li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuExpand'>
+ <strong>Widget concepts</strong>
+ <ul>
+
+ <li >
+ <strong>Validation</strong>
+ </li>
+
+ <li >
+ <a href="479_1_1.html">Event Handling</a>
+ </li>
+
+ <li >
+ <a href="487_1_1.html">Datatypes</a>
+ </li>
+
+ <li >
+ <a href="753_1_1.html">Selection lists</a>
+ </li>
+
+ <li >
+ <a href="733_1_1.html">Widget States</a>
+ </li>
+ </ul>
+ </li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="755_1_1.html">Form publishing</a>
+ </li>
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="488_1_1.html">Binding</a>
+ </li>
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="498_1_1.html">API</a>
+ </li>
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="685_1_1.html">Form libraries</a>
+ </li>
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="750_1_1.html">Ajax</a>
+ </li>
+ </ul>
+ </li>
+ <li>
+ Migration guide
+ <ul>
+
+ <li >
+ <a href="1351_1_1.html">Migration guide</a>
+ </li>
+ </ul>
+ </li>
+ <li>
+ Sitemap Components
+ <ul>
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="904_1_1.html">Action</a>
+ </li>
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="915_1_1.html">Generator</a>
+ </li>
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="994_1_1.html">Transformer</a>
+ </li>
+ </ul>
+ </li>
+ <li>
+ Project Documentation
+ <ul>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="project-info.html">Project Information</a>
+ </li>
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="project-reports.html">Project Reports</a>
+ </li>
+ </ul>
+ </li>
+ </ul>
+<!--
+ <a href="http://maven.apache.org/" title="Built by Maven" id="poweredBy">
+ <img alt="Built by Maven" src="./images/logos/maven-feather.png"></img>
+ </a>
+ <div id="lastPublished">
+
+ Last Published: 26/09/2007 05:18
+ </div>
+-->
+ <div id="contentBody"><div id="bodyText"><h1 class="docTitle">Cocoon Forms: Validation</h1><h1 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">Concept</h1><p>For each widget you can define a number of widget validators. A widget
+validator can perform some checks on the widget and if these fail, set a
+validation error on the widget.</p><p>Implementation-wise, a widget validator is an object implementing the
+<tt>WidgetValidator</tt> interface
+(<a href="http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/forms/validation/WidgetValidator.html">javadoc</a>).
+</p><p>WidgetValidators can either be defined as part of the form definition (inside
+the <tt>fd:validation</tt> element) or added to a widget instance at runtime.
+The former is useful for validators that only act on the data in the form. The
+latter is useful if the validation logic needs access to other objects you have
+available in your controller.</p><p>The validation logic runs over the widget tree. For each widget first the
+child widgets are validated and then the widget itself (recursively). The
+validators on a widget are executed in the order in which they were defined or
+added. First the ones defined in the form definition are executed, then the ones
+added on the widget instance. The validation of a widget stops at the first
+validator that fails (but continues to execute for the other widgets).</p><p>For widgets having a datatype and hence a convertor (field and
+multivaluefield), the convertor could be considered to be the first validator,
+i.e. it is executed before the other validators (because those operate on the
+converted value). If the conversion fails a validation error is set on the
+widget.</p><p>Validation errors can only be set on widgets implementing the interface
+<tt>ValidationErrorAware</tt>, which currently is not implemented by all
+widgets. For example, a repeater widget does not implement ValidationErrorAware.
+However, a validator attached to a repeater could perform inter-row checks on
+the fields in the different rows of the repeater, and set validation errors on
+these fields (instead of on the repeater itself).</p><p>CForms supplies a number of default widget validators, mostly for performing
+checks on the value of field widgets. Additionally you can write your own ones
+in Java or in Javascript.</p><h1 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">Table of widgets supporting ValidationErrorAware</h1><p>These are the widgets on which you can call <tt>setValidationError</tt> (and
+<tt>getValidationError</tt>). This is relevant if you are writing your own
+validation logic.</p><table class="bodyTable">
+<tbody>
+<tr class="a">
+<th>
+<p>Widget</p>
+</th>
+<th>
+<p>Supports ValidationErrorAware</p>
+</th>
+</tr>
+<tr class="b">
+<td>
+<p>field</p>
+</td>
+<td><img alt="yes_mark" name="yes_mark" height="11" width="10" src="images/375_1_1.img"></img></td>
+</tr>
+<tr class="a">
+<td>
+<p>multivaluefield</p>
+</td>
+<td><img alt="yes_mark" name="yes_mark" height="11" width="10" src="images/375_1_1.img"></img></td>
+</tr>
+<tr class="b">
+<td>
+<p>booleanfield</p>
+</td>
+<td></td>
+</tr>
+<tr class="a">
+<td>
+<p>repeater</p>
+</td>
+<td></td>
+</tr>
+<tr class="b">
+<td>
+<p>output</p>
+</td>
+<td></td>
+</tr>
+<tr class="a">
+<td>
+<p>submit</p>
+</td>
+<td></td>
+</tr>
+<tr class="b">
+<td>
+<p>action</p>
+</td>
+<td></td>
+</tr>
+<tr class="a">
+<td>
+<p>repeater-action</p>
+</td>
+<td></td>
+</tr>
+<tr class="b">
+<td>
+<p>row-action</p>
+</td>
+<td></td>
+</tr>
+<tr class="a">
+<td>
+<p>aggregatefield</p>
+</td>
+<td><img alt="yes_mark" name="yes_mark" height="11" width="10" src="images/375_1_1.img"></img></td>
+</tr>
+<tr class="b">
+<td>
+<p>upload</p>
+</td>
+<td><img alt="yes_mark" name="yes_mark" height="11" width="10" src="images/375_1_1.img"></img></td>
+</tr>
+<tr class="a">
+<td>
+<p>messages</p>
+</td>
+<td></td>
+</tr>
+</tbody>
+</table><h1 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">Reference</h1><h2 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">General remarks</h2><p>For most widget validators, the failmessage (i.e. the message displayed to
+the user in case the validation failed) can be overridden by specifying a child
+<strong>fd:failmessage</strong> element inside the validator element. The
+failmessage can contain mixed content. Example:</p><pre><fd:field id="yourmail">
+ <fd:datatype base="string"/>
+ <fd:validation>
+ <fd:email>
+ <fd:failmessage>Not a valid email address!</fd:failmessage>
+ </fd:email>
+ </fd:validation>
+</fd:field></pre><p>To provide locale-dependent messages, use i18n tags in combination with the
+I18nTransformer.</p><p>Often the values that validators will check are specified as expressions.
+CForms uses for this the
+<a href="http://cocoondev.org/xreporter/docs/core/91.html">xReporter expression
+interpreter</a>.</p><p>Note that you cannot use each validator with each widget. Most validators
+only work with certain types of widgets, in case of field widgets often
+expecting a specific datatype. The below table shows the supported combinations
+for the default validators.</p><table class="bodyTable">
+<tbody>
+<tr class="b">
+<th>
+<p>Validator</p>
+</th>
+<th>
+<p>Allowed datatypes</p>
+</th>
+</tr>
+<tr class="a">
+<td>
+<p>fd:assert</p>
+</td>
+<td>
+<p>all datatypes</p>
+</td>
+</tr>
+<tr class="b">
+<td>
+<p>fd:email</p>
+</td>
+<td>
+<p>string</p>
+</td>
+</tr>
+<tr class="a">
+<td>
+<p>fd:length</p>
+</td>
+<td>
+<p>string</p>
+</td>
+</tr>
+<tr class="b">
+<td>
+<p>fd:mod10</p>
+</td>
+<td>
+<p>string</p>
+</td>
+</tr>
+<tr class="a">
+<td>
+<p>fd:range</p>
+</td>
+<td>
+<p>integer, long, decimal</p>
+</td>
+</tr>
+<tr class="b">
+<td>
+<p>fd:regexp</p>
+</td>
+<td>
+<p>string</p>
+</td>
+</tr>
+<tr class="a">
+<td>
+<p>fd:value-count</p>
+</td>
+<td>
+<p>all array types (use this with multivaluefield)</p>
+</td>
+</tr>
+<tr class="b">
+<td>
+<p>fd:java</p>
+</td>
+<td>
+<p>all datatypes</p>
+</td>
+</tr>
+</tbody>
+</table><h2 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">fd:assert</h2><p>Evaluates the expression specified in the "test" attribute. This expression
+should have a boolean result, it should evaluate to either true or false.
+Example: Suppose there are 2 fields widgets <tt>password</tt> and
+<tt>confirmPassword</tt>. We can use assert inside <tt>confirmPassword</tt> to
+check if is equals to <tt>password</tt> widget:</p><pre><fd:assert test="password = confirmPassword">
+ <fd:failmessage>The two passwords are not equal.</fd:failmessage>
+</fd:assert></pre><h2 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">fd:email</h2><p>Checks that a value is a valid email address. Example:</p><pre><fd:email/></pre><p>Currently this checks the email does not contain any spaces, contains exactly
+one <tt>@</tt> symbol with at least one character before it and at least one dot
+after it.</p><h2 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">fd:length</h2><p>Checks the length of strings. This validator can take 3 attributes: min, max
+and exact. You can use either of these three separately or min and max together.
+The values of these attributes are expressions. Example:</p><pre><fd:length min="2" max="4"/>
+
+Another example:
+
+<fd:length exact="2*2">
+ <fd:failmessage>Must be 4 characters long!</fd:failmessage>
+</fd:length></pre><h2 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">fd:mod10</h2><p>Uses the "mod10" algorithm used to check the validity of credit card numbers
+such as VISA. This validator does not require any additional attributes.
+Example:</p><pre><fd:mod10>
+ <fd:failmessage>Invalid credit card number.</fd:failmessage>
+</fd:mod10></pre><h2 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">fd:range</h2><p>Checks the numeric range. This validator can take 3 attributes: min, max and
+exact. You can use either of these three separately or min and max together. The
+values of these attributes are expressions. Example:</p><pre><fd:range min="2" max="4"/>
+
+Another example:
+
+<fd:range exact="2*2"/></pre><h2 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">fd:regexp</h2><p>Checks that a string matches a regular expression. It requires a "pattern"
+attribute specifying the regexp. The regular expression library used is Jakarta
+ORO, see
+<a href="http://jakarta.apache.org/oro/api/org/apache/oro/text/regex/package-summary.html">here</a>
+for some information. Example:</p><pre><fd:regexp pattern="[a-z]{3,5}">
+ <fd:failmessage>Invalid code!</fd:failmessage>
+</fd:regexp></pre><h2 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">fd:value-count</h2><p>Checks the number of items selected in a multivaluefield. Again works with
+min, max and exact attributes. Example:</p><pre><fd:value-count min="2" max="4"/>
+
+Another example:
+
+<fd:value-count exact="2"/></pre><h2 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">fd:javascript</h2><p>Allows to write a validator using Javascript, embedded directly in the form
+definition. The widget in question is available in the Javascript snippet as a
+variable called <tt>widget</tt>.</p><p>See the samples of Cocoon for an example.</p><h2 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">fd:java</h2><p>Allows to write a validator as a java class. The class must implement the the
+<tt>WidgetValidator</tt> interface
+(<a href="http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/forms/validation/WidgetValidator.html">javadoc</a>)
+and be deployed in the cocoon webapplication.</p><pre><fd:java class="com.mycompany.validators.MyCustomValidator"/>
+</pre><p>For an example, see the class
+org.apache.cocoon.forms.samples.CustomBirthDateValidator included with Cocoon.
+Please note that, as defined by the WidgetValidator contract, the custom
+validator must add a validation error to the widget; simply returning false will
+not display an error to the user.</p><p>The validator instance is part of the form definition and hence shared
+between multiple form instances. This means it should usually not keep any state
+in its instance variables.</p><p>The validator class can optionally implement Avalon interfaces such as
+LogEnabled, Serviceable and Contextualizable to get access to the logger,
+service manager and context respectively. Via the context, you can get access to
+the request object (using the ContextHelper utility class of Ccooon).</p><p>As an alternative for fd:java, you can also add validators at run time to a
+form instance, using the addValidator method on a form or widget. Since you then
+instantiate the validator yourself, you can pass it anything you want, and it
+can be stateful.</p></div><div class="editUrl"><div><em>Errors and Improvements?</em> If you see any errors or potential improvements in this document please help
+ us: <a href="http://cocoon.zones.apache.org/daisy/cdocs/484?branch=1&language=1">View, Edit or comment</a> on the latest development version (registration required).
+ </div></div></div>
+ </div>
+ <!-- end of content -->
+ <div id="footer">
+ <p>©
+ 1999-2007
+
+ The Apache Software Foundation
+ <br/>
+
+ Last Published: 26/09/2007 05:18
+</p>
+ </div>
+ <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
+ </script>
+ <script type="text/javascript">
+ _uacct = "UA-1740622-3";
+ urchinTracker();
+ </script>
+ </body>
+</html>
Added: cocoon/site/site/2.2/blocks/forms/1.0/485_1_1.html
URL: http://svn.apache.org/viewvc/cocoon/site/site/2.2/blocks/forms/1.0/485_1_1.html?rev=580139&view=auto
==============================================================================
--- cocoon/site/site/2.2/blocks/forms/1.0/485_1_1.html (added)
+++ cocoon/site/site/2.2/blocks/forms/1.0/485_1_1.html Thu Sep 27 12:56:05 2007
@@ -0,0 +1,542 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!--
+ 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.
+-->
+
+
+
+
+
+
+
+
+
+<html>
+ <head>
+ <title> Cocoon Forms
+ </title>
+ <style type="text/css" media="all">
+ @import url("./css/maven-base.css");
+ @import url("./css/maven-theme.css");
+ @import url("./css/site.css");
+ </style>
+ <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
+ <meta name="author" content="The Cocoon Community" />
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+ </head>
+ <body>
+ <div id="breadtrail">
+ <p><a href="http://www.apache.org">Apache</a> » <a href="../../../../">Cocoon</a> »</p>
+ </div>
+ <div id="top">
+ <div id="header">
+ <div class="projectlogo">
+ <a href="../../../../"><img class="logoImage"
+ src="images/cocoon_logo.jpg"
+ alt="Apache Cocoon" border="0" /></a>
+ </div>
+ <div class="grouplogo">
+ <p class="grouptitle"><a href="../../../../">The Apache Cocoon Project</a><img
+ src="images/apache-logo.jpg" alt="Cocoon Project Logo" /></p>
+ <form class="searchbox" action="http://www.google.com/search" method="get">
+ <input value="cocoon.apache.org" name="sitesearch" type="hidden" />
+ <input onFocus="getBlank (this, 'Search the site with google');" size="25" name="q" id="query" type="text" value="Search the site with google" />
+ <input class="searchboxsubmit" name="Search" value="Search" type="submit" />
+ </form>
+ </div>
+ </div>
+ <div id="projectBar">
+ <p class="cocoonHome"><a href="../../../../"><img
+ src="images/pmc-home.gif"
+ alt="Back to Apache Cocoon homepage"
+ border="0" title="Back to Apache Cocoon homepage" /></a></p>
+ <h1 class="projectTitle"><a href="../../../../"> Cocoon Forms
+ 1.0
+ </a></h1>
+ <ul class="projectList">
+ <li><strong><a href="../../../../2.2/">Cocoon 2.2</a></em></strong></li>
+ <li><a href="../../../../2.2/core-modules/">Core <span class="pl-version-small">2.2</span></a></li>
+ <li><a href="../../../../2.2/blocks/">Blocks <span class="pl-version-small">2.2</span></a></li>
+ <li><a href="../../../../2.2/maven-plugins/">Maven Plugins <span class="pl-version-small">2.2</span></a></li>
+ <li><strong><a href="../../../../subprojects/">Subprojects</a></strong></li>
+ </ul>
+ </div>
+ <div class="projectBarClear"><!-- --></div>
+ </div>
+<!-- end of top -->
+
+ <div id="content">
+ <ul id="menu">
+ <li>
+ Forms
+ <ul>
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="489_1_1.html">Basics</a>
+ </li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="477_1_1.html">Widgets</a>
+ </li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="484_1_1.html">Widget concepts</a>
+ </li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuExpand'>
+ <a href="755_1_1.html">Form publishing</a>
+ <ul>
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="755_1_1.html">Templating</a>
+ </li>
+
+ <li >
+ <a href="476_1_1.html">Generator</a>
+ </li>
+
+ <li >
+ <strong>XSLT</strong>
+ </li>
+
+ <li >
+ <a href="1147_1_1.html">CSS</a>
+ </li>
+ </ul>
+ </li>
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="488_1_1.html">Binding</a>
+ </li>
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="498_1_1.html">API</a>
+ </li>
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="685_1_1.html">Form libraries</a>
+ </li>
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="750_1_1.html">Ajax</a>
+ </li>
+ </ul>
+ </li>
+ <li>
+ Migration guide
+ <ul>
+
+ <li >
+ <a href="1351_1_1.html">Migration guide</a>
+ </li>
+ </ul>
+ </li>
+ <li>
+ Sitemap Components
+ <ul>
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="904_1_1.html">Action</a>
+ </li>
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="915_1_1.html">Generator</a>
+ </li>
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="994_1_1.html">Transformer</a>
+ </li>
+ </ul>
+ </li>
+ <li>
+ Project Documentation
+ <ul>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="project-info.html">Project Information</a>
+ </li>
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="project-reports.html">Project Reports</a>
+ </li>
+ </ul>
+ </li>
+ </ul>
+<!--
+ <a href="http://maven.apache.org/" title="Built by Maven" id="poweredBy">
+ <img alt="Built by Maven" src="./images/logos/maven-feather.png"></img>
+ </a>
+ <div id="lastPublished">
+
+ Last Published: 26/09/2007 05:18
+ </div>
+-->
+ <div id="contentBody"><div id="bodyText"><h1 class="docTitle">XSLT</h1><h1 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">Intro</h1><p>This page contains information on the default XSLT's provided by CForms, and
+the fi:styling directives they support.</p><p>As specified in <a href="755_1_1.html">templating mechanism</a> (be sure to read
+about it), the form template file is transformed in a form instance xml file.
+This file contains all the data needed to properly display a form. An XSLT must
+then be used to transform the form instance to an HTML to be displayed in a
+browser.</p><p>This XSLT does not need to create also all the page layout (that can be added
+by other XSLT, or aggregating the form with other markup), it should only format
+the forms field and the form layout.</p><p>Cocoon forms already a set of XSLTs that does exactly this, they are
+"library" stylesheets :</p><ul>
+<li><tt>forms-field-styling.xsl</tt>: contains templates that style individual
+widgets, i.e. templates that translate fi:field, fi:booleanfield fi:action, etc.
+to HTML.</li>
+<li><tt>forms-page-styling.xsl</tt>: contains templates for building high-level
+page layout effects, such as tabbed panes.</li>
+<li><tt>forms-advanced-field-styling.xsl</tt>: contains templates that provide
+advanced styling of fields, e.g. the "double-listbox" for a multivaluefield.
+It's indeed an extension of the above basic <tt>forms-field-styling.xsl</tt>.
+Furthermore it includes the next stylesheet.</li>
+<li><tt>forms-calendar-styling.xsl</tt>: contains the styling of a field with
+type "date" and provides a visual calendar for easy selection of date. So the
+calendar is an advanced styling too, but because it has much specific stuff we
+separated it out of <tt>forms-advanced-styling.xsl</tt>.</li>
+<li><tt>forms-htmlarea-styling.xsl</tt>: contains the styling for the html edit
+field.</li>
+</ul>If you have a look at samples, you'll see also another XSLT,
+<tt>forms-samples-styling.xsl</tt>. This stylesheet includes other two
+stylesheets from the default set. Usually, you will make a clone of this
+stylesheet for your own project, have it include the library XSLTs, and
+customize what you need by writing templates in this XSLT by giving templates
+higher priority than those in the library ones.From the sitemap you only need to reference only your custom XSLT, for
+example as follows:<pre><map:transform src="context://forms/resources/myproject-forms-styling.xsl"/></pre><h1 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">fi:styling options</h1>The fi:styling elements are specified in the template, and offer a way to
+customize the way the library XSLTs render widgets. For example :<pre><ft:widget id="preferredBeer">
+ <fi:styling list-type="radio"/>
+</ft:widget>
+</pre>The fi:styling options for the different widgets are documented in the
+respective sections about those widgets.<h1 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">High-level styling with fi:group</h1>It's quite common to want to layout the form. For example, have part of the
+form displayed in a table with two columns, one with labels the other one with
+actual fields, while in another part have a single colum with labels followed by
+fields, and in another part some tabs to group together fields.<p>We could do this simply writing HTML in the template file, but this is
+verbose, non reusable, and not easy to style. That's why fi:groups are there.
+You can layout your form with fi:groups in a simple, efficient, extensible and
+easy to style way. For example :</p><pre><ft:form-template .... >
+ <fi:group>
+ <fi:styling layout="columns">
+ <fi:items>
+ <ft:widget id="name"/>
+ <ft:widget id="surname"/>
+ <ft:widget id="birthday"/>
+ </fi:items>
+ </fi:group>
+</ft:form-template>
+</pre><p>Will produce a table with two columns, like the following :</p><table class="bodyTable">
+<tbody>
+<tr class="a">
+<td>
+<p>Name</p>
+</td>
+<td>
+<p>[_______]</p>
+</td>
+</tr>
+<tr class="b">
+<td>
+<p>Surname</p>
+</td>
+<td>
+<p>[_______]</p>
+</td>
+</tr>
+<tr class="a">
+<td>
+<p>Birthday</p>
+</td>
+<td>
+<p>[_______]</p>
+</td>
+</tr>
+</tbody>
+</table><p>The <tt>fi:group</tt> accept either a <tt>layout</tt> or a <tt>type</tt>
+attribute in its <tt>fi:styling</tt> element to specify the layout we want. This
+difference is because the "layout based" groups are quite lightweight, while the
+"type based" groups are more sophisticated and usually contains other groups.
+</p><h2 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">Layout groups</h2><p><tt><fi:group layout="column"></tt> will format its items in a single
+column. One row will contain the label, the following row the input field.</p><p><tt><fi:group layout="columns"></tt> will format its items in two
+columns. For each item a row is created, the first column will contain the
+label, and the second column the input field.</p><p><tt><fi:group layout="row"></tt> will format its items in a single row.
+One cell will contain the label, the following cell the input field.</p><p><tt><fi:group layout="rows"></tt> will format its items in two rows.
+The first row will contain all the labels, one each cell, the second row all the
+input fields, again one each cell.</p><p>Some input fields will have a special layout when inside a certain group :
+</p><ul>
+<li><tt>action</tt>, <tt>submit</tt> and <tt>boolanfield</tt> widgets does not
+have a "label" which can be displayed separated from the button or checkbox
+itself, so they will be placed</li>
+<ul>
+<li>in a single line inside the <tt>column</tt> and <tt>columns</tt> layout</li>
+<li>using only one cell in <tt>row</tt> layout</li>
+<li>using an empty cell in the first row of a <tt>rows</tt> layout</li>
+</ul>
+
+<li><tt>multivaluefield</tt> with a <tt><tt>list-type="double-listbox"</tt></tt>
+will be displayed with a row with a label and another row with the two lists
+when in a <tt>columns</tt> group.</li>
+<li>every other <tt>fi:group</tt> nested inside a <tt>fi:group</tt> with layout
+<tt>columns</tt> will span on both columns</li>
+</ul>Also layout <tt>fi:group</tt> can contain other <tt>fi:group</tt> between
+their items, and can be used to create quite complex layouts.<h2 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">Type groups</h2>There are currently two "type" groups : <tt>tabs</tt> and <tt>choice.</tt>
+The tabs group will display some tabs, every tab is (usually) a fi:group. For
+example :<pre><fi:group>
+ <fi:styling type="tabs"/>
+ <fi:items>
+ <fi:group>
+ <fi:label>Personal info</fi:label>
+ <fi:styling layout="columns"/>
+ <fi:items>
+ <ft:widget id="name"/>
+ <ft:widget id="surname"/>
+ </fi:items>
+ </fi:group>
+ <fi:group>
+ <fi:label>Iternet data</fi:label>
+ <fi:styling layout="columns"/>
+ <fi:items>
+ <ft:widget id="email"/>
+ <ft:widget id="icqaccount"/>
+ </fi:items>
+ </fi:group>
+ </fi:items>
+</fi:group></pre>Will display two tabs, one called "Personal info" and the other one "Internet
+data". When the user clicks on "Personal info" the field name and surname will
+be displayed, while when the user clicks on "Internet data" the field email and
+icqaccount will be displayed.You can specify a widget that will be used to store and retrieve which tab is
+curently active. This way you can control from the flow which tab will be active
+when the form will be displayed, or check which tab was active when the user
+submitted the form. To specify this special field use :<pre><fi:group>
+ <fi:styling type="tabs"/>
+ <fi:state>
+ <ft:widget id="activetab"/>
+ </fi:state>
+ ....
+</fi:group></pre>Obviously you can call the widget whatever you want, and the suggested
+datatype is integer, since the field will contain a number indicating the active
+tab, the field must be declared in the definition, and can be used in binding if
+needed. For example :<pre><fd:field id="activetab">
+ <fd:datatype base="integer"/>
+</fd:field></pre><p>The group of type <tt>choice </tt>is identical to the <tt>tabs</tt> group,
+but instead of a row of tabs, a drop down is displayed, and selecting one
+element of the drop down will display the relative group.</p><p>You can specify a client side javascript that will be executed when a tab is
+clicked or when an option of the <tt>choice</tt> drop down is selected. This is
+done simply adding an attribute to the items of the group, for example :</p><pre><fi:group>
+ <fi:styling type="tabs"/>
+ <fi:items>
+ <fi:group formsOnShow="personalSelected()">
+ <fi:label>Personal info</fi:label>
+ ...
+ </fi:group>
+ <fi:group formsOnShow="internetSelected()">
+ <fi:label>Iternet data</fi:label>
+ ...
+ </fi:group>
+ </fi:items>
+</fi:group></pre><p>Have a look at <tt>forms-page-styling.xsl</tt> , all <tt>fi:groups</tt> are
+formatted there.</p><h1 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">Miscellaneous</h1><h2 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">fi:validation-errors</h2><p>The <tt>fi:validation-errors</tt> tag is used to display all validation
+errors of all widgets in a form at one location, i.e. a the top of the form.</p><p>The fi:validation-errors tag must be a child of a ft:form-template element.
+</p><p>You can customise a message to be shown before and after the errors by adding
+a child header and/or footer element:</p><pre><fi:validation-errors>
+ <header><p>Correct these errors please:</p></header>
+ <footer><p>And then resubmit the form.</p></footer>
+</fi:validation-errors></pre></div><div class="editUrl"><div><em>Errors and Improvements?</em> If you see any errors or potential improvements in this document please help
+ us: <a href="http://cocoon.zones.apache.org/daisy/cdocs/485?branch=1&language=1">View, Edit or comment</a> on the latest development version (registration required).
+ </div></div></div>
+ </div>
+ <!-- end of content -->
+ <div id="footer">
+ <p>©
+ 1999-2007
+
+ The Apache Software Foundation
+ <br/>
+
+ Last Published: 26/09/2007 05:18
+</p>
+ </div>
+ <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
+ </script>
+ <script type="text/javascript">
+ _uacct = "UA-1740622-3";
+ urchinTracker();
+ </script>
+ </body>
+</html>
Added: cocoon/site/site/2.2/blocks/forms/1.0/486_1_1.html
URL: http://svn.apache.org/viewvc/cocoon/site/site/2.2/blocks/forms/1.0/486_1_1.html?rev=580139&view=auto
==============================================================================
--- cocoon/site/site/2.2/blocks/forms/1.0/486_1_1.html (added)
+++ cocoon/site/site/2.2/blocks/forms/1.0/486_1_1.html Thu Sep 27 12:56:05 2007
@@ -0,0 +1,461 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!--
+ 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.
+-->
+
+
+
+
+
+
+
+
+
+<html>
+ <head>
+ <title> Cocoon Forms
+ </title>
+ <style type="text/css" media="all">
+ @import url("./css/maven-base.css");
+ @import url("./css/maven-theme.css");
+ @import url("./css/site.css");
+ </style>
+ <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
+ <meta name="author" content="The Cocoon Community" />
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+ </head>
+ <body>
+ <div id="breadtrail">
+ <p><a href="http://www.apache.org">Apache</a> » <a href="../../../../">Cocoon</a> »</p>
+ </div>
+ <div id="top">
+ <div id="header">
+ <div class="projectlogo">
+ <a href="../../../../"><img class="logoImage"
+ src="images/cocoon_logo.jpg"
+ alt="Apache Cocoon" border="0" /></a>
+ </div>
+ <div class="grouplogo">
+ <p class="grouptitle"><a href="../../../../">The Apache Cocoon Project</a><img
+ src="images/apache-logo.jpg" alt="Cocoon Project Logo" /></p>
+ <form class="searchbox" action="http://www.google.com/search" method="get">
+ <input value="cocoon.apache.org" name="sitesearch" type="hidden" />
+ <input onFocus="getBlank (this, 'Search the site with google');" size="25" name="q" id="query" type="text" value="Search the site with google" />
+ <input class="searchboxsubmit" name="Search" value="Search" type="submit" />
+ </form>
+ </div>
+ </div>
+ <div id="projectBar">
+ <p class="cocoonHome"><a href="../../../../"><img
+ src="images/pmc-home.gif"
+ alt="Back to Apache Cocoon homepage"
+ border="0" title="Back to Apache Cocoon homepage" /></a></p>
+ <h1 class="projectTitle"><a href="../../../../"> Cocoon Forms
+ 1.0
+ </a></h1>
+ <ul class="projectList">
+ <li><strong><a href="../../../../2.2/">Cocoon 2.2</a></em></strong></li>
+ <li><a href="../../../../2.2/core-modules/">Core <span class="pl-version-small">2.2</span></a></li>
+ <li><a href="../../../../2.2/blocks/">Blocks <span class="pl-version-small">2.2</span></a></li>
+ <li><a href="../../../../2.2/maven-plugins/">Maven Plugins <span class="pl-version-small">2.2</span></a></li>
+ <li><strong><a href="../../../../subprojects/">Subprojects</a></strong></li>
+ </ul>
+ </div>
+ <div class="projectBarClear"><!-- --></div>
+ </div>
+<!-- end of top -->
+
+ <div id="content">
+ <ul id="menu">
+ <li>
+ Forms
+ <ul>
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="489_1_1.html">Basics</a>
+ </li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuExpand'>
+ <a href="477_1_1.html">Widgets</a>
+ <ul>
+
+ <li >
+ <a href="477_1_1.html">Action widget</a>
+ </li>
+
+ <li >
+ <strong>Aggregatefield widget</strong>
+ </li>
+
+ <li >
+ <a href="482_1_1.html">Booleanfield widget</a>
+ </li>
+
+ <li >
+ <a href="1161_1_1.html">Calculated fields</a>
+ </li>
+
+ <li >
+ <a href="1294_1_1.html">Captcha Widget</a>
+ </li>
+
+ <li >
+ <a href="742_1_1.html">Class/New (not really widgets)</a>
+ </li>
+
+ <li >
+ <a href="481_1_1.html">Field widget</a>
+ </li>
+
+ <li >
+ <a href="754_1_1.html">Form</a>
+ </li>
+
+ <li >
+ <a href="740_1_1.html">Group/Struct widget</a>
+ </li>
+
+ <li >
+ <a href="738_1_1.html">ImageMap widget</a>
+ </li>
+
+ <li >
+ <a href="497_1_1.html">Messages widget</a>
+ </li>
+
+ <li >
+ <a href="490_1_1.html">MultiValueField widget</a>
+ </li>
+
+ <li >
+ <a href="492_1_1.html">Output widget</a>
+ </li>
+
+ <li >
+ <a href="494_1_1.html">RepeaterAction widget</a>
+ </li>
+
+ <li >
+ <a href="496_1_1.html">Repeater widget</a>
+ </li>
+
+ <li >
+ <a href="495_1_1.html">RowAction widget</a>
+ </li>
+
+ <li >
+ <a href="493_1_1.html">Submit widget</a>
+ </li>
+
+ <li >
+ <a href="739_1_1.html">Tree widget</a>
+ </li>
+
+ <li >
+ <a href="741_1_1.html">Union widget</a>
+ </li>
+
+ <li >
+ <a href="483_1_1.html">Upload widget</a>
+ </li>
+ </ul>
+ </li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="484_1_1.html">Widget concepts</a>
+ </li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="755_1_1.html">Form publishing</a>
+ </li>
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="488_1_1.html">Binding</a>
+ </li>
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="498_1_1.html">API</a>
+ </li>
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="685_1_1.html">Form libraries</a>
+ </li>
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="750_1_1.html">Ajax</a>
+ </li>
+ </ul>
+ </li>
+ <li>
+ Migration guide
+ <ul>
+
+ <li >
+ <a href="1351_1_1.html">Migration guide</a>
+ </li>
+ </ul>
+ </li>
+ <li>
+ Sitemap Components
+ <ul>
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="904_1_1.html">Action</a>
+ </li>
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="915_1_1.html">Generator</a>
+ </li>
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="994_1_1.html">Transformer</a>
+ </li>
+ </ul>
+ </li>
+ <li>
+ Project Documentation
+ <ul>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="project-info.html">Project Information</a>
+ </li>
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="project-reports.html">Project Reports</a>
+ </li>
+ </ul>
+ </li>
+ </ul>
+<!--
+ <a href="http://maven.apache.org/" title="Built by Maven" id="poweredBy">
+ <img alt="Built by Maven" src="./images/logos/maven-feather.png"></img>
+ </a>
+ <div id="lastPublished">
+
+ Last Published: 26/09/2007 05:18
+ </div>
+-->
+ <div id="contentBody"><div id="bodyText"><h1 class="docTitle">Aggregatefield widget</h1><h1 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">Concept</h1><p>An aggregated field allows to represent one value as multiple input fields,
+or several values as one field. Hence this widget is a field and a container
+widget simultaneously.</p><p>Upon submit, it first attempts to read own value from the request, and splits
+over nested field widgets using a regular expression. If split fails, this will
+simply give a validation error. If own value was not submitted, it attempts to
+read values for nested field widgets, and combines theirs values using combine
+expression.</p><p>To validate this widget, both the validation rules of the nested widgets are
+checked, and those of the aggregated field themselves. The validation rules of
+the aggregated field can perform checks on the string as entered by the user
+(e.g. check its total length).</p><p>This field and nested fields can be of any supported type, as long as combine
+expression gives result of the correct type, and split regular expression can
+split string representation into parts which can be converted to the values of
+nested fields.</p><h1 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">Definition</h1><pre><fd:aggregatefield id="..." state="...">
+ <fd:widgets>
+ <fd:field .../>
+ [... more fd:field elements ...]
+ </fd:widgets>
+ <fd:split pattern="...">
+ <fd:map group="..." field="..."/>
+ [... more fd:map elements ...]
+ <fd:failmessage>...</fd:failmessage>
+ </fd:split>
+ <fd:combine expression="..."/>
+ <fd:on-create>
+ [...]
+ </fd:on-create>
+ <fd:attributes>
+ <fd:attribute name="..." value="..."/>
+ </fd:attributes>
+</fd:aggregatefield>
+</pre></div><div class="editUrl"><div><em>Errors and Improvements?</em> If you see any errors or potential improvements in this document please help
+ us: <a href="http://cocoon.zones.apache.org/daisy/cdocs/486?branch=1&language=1">View, Edit or comment</a> on the latest development version (registration required).
+ </div></div></div>
+ </div>
+ <!-- end of content -->
+ <div id="footer">
+ <p>©
+ 1999-2007
+
+ The Apache Software Foundation
+ <br/>
+
+ Last Published: 26/09/2007 05:18
+</p>
+ </div>
+ <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
+ </script>
+ <script type="text/javascript">
+ _uacct = "UA-1740622-3";
+ urchinTracker();
+ </script>
+ </body>
+</html>
Added: cocoon/site/site/2.2/blocks/forms/1.0/487_1_1.html
URL: http://svn.apache.org/viewvc/cocoon/site/site/2.2/blocks/forms/1.0/487_1_1.html?rev=580139&view=auto
==============================================================================
--- cocoon/site/site/2.2/blocks/forms/1.0/487_1_1.html (added)
+++ cocoon/site/site/2.2/blocks/forms/1.0/487_1_1.html Thu Sep 27 12:56:05 2007
@@ -0,0 +1,588 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!--
+ 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.
+-->
+
+
+
+
+
+
+
+
+
+<html>
+ <head>
+ <title> Cocoon Forms
+ </title>
+ <style type="text/css" media="all">
+ @import url("./css/maven-base.css");
+ @import url("./css/maven-theme.css");
+ @import url("./css/site.css");
+ </style>
+ <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
+ <meta name="author" content="The Cocoon Community" />
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+ </head>
+ <body>
+ <div id="breadtrail">
+ <p><a href="http://www.apache.org">Apache</a> » <a href="../../../../">Cocoon</a> »</p>
+ </div>
+ <div id="top">
+ <div id="header">
+ <div class="projectlogo">
+ <a href="../../../../"><img class="logoImage"
+ src="images/cocoon_logo.jpg"
+ alt="Apache Cocoon" border="0" /></a>
+ </div>
+ <div class="grouplogo">
+ <p class="grouptitle"><a href="../../../../">The Apache Cocoon Project</a><img
+ src="images/apache-logo.jpg" alt="Cocoon Project Logo" /></p>
+ <form class="searchbox" action="http://www.google.com/search" method="get">
+ <input value="cocoon.apache.org" name="sitesearch" type="hidden" />
+ <input onFocus="getBlank (this, 'Search the site with google');" size="25" name="q" id="query" type="text" value="Search the site with google" />
+ <input class="searchboxsubmit" name="Search" value="Search" type="submit" />
+ </form>
+ </div>
+ </div>
+ <div id="projectBar">
+ <p class="cocoonHome"><a href="../../../../"><img
+ src="images/pmc-home.gif"
+ alt="Back to Apache Cocoon homepage"
+ border="0" title="Back to Apache Cocoon homepage" /></a></p>
+ <h1 class="projectTitle"><a href="../../../../"> Cocoon Forms
+ 1.0
+ </a></h1>
+ <ul class="projectList">
+ <li><strong><a href="../../../../2.2/">Cocoon 2.2</a></em></strong></li>
+ <li><a href="../../../../2.2/core-modules/">Core <span class="pl-version-small">2.2</span></a></li>
+ <li><a href="../../../../2.2/blocks/">Blocks <span class="pl-version-small">2.2</span></a></li>
+ <li><a href="../../../../2.2/maven-plugins/">Maven Plugins <span class="pl-version-small">2.2</span></a></li>
+ <li><strong><a href="../../../../subprojects/">Subprojects</a></strong></li>
+ </ul>
+ </div>
+ <div class="projectBarClear"><!-- --></div>
+ </div>
+<!-- end of top -->
+
+ <div id="content">
+ <ul id="menu">
+ <li>
+ Forms
+ <ul>
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="489_1_1.html">Basics</a>
+ </li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="477_1_1.html">Widgets</a>
+ </li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuExpand'>
+ <a href="484_1_1.html">Widget concepts</a>
+ <ul>
+
+ <li >
+ <a href="484_1_1.html">Validation</a>
+ </li>
+
+ <li >
+ <a href="479_1_1.html">Event Handling</a>
+ </li>
+
+ <li >
+ <strong>Datatypes</strong>
+ </li>
+
+ <li >
+ <a href="753_1_1.html">Selection lists</a>
+ </li>
+
+ <li >
+ <a href="733_1_1.html">Widget States</a>
+ </li>
+ </ul>
+ </li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="755_1_1.html">Form publishing</a>
+ </li>
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="488_1_1.html">Binding</a>
+ </li>
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="498_1_1.html">API</a>
+ </li>
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="685_1_1.html">Form libraries</a>
+ </li>
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="750_1_1.html">Ajax</a>
+ </li>
+ </ul>
+ </li>
+ <li>
+ Migration guide
+ <ul>
+
+ <li >
+ <a href="1351_1_1.html">Migration guide</a>
+ </li>
+ </ul>
+ </li>
+ <li>
+ Sitemap Components
+ <ul>
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="904_1_1.html">Action</a>
+ </li>
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="915_1_1.html">Generator</a>
+ </li>
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="994_1_1.html">Transformer</a>
+ </li>
+ </ul>
+ </li>
+ <li>
+ Project Documentation
+ <ul>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="project-info.html">Project Information</a>
+ </li>
+
+
+
+
+
+
+
+
+
+ <li class='menuCollapse'>
+ <a href="project-reports.html">Project Reports</a>
+ </li>
+ </ul>
+ </li>
+ </ul>
+<!--
+ <a href="http://maven.apache.org/" title="Built by Maven" id="poweredBy">
+ <img alt="Built by Maven" src="./images/logos/maven-feather.png"></img>
+ </a>
+ <div id="lastPublished">
+
+ Last Published: 26/09/2007 05:18
+ </div>
+-->
+ <div id="contentBody"><div id="bodyText"><h1 class="docTitle">Cocoon Forms: Datatypes</h1><h1 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">Context</h1><p>Datatypes are used by certain widgets, more specifically the
+<a href="481_1_1.html">field</a> and <a href="490_1_1.html">multivaluefield</a>
+widgets, to allow them to edit different types of data (e.g. strings, numbers,
+dates). For a general introduction of the relationship between the widget and
+the datatype, see the documentation of the <a href="481_1_1.html">field</a>
+widget.</p><h1 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">General information</h1><p>In its most basic form a datatype is declared as follows:</p><pre><fd:datatype base="..."></pre><p>The <strong>base</strong> attribute refers to one of the built-in datatypes
+such as string or long.</p><h2 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">Convertors</h2><p>A datatype needs a convertor. The purpose of a convertor is to convert
+between string and object representations of values. There is always a default
+convertor, but you change or configure that using the fd:convertor element.
+Here's an example for dates:</p><pre><fd:datatype base="date">
+ <fd:convertor type="formatting">
+ <fd:patterns>
+ <fd:pattern>dd/MM/yyyy</fd:pattern>
+ </fd:patterns>
+ </fd:convertor>
+</fd:datatype></pre><p>The <strong>type</strong> attribute on the fd:convertor element is optional,
+if not specified the default one will be used (configured in the cocoon.xconf).
+Any further content of the fd:convertor element is specific to the convertor
+implementation and will be documented in a seperate section.</p><h1 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">Available datatypes</h1><table class="bodyTable">
+<tbody>
+<tr class="a">
+<th>
+<p>CForms datatype</p>
+</th>
+<th>
+<p>Java class</p>
+</th>
+<th>
+<p>Convertors</p>
+</th>
+</tr>
+<tr class="b">
+<td>
+<p>string</p>
+</td>
+<td>
+<p>java.lang.String</p>
+</td>
+<td>
+<p>Strings obviously don't support any convertors, since there's no purpose in
+converting a string to a string.</p>
+</td>
+</tr>
+<tr class="a">
+<td>
+<p>decimal</p>
+</td>
+<td>
+<p>java.math.BigDecimal</p>
+</td>
+<td>
+<p><a href="#decimalformatting">formatting (decimal)</a>,
+<a href="#plain">plain</a></p>
+</td>
+</tr>
+<tr class="b">
+<td>
+<p>integer</p>
+</td>
+<td>
+<p>java.lang.Integer</p>
+</td>
+<td>
+<p>similar as decimal datatype</p>
+</td>
+</tr>
+<tr class="a">
+<td>
+<p>long</p>
+</td>
+<td>
+<p>java.lang.Long</p>
+</td>
+<td>
+<p>similar as decimal datatype</p>
+</td>
+</tr>
+<tr class="b">
+<td>
+<p>double</p>
+</td>
+<td>
+<p>java.lang.Double</p>
+</td>
+<td>
+<p>similar as decimal datatype</p>
+</td>
+</tr>
+<tr class="a">
+<td>
+<p>date</p>
+</td>
+<td>
+<p>java.util.Date</p>
+</td>
+<td>
+<p><a href="#dateformatting">formatting (date)</a>, <a href="#millis">millis</a>
+</p>
+</td>
+</tr>
+<tr class="b">
+<td>
+<p>enum</p>
+</td>
+<td>
+<p>Enumerated type</p>
+</td>
+<td>
+<p><a href="#enum">enum</a></p>
+</td>
+</tr>
+<tr class="a">
+<td>
+<p>char</p>
+</td>
+<td>
+<p>java.lang.Char</p>
+</td>
+<td>
+<p>only the default char convertor</p>
+</td>
+</tr>
+</tbody>
+</table><h2 id="enum" xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">Enumerated datatype</h2><p>The <strong>enum</strong> datatype is meant to be used with types
+implementing Joshua Bloch's
+<a href="http://developer.java.sun.com/developer/Books/shiftintojava/page1.html#replaceenums">typesafe
+enum pattern</a>. The following is a possible implementation:</p><pre>package com.example;
+
+public class Sex {
+
+ public static final Sex MALE = new Sex("M");
+ public static final Sex FEMALE = new Sex("F");
+ private String code;
+
+ private Sex(String code) { this.code = code; }
+}</pre><p>The following snippet shows the usage of this type:</p><pre><fd:field id="sex">
+ <fd:label>Sex</fd:label>
+ <fd:datatype base="enum">
+ <fd:convertor type="enum">
+ <fd:enum>com.example.Sex</fd:enum>
+ </fd:convertor>
+ </fd:datatype>
+ <fd:selection-list type="enum" class="com.example.Sex"/>
+</fd:field></pre><p>If your enumerated type does not provide a <tt>toString()</tt> method, the
+enum convertor will use the fully qualified class name, followed by the name of
+the <tt>public static final</tt> field referring to each instance, i.e.
+"<tt>com.example.Sex.MALE</tt>", "<tt>com.example.Sex.FEMALE</tt>" and so on.
+</p><p>If you provide a <tt>toString()</tt> method which returns something
+different, you should also provide a <tt>fromString(String, Locale)</tt> method
+to convert those strings back to instances.</p><p>The enum datatype is typically used together with the
+<a href="753_1_1.html"><strong>enum</strong> selection list type</a>.</p><h1 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">Available convertors</h1><h2 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">Decimal convertors</h2><p>Numeric or decimal types can be formatted in two ways: plain and formatted.
+The first is very simple, the second provides locale-dependent formatting.</p><h3 id="plain" xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">plain</h3><p>This convertor is not locale-dependent. It shows the full precision of the
+number and uses dot as the decimal separator.</p><p>Configuration example:</p><pre><fd:datatype base="decimal">
+ <fd:convertor type="plain"/>
+</fd:datatype></pre><p>Output of this field with a value of <em>1234.5678</em> would be</p><pre>1234.5678
+</pre><h3 id="decimalformatting" xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">formatting (decimal)</h3><p>This convertor uses the <tt>java.text.DecimalFormat</tt> class (or
+<tt>com.ibm.icu.text.DecimalFormat</tt> class if it is present in the
+classpath). This means it can perform locale-dependent, pattern-based formatting
+of numbers.</p><p>Configuration pseudo-schema:</p><pre><fd:convertor type="formatting" variant="integer|number|currency|percent" ? >
+ <fd:patterns>
+ <fd:pattern>....</fd:pattern> ?
+ <fd:pattern locale="lang-COUNTRY">....</fd:pattern> *
+ </fd:patterns> ?
+</fd:convertor></pre><p>The variant attribute and patterns element are optional. By default, the
+"number" variant is used (or for longs: the "integer" variant).</p><p>You can supply either a locale-independent formatting pattern or
+locale-dependent formatting patterns. See the
+<a href="http://java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormat.html">javadoc
+of the DecimalFormat class</a> for the supported pattern syntax. CForms will
+always use the pattern that is most specific for the current locale.</p><p>Example:</p><pre><fd:datatype base="decimal">
+ <fd:convertor type="formatting">
+ <fd:patterns>
+ <fd:pattern locale="en-US">#,###.##</fd:pattern>
+ <fd:pattern locale="nl-NL">####,####</fd:pattern>
+ </fd:patterns>
+ </fd:convertor>
+</fd:datatype>
+</pre><p>Output of this field with a value of <em>1234.5612</em> would be</p><p>With locale = en-US: 1,234.56</p><p>With locale = nl-NL: 1234,5612</p><h2 xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">Date convertors</h2><p>The date datatype can be used both for dates as times. The date datatype
+supports the following convertors:</p><h3 id="dateformatting" xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">formatting (date)</h3><p>This convertor uses the <tt>java.text.SimpleDateFormat</tt> class (or
+<tt>com.ibm.icu.text.SimpleDateFormat</tt> class if it is present in the
+classpath). This means it can perform locale-dependent, pattern-based formatting
+of dates.</p><p>Configuration pseudo-schema:</p><pre><fd:convertor type="formatting" variant="date|time|datetime" ?
+ style="short|medium|long|full" ?
+ timeStyle="short|medium|long|full" ?
+ lenient="true|false" ?>
+ <fd:patterns>
+ <fd:pattern>....</fd:pattern> ?
+ <fd:pattern locale="lang-COUNTRY">....</fd:pattern> *
+ </fd:patterns> ?
+</fd:convertor></pre><p>Usually you will use either the variant and style attributes or the
+pattern(s).</p><p>For example, the following convertor configuration:</p><pre><fd:convertor type="formatting" variant="date" style="short"></pre><p>Will give the following for July 15, 2003: 7/15/03. Using style medium it
+gives "Jul 15, 2003", style long gives "July 15, 2003", and style full gives
+"Tuesday, July 15, 2003". These result are locale-dependent of course. By
+default the value of the style attribute applies to both the date and time
+components, but you can specify a different style preference for times using the
+timeStyle attribute.</p><p>Here's an example of using a formatting pattern:</p><pre><fd:convertor type="formatting">
+ <fd:patterns>
+ <fd:pattern>dd/MM/yyyy</fd:pattern>
+ </fd:patterns>
+</fd:convertor></pre><p>Using the same date, this will now give "15/07/2003".</p><p>It is also possible to use different patterns for different locales by using
+multiple fd:pattern elements with "locale" attributes, for example:</p><pre><fd:convertor type="formatting">
+ <fd:patterns>
+ <fd:pattern>MM/dd/yyyy</fd:pattern>
+ <fd:pattern locale="nl-BE">dd/MM/yyyy</fd:pattern>
+ <fd:pattern locale="fr">dd-MM-yyyy</fd:pattern>
+ </fd:patterns>
+</fd:convertor></pre><p>In this case, if the locale is "nl-BE", the second pattern will be used; if
+the locale is "en", the first pattern will be used; and if the locale is "fr-BE"
+the third pattern will be used (because when fr-BE is not found, it will first
+search for "fr" before using the locale-indepent pattern).</p><p>The "lenient" attribute governs whether date parsing is lenient or not. The
+default is lenient, which means that the convertor will try to convert a
+somewhat invalid date like "Dec. 32, 2005" into "Jan. 1, 2006". If the value of
+the "lenient" attribute is false, such a date won't validate.</p><div class="note"><div><strong>Note: </strong>Note that when binding XML documents you can also specify the
+final pattern in which the date is stored. More information can be found on the
+<a href="488_1_1.html">binding framework</a> page. The same holds true
+for numbers.</div></div><h3 id="millis" xmlns:p="http://outerx.org/daisy/1.0#publisher" xmlns:ns="http://outerx.org/daisy/1.0">millis</h3><p>The millis convertor for dates uses the number of milliseconds since January
+1, 1970, 00:00:00 GMT as string representation. This will likely not be used to
+present dates to the user, but may be useful in selection lists retrieved from
+external sources.</p></div><div class="editUrl"><div><em>Errors and Improvements?</em> If you see any errors or potential improvements in this document please help
+ us: <a href="http://cocoon.zones.apache.org/daisy/cdocs/487?branch=1&language=1">View, Edit or comment</a> on the latest development version (registration required).
+ </div></div></div>
+ </div>
+ <!-- end of content -->
+ <div id="footer">
+ <p>©
+ 1999-2007
+
+ The Apache Software Foundation
+ <br/>
+
+ Last Published: 26/09/2007 05:18
+</p>
+ </div>
+ <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
+ </script>
+ <script type="text/javascript">
+ _uacct = "UA-1740622-3";
+ urchinTracker();
+ </script>
+ </body>
+</html>