You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by st...@outerthought.org on 2003/10/31 17:00:07 UTC

[WIKI-UPDATE] WoodyWidgetReference Woody WoodyReference WoodyDatatypeReference WoodyEventHandling Javadocs Fri Oct 31 17:00:07 2003

Page: http://wiki.cocoondev.org/Wiki.jsp?page=WoodyWidgetReference , version: 1 on Fri Oct 31 16:01:23 2003 by BrunoDumon

New page created:
+ !!field widget
+ 
+ The field widget is the most common widget. It is used both for text
+ boxes or selection lists. It can be associated with different datatypes
+ such as string, long or date to ask for different types of data.
+ 
+ Configuration example:
+ 
+ {{{
+ <wd:field id="..." required="true|false">
+   <wd:label>...</wd:label>
+   <wd:hint>...</wd:hint>
+   <wd:help>...</wd:help>
+   <wd:datatype base="...">
+      [...]
+   </wd:datatype>
+   <wd:selection-list .../>
+   <wd:on-value-changed>
+     ...
+   </wd:on-value-changed>
+ </wd:field>
+ }}}
+ 
+ The field element takes a required __id attribute__. This id should be unique among all widgets in the same container (usually the form).
+ 
+ The __required attribute__ is optional, by default it is false. It indicates whether this field is required.
+ 
+ The __wd:label__ element contains the label for this widget. This element is optional. It can contain mixed content. For internationalised labels, use i18n-tags in combination with Cocoon's [I18nTransformer|I18NTransformer].
+ 
+ The __wd:hint__ element contains a hint for the form control of this widget. This element is optional. It can contain a hint about the input control. For internationalised labels, use i18n-tags in combination with Cocoon's [I18nTransformer|I18NTransformer].
+ 
+ The __wd:help__ element contains more help for the form control of this widget. This element is optional. It can contain text help about the input control. For internationalised labels, use i18n-tags in combination with Cocoon's [I18nTransformer|I18NTransformer].
+ 
+ The __wd:datatype__ element indicates the datatype for this field. This element is required. The __base attribute__ specifies on which built-in type this datatype should be based. The contents of the wd:datatype element can contain further configuration information for the datatype. The possible datatypes and their configuration options are described in a seperate section.
+ 
+ The __wd:selection-list__ element is used to associate a selection list with this field. See the information on datatypes for more details.
+ 
+ The __wd:on-value-changed__ element specifies event handlers to be executed in case the value of this field changes. See also [WoodyEventHandling]. The interface to be implemented for Java event listeners is ''org.apache.cocoon.woody.event.ValueChangedListener''. The WidgetEvent subclass is ''org.apache.cocoon.woody.event.ValueChangedEvent''.
+ 
+ !!multivaluefield widget
+ 
+ The __wd:multivaluefield__ is similar to the field widget but can take multiple values. A multivaluefield should always have a __wd:datatype__ element with a selection list, since the user will have to select values from this list. This the wd:multivaluefield could be rendered as a list of checkboxes or as a listbox in which the user can select multiple items.
+ 
+ Configuration example:
+ 
+ {{{
+ <wd:multivaluefield id="...">
+   <wd:label>...</wd:label>
+   <wd:help>...</wd:help>
+   <wd:hint>...</wd:hint>
+   <wd:datatype base="...">
+     [...]
+   </wd:datatype>
+   <wd:selection-list>
+     <wd:item value="...">
+       <wd:label>...</wd:label>
+     </wd:item>
+     [...]
+   </wd:selection-list>
+ </wd:multivaluefield>
+ }}}
+ 
+ Most of the elements and attributes have the same meaning as for the
+ field widget.
+ 
+ A multivaluefield cannot have a required attribute, instead you should
+ use the "value-count" validation rule to check the number of values
+ the user has selected.
+ 
+ !booleanfield widget
+ 
+ A __wd:booleanfield__ is a field that has a value of true or false. Usually is rendered as a checkbox.
+ 
+ Configuration example:
+ 
+ {{{
+ <wd:booleanfield id="...">
+   <wd:label>...</wd:label>
+   <wd:help>...</wd:help>
+   <wd:hint>...</wd:hint>
+ </wd:booleanfield>
+ }}}
+ 
+ !!repeater widget
+ 
+ A __wd:repeater__ widget is a widget that repeats a number of other widgets.
+ It can be used to create e.g. tables.
+ 
+ Configuration example:
+ 
+ {{{
+ <wd:repeater id="...">
+   [...]
+ </wd:repeater>
+ }}}
+ 
+ The repeater element should contain a number of other widgets
+ to repeat. This can be any of type of widget: field, multivaluefied,
+ booleanfield, or even repeater itself.
+ 
+ Note: the [WoodyTemplateTransformer] has specific support for specifying a template to use to render each of the rows of a repeater widget. See the "Form1" example of Woody for an example on how to use this.
+ 
+ !!output widget
+ An __wd:output__ widget is similar to a field widget, but its value is not editable. The value of an output widget must be set programmatically (or through [binding|WoodyBinding]). An output widget does not read its value from the request, so is most useful in the case where the form is stored accross requests (e.g. as part of a flowscript or flow-apple). An output widget does not perform any validation, it is always considered to be valid.
+ 
+ {{{
+ <wd:output id="...">
+   <wd:label>...</wd:label>
+   <wd:help>...</wd:help>
+   <wd:hint>...</wd:hint>
+   <wd:datatype base="...">
+      [...]
+   </wd:datatype>
+ </wd:output>
+ }}}
+ 
+ !!action widget
+ 
+ Used to trigger an action event on the server side. Usually presented as a button the user can press (though this is not required).
+ 
+ {{{
+ <wd:action id="..." action-command="...">
+   <wd:label>...</wd:label>
+   <wd:help>...</wd:help>
+   <wd:hint>...</wd:hint>
+   <wd:on-action>
+     ...
+   </wd:on-action>
+ </wd:action>
+ }}}
+ 
+ The action-command attribute specifies a name that will be part of the event generated by this widget. It can be used to distinguish events originated from this wd:action from another one.
+ 
+ For more information on how event handlers are defined, see [WoodyEventHandling]. The interface to be implemented for Java event listeners is ''org.apache.cocoon.woody.event.ActionListener''. The WidgetEvent subclass is ''org.apache.cocoon.woody.event.ActionEvent''.
+ 
+ !!repeater-action widget
+ 
+ This is a specific type of action widget that handles the much needed case of adding or removing rows from a repeater.
+ 
+ {{{
+ <wd:repeater-action id="..." action-command="delete-rows|add-row" repeater="..." select="...">
+   <wd:label>...</wd:label>
+   <wd:help>...</wd:help>
+   <wd:hint>...</wd:hint>
+   <wd:on-activate>
+     ...
+   </wd:on-activate>
+ </wd:repeater-action>
+ }}}
+ 
+ The action-command attribute should have either the value "delete-rows" or "add-row".
+ 
+ If add-row is specified, the attribute repeater is required. If delete-rows is specified, both the repeater and select attributes are required.
+ 
+ The repeater attribute should contain the id of the repeater widget on which this repeater-action should act.
+ 
+ The select attribute should contain the id of the booleanfield widget (or any type of widget who's getValue() method returns a boolean) that is part of the repeater and used to mark the rows to be deleted.
+ 
+ wd:on-activate allows additional event handlers to be defined, see also [WoodyEventHandling]. The interface to be implemented for Java event listeners is org.apache.cocoon.woody.event.ActionListener. The WidgetEvent subclass is ''org.apache.cocoon.woody.event.ActionEvent''.
+ 
+ !!other widgets:
+ 
+ Widgets yet to be documented:
+ 
+ * __wd:aggregatefield__: used to edit the value of multiple fields through one textbox
+ 


Page: http://wiki.cocoondev.org/Wiki.jsp?page=Woody , version: 8 on Fri Oct 31 15:47:35 2003 by BrunoDumon

- * [Event handling|WoodyEventHandling]
+ * [Event handling (& request processing phases)|WoodyEventHandling]


Page: http://wiki.cocoondev.org/Wiki.jsp?page=WoodyReference , version: 17 on Fri Oct 31 15:59:07 2003 by BrunoDumon

- Work in progress.
+ * [WoodyWidgetReference]
+ * [WoodyDatatypeReference]
+ * [WoodyValidationRuleReference]


Page: http://wiki.cocoondev.org/Wiki.jsp?page=WoodyDatatypeReference , version: 1 on Fri Oct 31 16:04:04 2003 by BrunoDumon

New page created:
+ !!!General information
+ 
+ In its most basic form a datatype is declared as follows:
+ 
+ {{{
+ <wd:datatype base="...">
+ }}}
+ 
+ The __base__ attribute refers to one of the built-in datatypes such as string or long.
+ 
+ A datatype can have a number of validation rules, for example:
+ 
+ {{{
+ <wd:datatype base="string">
+   <wd:validation>
+     <wd:length exact='4'/>
+   </wd:validation>
+ </wd:datatype>
+ }}}
+ 
+ The __wd:validation__ element contains a number of child elements, each child element signifies a validation rule. The supported validation rules are documented in a seperate section.
+ 
+ A datatype also 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 __wd:convertor__ element. Here's an example for dates:
+ {{{
+ <wd:datatype base="date">
+   <wd:convertor type="formatting">
+     <wd:patterns>
+       <wd:pattern>dd/MM/yyyy</wd:pattern>
+     </wd:patterns>
+   </wd:convertor>
+ </wd:datatype>
+ }}}
+ 
+ The __type__ attribute on the wd:convertor element is optional, if not specified the default one will be used (configured in the cocoon.xconf). Any further content of the wd:convertor element is specific to the convertor implementation and will be documented in a seperate section.
+ 
+ Widgets that have a datatype can also have a selection list. Since selection lists are associated with datatypes, we discuss them here. The selection list can be defined inline or read from an external source. Example of inline declaration:
+ 
+ {{{
+ <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>
+ }}}
+ 
+ Each item in the selection-list can have a value (specified in the value attribute) and optionally a label (specified in the wd:label element). If no label is specified, the value is used as label. The wd:label element can contain mixed content.
+ 
+ Example of getting a selection list from an external source:
+ {{{
+ <wd:datatype base="string"/>
+ <wd:selection-list src="cocoon:/mychoices.xml"/>
+ }}}
+ 
+ All Cocoon-supported protocols can be used. The format of the XML produced by the source should be the same as in case of inline specification of the selection list, thus the root element should be a wd:selection-list element.
+ 
+ By default, the selection list will be retrieved form the source once, and then become part of the form definition, just like when you would have defined it inline. This has the consequence that if the XML produced by the source changes, you won't see the selection list changed. If you'd like Woody to retrieve the content of the selection list each time it needs it, add an attribute called "dynamic" with value "true", for example:
+ {{{
+ <wd:datatype base="string"/>
+ <wd:selection-list src="cocoon:/mychoices.xml" dynamic="true"/>
+ }}}
+ 
+ If the datatype is different from string, Woody will need to convert the string values that appear in the selection list to their object equivalent. This conversion is normally done using the same convertor as the datatype in which the selection list appears, but you can also specify a different one. Here's an example for a date selection list:
+ {{{
+ <wd:datatype base="date"/>
+ <wd:selection-list>
+   <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>
+ }}}
+ 
+ If there is a wd:convertor element, it should always be the first child element of the wd:selection-list element. This works of course also for selection lists retrieved from external sources.
+ 
+ !!!Supported datatypes
+ 
+ ||Woody Datatype||Java class||Convertors||
+ |string|{{java.lang.String}}|Strings obviously don't support any convertors, since there's no purpose in converting a string to a string.|
+ |decimal|{{java.math.BigDecimal}}|formatting (decimal), plain|
+ |integer|{{java.lang.Integer}}|similar convertors as the decimal datatype (see below)|
+ |long|{{java.lang.Long}}|similar convertors as the decimal datatype (see below)|
+ |date|{{java.util.Date}}|formatting (date), millis
+ 
+ 
+ !!!Convertors
+ 
+ !formatting (decimal)
+ 
+ This convertor uses the {{java.text.DecimalFormat}} class (or {{com.ibm.icu.text.DecimalFormat}} class if it is present in the classpath). This means it can perform locale-dependent, pattern-based formatting of numbers.
+ 
+ Configuration pseudo-schema:
+ {{{
+ <wd:convertor type="formatting" variant="integer|number|currency|percent" ? >
+   <wd:patterns>
+     <wd:pattern>....</wd:pattern> ?
+     <wd:pattern locale="lang-COUNTRY">....</wd:pattern> *
+   </wd:patterns> ?
+ </wd:convertor>
+ }}}
+ 
+ The variant attribute and patterns element are optional. By default, the "number" variant is used (or for longs: the "integer" variant).
+ 
+ You can supply either a locale-independent formatting pattern or locale-dependent formatting patterns. See the [javadoc of the DecimalFormat|http://java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormat.html] class for the supported pattern syntax. Woody will always use the pattern that is most specific for the current locale.
+ 
+ !plain
+ 
+ This convertor is not locale-dependent. It shows the full precision of the number and uses dot as the decimal separator.
+ 
+ !!date convertors
+ 
+ The date datatype can be used both for dates as times. The date datatype supports the following convertors:
+ 
+ !formatting (date)
+ 
+ This convertor uses the {{java.text.SimpleDateFormat}} class (or {{com.ibm.icu.text.SimpleDateFormat}} class if it is present in the classpath). This means it can perform locale-dependent, pattern-based formatting of dates.
+ 
+ Configuration pseudo-schema:
+ {{{
+ <wd:convertor type="formatting" variant="date|time|datetime" ? style="short|medium|long|full" ?>
+   <wd:patterns>
+     <wd:pattern>....</wd:pattern> ?
+     <wd:pattern locale="lang-COUNTRY">....</wd:pattern> *
+   </wd:patterns> ?
+ </wd:convertor>
+ }}}
+ 
+ Usually you will use either the variant and style attributes or the pattern(s).
+ 
+ For example, the following convertor configuration:
+ {{{
+ <wd:convertor type="formatting" variant="date" style="short">
+ }}}
+ 
+ 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.
+ 
+ Here's an example of using a formatting pattern:
+ {{{
+ <wd:convertor type="formatting">
+   <wd:patterns>
+     <wd:pattern>dd/MM/yyyy</wd:pattern>
+   </wd:patterns>
+ </wd:convertor>
+ }}}
+ 
+ Using the same date, this will now give "15/07/2003".
+ 
+ It is also possible to use different patterns for different locales by using multiple wd:pattern elements with "locale" attributes, for example:
+ {{{
+ <wd:convertor type="formatting">
+   <wd:patterns>
+     <wd:pattern>MM/dd/yyyy</wd:pattern>
+     <wd:pattern locale="nl-BE">dd/MM/yyyy</wd:pattern>
+     <wd:pattern locale="fr">dd-MM-yyyy</wd:pattern>
+   </wd:patterns>
+ </wd:convertor>
+ }}}
+ 
+ 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).
+ 
+ !millis
+ 
+ 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.
+ 


Page: http://wiki.cocoondev.org/Wiki.jsp?page=WoodyEventHandling , version: 3 on Fri Oct 31 15:35:10 2003 by BrunoDumon

- * __event__: a subclass of WidgetEvent. See the [woody reference documentation|WoodyReference] for information on the type of WidgetEvent, and see the javadocs for what these provide (the samples might also give a good start),
+ * __event__: a subclass of WidgetEvent. See the [woody reference documentation|WoodyReference] for information on the type of WidgetEvent, and see the [javadocs|Javadocs] for what these provide (the samples might also give a good start),
?                                                                                                                                                        +        ++++++++++

- To handle events using a FormHandler, write a class implementing the org.apache.cocoon.woody.event.FormHandler interface. Alternatively you can extend from the abstract class org.apache.cocoon.woody.event.AbstractFormHandler, which will split ActionEvents and ValueChangedEvents to two different methods. See the javadocs of these interfaces and classes for more details.
+ To handle events using a FormHandler, write a class implementing the org.apache.cocoon.woody.event.FormHandler interface. Alternatively you can extend from the abstract class org.apache.cocoon.woody.event.AbstractFormHandler, which will split ActionEvents and ValueChangedEvents to two different methods. See the [javadocs|Javadocs] of these interfaces and classes for more details.
?                                                                                                                                                                                                                                                                                                                          +        ++++++++++



Page: http://wiki.cocoondev.org/Wiki.jsp?page=Javadocs , version: 1 on Fri Oct 31 15:46:39 2003 by BrunoDumon

New page created:
+ !!!Where to find the Cocoon Javadocs (= API documentation)
+ 
+ [Online Cocoon 2.1 javadocs|http://cocoon.apache.org/2.1/apidocs/index.html]
+ 
+ The javadocs for the specific version of Cocoon (e.g. CVS checkout) you have in front of you can be found after building Cocoon in:
+ 
+ {{{
+ build/cocoon-<version>/javadocs/index.html
+ }}}
+ 
+ You can build the javadocs separately by invoking this command:
+ 
+ {{{
+ ./build.sh javadocs
+ }}}
+ 
+ but make sure the following property isn't activated in the local.build.properties:
+ 
+ {{{
+ #exclude.javadocs=true
+ }}}
+