G
Greg Williams
Has anyone noticed this? When declaring a form bean, I declare a
property (pluNumber) as type Long (java.lang.Long). Then I edit
validation.xml (could be called something else) and add the following:
<form name="thisForm">
<field
property="pluNumber"
depends="required">
<arg0 key="setup.thisForm.pluNumber.displayName"/>
</field>
</form>
So, provided I declare this form to be validated in my action
declarations, struts should return an error message if nothing is
entered into the input box for this property. However, what really
happens is that, since it is a Long, struts instantiates this class
witha value of 0. So the "required" check passes and no error message
is created. In fact, i could put "required,integer" and enter a string
"cncnvbeueb" into the input and this would pass because Long can be
intantiated by passing a string. I've had trouble making this field a
primitive long, not sure if you can?. i dont really want to anyway
because when i copy the properties
(org.apache.commons.beanutils.BeanUtils.copyProperties) I want the
property to be the same type as in the model object (or DTO) before
working with it. Am I missing something?
greg
property (pluNumber) as type Long (java.lang.Long). Then I edit
validation.xml (could be called something else) and add the following:
<form name="thisForm">
<field
property="pluNumber"
depends="required">
<arg0 key="setup.thisForm.pluNumber.displayName"/>
</field>
</form>
So, provided I declare this form to be validated in my action
declarations, struts should return an error message if nothing is
entered into the input box for this property. However, what really
happens is that, since it is a Long, struts instantiates this class
witha value of 0. So the "required" check passes and no error message
is created. In fact, i could put "required,integer" and enter a string
"cncnvbeueb" into the input and this would pass because Long can be
intantiated by passing a string. I've had trouble making this field a
primitive long, not sure if you can?. i dont really want to anyway
because when i copy the properties
(org.apache.commons.beanutils.BeanUtils.copyProperties) I want the
property to be the same type as in the model object (or DTO) before
working with it. Am I missing something?
greg