You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by da...@cocoon.zones.apache.org on 2007/03/19 10:00:34 UTC

[DAISY] Updated: Cocoon Forms: Datatypes

A document has been updated:

http://cocoon.zones.apache.org/daisy/documentation/487.html

Document ID: 487
Branch: main
Language: default
Name: Cocoon Forms: Datatypes (unchanged)
Document Type: Cocoon Document (unchanged)
Updated on: 3/14/07 10:53:46 AM
Updated by: Helma van der Linden

A new version has been created, state: publish

Parts
=====

Content
-------
This part has been updated.
Mime type: text/xml (unchanged)
File name:  (unchanged)
Size: 9946 bytes (previous version: 8542 bytes)
Content diff:
(73 equal lines skipped)
    <p>java.math.BigDecimal</p>
    </td>
    <td>
--- <p>formatting (decimal), plain</p>
+++ <p><a href="#decimalformatting">formatting (decimal)</a>,
+++ <a href="#plain">plain</a></p>
    </td>
    </tr>
    <tr>
(37 equal lines skipped)
    <p>java.util.Date</p>
    </td>
    <td>
--- <p>formatting (date), millis</p>
+++ <p><a href="#dateformatting">formatting (date)</a>, <a href="#millis">millis</a>
+++ </p>
    </td>
    </tr>
    <tr>
(4 equal lines skipped)
    <p>Enumerated type</p>
    </td>
    <td>
--- <p>enum</p>
+++ <p><a href="#enum">enum</a></p>
    </td>
    </tr>
    <tr>
(10 equal lines skipped)
    </tbody>
    </table>
    
--- <h2>Enumerated datatype</h2>
+++ <h2 id="enum">Enumerated datatype</h2>
    
    <p>The <strong>enum</strong> datatype is meant to be used with types
    implementing Joshua Bloch's
(33 equal lines skipped)
    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 <strong>enum</strong>
--- selection list type.</p>
+++ <p>The enum datatype is typically used together with the
+++ <a href="daisy:753#enum"><strong>enum</strong> selection list type</a>.</p>
    
    <h1>Available convertors</h1>
    
--- <h2>formatting (decimal)</h2>
+++ <h2>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">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>&lt;fd:datatype base="decimal"&gt;
+++    &lt;fd:convertor type="plain"/&gt;
+++ &lt;/fd:datatype&gt;</pre>
+++ 
+++ <p>Output of this field with a value of <em>1234.5678</em> would be</p>
+++ 
+++ <pre>1234.5678
+++ </pre>
+++ 
+++ <h3 id="decimalformatting">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
(17 equal lines skipped)
    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>
    
--- <h2>plain</h2>
+++ <p>Example:</p>
    
--- <p>This convertor is not locale-dependent. It shows the full precision of the
--- number and uses dot as the decimal separator.</p>
+++ <pre>&lt;fd:datatype base="decimal"&gt;
+++    &lt;fd:convertor type="formatting"&gt;
+++       &lt;fd:patterns&gt;
+++          &lt;fd:pattern locale="en-US"&gt;#,###.##&lt;/fd:pattern&gt;
+++          &lt;fd:pattern locale="nl-NL"&gt;####,####&lt;/fd:pattern&gt;
+++       &lt;/fd:patterns&gt;
+++    &lt;/fd:convertor&gt;
+++ &lt;/fd:datatype&gt;
+++ </pre>
    
--- <h2>date convertors</h2>
+++ <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>Date convertors</h2>
+++ 
    <p>The date datatype can be used both for dates as times. The date datatype
    supports the following convertors:</p>
    
--- <h3>formatting (date)</h3>
+++ <h3 id="dateformatting">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
(57 equal lines skipped)
    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>
    
--- <h3>millis</h3>
+++ <p class="note">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="daisy:488#convertor">binding framework</a> page. The same holds true
+++ for numbers.</p>
    
+++ <h3 id="millis">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
(4 equal lines skipped)