You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Markus Heussen <he...@rheinland-online.com> on 2003/12/19 15:22:45 UTC

[Woody] wd:datatype base="date" -> setLenient(false) behavior

If the input of the date form field is for example "31.02.2004" after
submission this value is automatically set to "02.03.2004".

How can I change this behavior? Is there a attribute I can set in the woody
binding or definition file to get the behavior like using the
"setLenient(false)" method in java?

Thanks for your help!

Markus


woody defintion:

<wd:field id="vn_geburtsdatum" required="true">
	<wd:label>Geburtsdatum</wd:label>
	<wd:datatype base="date">
		<wd:convertor>
			<wd:patterns>
				<wd:pattern>dd.MM.yyyy</wd:pattern>
			</wd:patterns>
		</wd:convertor>
	</wd:datatype>
</wd:field>


woody binding:

<wb:value id="vn_geburtsdatum" path="v:Geburtsdatum">
	<wd:convertor datatype="date" type="formatting">
		<wd:patterns>
			<wd:pattern>yyyy-MM-dd</wd:pattern>
		</wd:patterns>
	</wd:convertor>
</wb:value>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [Woody] wd:datatype base="date" -> setLenient(false) behavior

Posted by Ugo Cei <u....@cbim.it>.
Marc Portier wrote:
> 2/ provide a wd:pattern/@lenient to let it be user-defined (in which 
> case we still need some choice for the default)

+1 and +1 to setting "false" as the default.

	Ugo


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [Woody] wd:datatype base="date" -> setLenient(false) behavior

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Marc Portier wrote:
<snip/>

> the standard date-conversion is done using the java.util.text stuff 
> which is by default lenient towards typos of the kind you describe 
> (31/02 automatically becomes 02/03)

...

> 2/ provide a wd:pattern/@lenient to let it be user-defined (in which 
> case we still need some choice for the default)


+1. Where java.text is used? I found only references to the outerthought
expressions package.

Vadim





Re: [Woody] wd:datatype base="date" -> setLenient(false) behavior

Posted by Marc Portier <mp...@outerthought.org>.
Taking it to dev since we should have some consensus on changes like 
these IMHO.


Markus Heussen wrote:

> If the input of the date form field is for example "31.02.2004" after
> submission this value is automatically set to "02.03.2004".
> 
> How can I change this behavior? Is there a attribute I can set in the woody
> binding or definition file to get the behavior like using the
> "setLenient(false)" method in java?
> 
> Thanks for your help!
> 
> Markus
> 

Markus,

I think you correctly identified the source of your problems here: the 
standard date-conversion is done using the java.util.text stuff which is 
by default lenient towards typos of the kind you describe (31/02 
automatically becomes 02/03)

Possible options out I see:
1/ call setLenient(false) in the code so we avoid the surprises 
introduced by the default behaviour of the Java classes (although that 
might surprise the java-savvy)

2/ provide a wd:pattern/@lenient to let it be user-defined (in which 
case we still need some choice for the default)

other suggestions?

-marc=


> 
> woody defintion:
> 
> <wd:field id="vn_geburtsdatum" required="true">
> 	<wd:label>Geburtsdatum</wd:label>
> 	<wd:datatype base="date">
> 		<wd:convertor>
> 			<wd:patterns>
> 				<wd:pattern>dd.MM.yyyy</wd:pattern>
> 			</wd:patterns>
> 		</wd:convertor>
> 	</wd:datatype>
> </wd:field>
> 
> 
> woody binding:
> 
> <wb:value id="vn_geburtsdatum" path="v:Geburtsdatum">
> 	<wd:convertor datatype="date" type="formatting">
> 		<wd:patterns>
> 			<wd:pattern>yyyy-MM-dd</wd:pattern>
> 		</wd:patterns>
> 	</wd:convertor>
> </wb:value>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 

-- 
Marc Portier                            http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at                http://blogs.cocoondev.org/mpo/
mpo@outerthought.org                              mpo@apache.org


Re: [Woody] wd:datatype base="date" -> setLenient(false) behavior

Posted by Marc Portier <mp...@outerthought.org>.
Taking it to dev since we should have some consensus on changes like 
these IMHO.


Markus Heussen wrote:

> If the input of the date form field is for example "31.02.2004" after
> submission this value is automatically set to "02.03.2004".
> 
> How can I change this behavior? Is there a attribute I can set in the woody
> binding or definition file to get the behavior like using the
> "setLenient(false)" method in java?
> 
> Thanks for your help!
> 
> Markus
> 

Markus,

I think you correctly identified the source of your problems here: the 
standard date-conversion is done using the java.util.text stuff which is 
by default lenient towards typos of the kind you describe (31/02 
automatically becomes 02/03)

Possible options out I see:
1/ call setLenient(false) in the code so we avoid the surprises 
introduced by the default behaviour of the Java classes (although that 
might surprise the java-savvy)

2/ provide a wd:pattern/@lenient to let it be user-defined (in which 
case we still need some choice for the default)

other suggestions?

-marc=


> 
> woody defintion:
> 
> <wd:field id="vn_geburtsdatum" required="true">
> 	<wd:label>Geburtsdatum</wd:label>
> 	<wd:datatype base="date">
> 		<wd:convertor>
> 			<wd:patterns>
> 				<wd:pattern>dd.MM.yyyy</wd:pattern>
> 			</wd:patterns>
> 		</wd:convertor>
> 	</wd:datatype>
> </wd:field>
> 
> 
> woody binding:
> 
> <wb:value id="vn_geburtsdatum" path="v:Geburtsdatum">
> 	<wd:convertor datatype="date" type="formatting">
> 		<wd:patterns>
> 			<wd:pattern>yyyy-MM-dd</wd:pattern>
> 		</wd:patterns>
> 	</wd:convertor>
> </wb:value>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 

-- 
Marc Portier                            http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at                http://blogs.cocoondev.org/mpo/
mpo@outerthought.org                              mpo@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org