You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Chris Newland <ch...@emorphia.com> on 2001/08/28 19:09:31 UTC

Bug in AbstractValidatorAction?

Hi All,

I'm a little confused by the behaviour in AbstractValidatorAction for
parameters that have the nullable property set to "yes".

If the parameter is nullable and I don't set the value in the form (so it
becomes null) then the method validate<Type>(...) will set the value to its
default value and then apply any other constraint tests set on the property.
If one of these constraint tests fails then the form validation fails which
is not what I expected since I declared that the parameter could be null in
the first place!

Also, is it correct that if the default is not set for a nullable parameter,
this will cause an NPE when any other constraint is tested (on the default,
since this is substituted for a nullable parameter).

I can patch this is people agree this is a bug, but maybe the design was
that you could not have a parameter that has both constraints *and* the
ability to be null:

<!-- if they enter their age it must be between 18 and 120 -->
<parameter type="long" name="age" min="18" max="120" nullable="yes"/>

Thanks,

Best Regards,

Chris

--
Chris Newland
Software Research Engineer

Emorphia Ltd
Registered in England.  4133002
Mill House, Station Approach, Harlow Mill, Harlow, Essex, CM20 2EL, UK

Email: chris.newland@emorphia.com
Tel: +44 (0)1279 450100
Fax: +44 (0)1279 450102

Check out FIPA-OS at http://fipa-os.sourceforge.net/

This message may contain information proprietary to Emorphia so any
unauthorised disclosure, copying or distribution of its contents is strictly
prohibited.



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


Re: Bug in AbstractValidatorAction?

Posted by Martin Man <Ma...@seznam.cz>.
On Tue, Aug 28, 2001 at 06:09:31PM +0100, Chris Newland wrote:
> Hi All,
> 
> I'm a little confused by the behaviour in AbstractValidatorAction for
> parameters that have the nullable property set to "yes".
> 
> If the parameter is nullable and I don't set the value in the form (so it
> becomes null) then the method validate<Type>(...) will set the value to its
> default value and then apply any other constraint tests set on the property.
> If one of these constraint tests fails then the form validation fails which
> is not what I expected since I declared that the parameter could be null in
> the first place!
yes, that should be the expected behavior...

> 
> Also, is it correct that if the default is not set for a nullable parameter,
> this will cause an NPE when any other constraint is tested (on the default,
> since this is substituted for a nullable parameter).
> 
> I can patch this is people agree this is a bug, but maybe the design was
> that you could not have a parameter that has both constraints *and* the
> ability to be null:
if you have a patch, send it to the list and I'll apply it, otherwise give me
some time to fix it :-))

> 
> <!-- if they enter their age it must be between 18 and 120 -->
> <parameter type="long" name="age" min="18" max="120" nullable="yes"/>
> 
> Thanks,
> 
> Best Regards,
> 
> Chris
> 
rgds,
martin man


-- 
-------------------------------------------------------------------------------
"Only dead fish swims with a stream"                         Malcolm Muggeridge
gpg_key_available: http://globales.cz/~mman/martin.man.gpg
gpg_key_fingerprint: 2CC0 4AF6 92DA 5CBF 5F09  7BCB 6202 7024 6E06 0223

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


Re: Bug in AbstractValidatorAction?

Posted by Martin Man <Ma...@seznam.cz>.
hi all,
	o.k., it's fixed now in both active branches, when the value is null
(and when t takes the default value) it's just passed back with correct
status, ..., the constraints tests are therefore skipped,

please test it on some real-world problem :))


rgds,
martin

On Tue, Aug 28, 2001 at 06:09:31PM +0100, Chris Newland wrote:
> Hi All,
> 
> I'm a little confused by the behaviour in AbstractValidatorAction for
> parameters that have the nullable property set to "yes".
> 
> If the parameter is nullable and I don't set the value in the form (so it
> becomes null) then the method validate<Type>(...) will set the value to its
> default value and then apply any other constraint tests set on the property.
> If one of these constraint tests fails then the form validation fails which
> is not what I expected since I declared that the parameter could be null in
> the first place!
> 
> Also, is it correct that if the default is not set for a nullable parameter,
> this will cause an NPE when any other constraint is tested (on the default,
> since this is substituted for a nullable parameter).
> 
> I can patch this is people agree this is a bug, but maybe the design was
> that you could not have a parameter that has both constraints *and* the
> ability to be null:
> 
> <!-- if they enter their age it must be between 18 and 120 -->
> <parameter type="long" name="age" min="18" max="120" nullable="yes"/>
> 
> Thanks,
> 
> Best Regards,
> 
> Chris
> 
> --
> Chris Newland
> Software Research Engineer
> 
> Emorphia Ltd
> Registered in England.  4133002
> Mill House, Station Approach, Harlow Mill, Harlow, Essex, CM20 2EL, UK
> 
> Email: chris.newland@emorphia.com
> Tel: +44 (0)1279 450100
> Fax: +44 (0)1279 450102
> 
> Check out FIPA-OS at http://fipa-os.sourceforge.net/
> 
> This message may contain information proprietary to Emorphia so any
> unauthorised disclosure, copying or distribution of its contents is strictly
> prohibited.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
> 

-- 
-------------------------------------------------------------------------------
"Only dead fish swims with a stream"                         Malcolm Muggeridge
gpg_key_available: http://globales.cz/~mman/martin.man.gpg
gpg_key_fingerprint: 2CC0 4AF6 92DA 5CBF 5F09  7BCB 6202 7024 6E06 0223

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