cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Velychko <>
Subject Re: Validating fd:fields with datatype base="date"
Date Fri, 02 Jul 2004 08:20:34 GMT
Hello Joerg,

Friday, July 2, 2004, 12:46:12 AM, you wrote:

> On 01.07.2004 21:13, Colin Paul Adams wrote:
>> I have a widget defined with a base datatype of date. I have the
>> calendar pop-up attached so that the user can enter dates easily.
>> However, if the users types in a date by hand, and gets it wrong, the
>> rather unhelpful error message is:
>> datatype.conversion
>> Fine for developers whilst writing the application but ...

> This should be handled by i18n. When I try the flow sample I get a 
> message "Not a valid date."

Lyrical digression
Error messages produced by forms are generated by
org.apache.cocoon.forms.util.I18nMessage class with following
- String key_of_i18n_message
- String catalogue_name
For second argument it has
org.apache.cocoon.forms.Constants.I18N_CATALOGUE that has value "forms"
   public static final String I18N_CATALOGUE = "forms";

1. Add the definition of "forms" catalogue in definition of i18n
<map:transformer name="i18n" src="org.apache.cocoon.transformation.I18nTransformer">
  <catalogues default="messages">
    <catalogue id="messages" name="messages" location="resources/i18n"/>
    <catalogue id="forms" name="messages" location="resources/i18n"/>

2. Add to resources/i18n/forms.xml messages you need.
<?xml version="1.0"?>
<catalogue xml:lang="locale">
  <message key="general.field-required">Message 1</message>
  <message key="upload.invalid-type">Message 3</message>
  <message key="datatype.conversion-failed">Message 2</message>
  ...your other messages...

>> Even worse, if the user types in nothing (on a freshly added row), the
>> form accepts this without complaint (I'm not quite sure why this
>> should be - I have a pattern convertor and the empty string doesn't
>> match the pattern - well, I don't think it does:

> If you do not enter anything no convertor is asked. That's an expected 
> behaviour. If you want to make a required field, add required="true". If 
> the behaviour were like you expect it, it would not be possible to leave 
> out a date field.

>> Anyway, clearly I need a validator so I can give appropriate error
>> messages. Looking at the documentation, there does not appear to be
>> one available for date fields. Does that mean I have to write one in
>> javascript (or will I need to use java?)?

> No, required="true", the convertor with a pattern and an i18n message 
> should be sufficient.

> Joerg

> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Best regards,
Peter Velychko                   

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message