You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Greg Huber <gr...@gmail.com> on 2018/02/23 11:10:01 UTC

Changes on the validator field-validator required

We use  <field-validator type="required"> validator to make sure null is
not passed, but if I use a double it does not now validate, it wants a
Double for it to work.

Has there been any changes, or has it always been like this?

also, other validators work ie the min/max below, with the double.

<field name="bean.thePrice">
        <field-validator type="required">
            <message key="bean.theprice.required">unspecified key</message>
        </field-validator>
        <field-validator type="double">
            <param name="minInclusive">0</param>
            <param name="maxInclusive">2999</param>
            <message key="bean.theprice.range">unspecified key</message>
        </field-validator>
</field>

bean:
..
private double thePrice;
public double getThePrice() {
    return thePrice;
}
public void setThePrice(double thePrice) {
    this.thePrice = thePrice;
}
..
Cheers Greg

Re: Changes on the validator field-validator required

Posted by Greg Huber <gr...@gmail.com>.
Must have worked at some point, otherwise I would not have has the required
in there in the first place.  It was an easy change, so no problem.

Chees Greg

On 23 February 2018 at 16:51, Yasser Zamani <ya...@apache.org> wrote:

> Did your form beans work in previous Struts version and now you have to
> change all? Or you get this error always with all Struts versions?
> On Feb 23, 2018, at 5:48PM, Greg Huber <gregh3269@gmail.com<mailto:gr
> egh3269@gmail.com>> wrote:
>
> I checked, and double value comes from ongl,  and yes it wont be a null, so
> does not get validated.  I get the struts error though.  I have had to
> change all my form beans to be Doubles.
> https://struts.apache.org/core-developers/required-validator.html could do
> with an update warning no not to use primitives.
>
> Cheers Greg
>
> Cheers Greg
>
> On 23 February 2018 at 12:51, Yasser Zamani <ya...@apache.org>
> wrote:
>
>
>
>  On 2/23/2018 2:40 PM, Greg Huber wrote:
>  We use  <field-validator type="required"> validator to make sure null is
>  not passed, but if I use a double it does not now validate, it wants a
>  Double for it to work.
>
>  Has there been any changes, or has it always been like this?
>
>  Did you mean it works in some versions as you expect?
>
>  I think the primitive type double, cannot be null at all in java and
>  automatically will be initialized to 0 by java i.e. you don't need a
>  null validator in such situations. The non-primitive type Double, can.
>  This may explain why when you change your type to Double it starts
> working.
>
>  Regards.
>
>
> ________________________________
>
>  To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  For additional commands, e-mail: dev-help@struts.apache.org
>
>
>

Re: Changes on the validator field-validator required

Posted by Yasser Zamani <ya...@apache.org>.
Did your form beans work in previous Struts version and now you have to change all? Or you get this error always with all Struts versions?
On Feb 23, 2018, at 5:48PM, Greg Huber <gr...@gmail.com>> wrote:

I checked, and double value comes from ongl,  and yes it wont be a null, so
does not get validated.  I get the struts error though.  I have had to
change all my form beans to be Doubles.
https://struts.apache.org/core-developers/required-validator.html could do
with an update warning no not to use primitives.

Cheers Greg

Cheers Greg

On 23 February 2018 at 12:51, Yasser Zamani <ya...@apache.org> wrote:



 On 2/23/2018 2:40 PM, Greg Huber wrote:
 We use  <field-validator type="required"> validator to make sure null is
 not passed, but if I use a double it does not now validate, it wants a
 Double for it to work.

 Has there been any changes, or has it always been like this?

 Did you mean it works in some versions as you expect?

 I think the primitive type double, cannot be null at all in java and
 automatically will be initialized to 0 by java i.e. you don't need a
 null validator in such situations. The non-primitive type Double, can.
 This may explain why when you change your type to Double it starts working.

 Regards.


________________________________

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



Re: Changes on the validator field-validator required

Posted by Greg Huber <gr...@gmail.com>.
I checked, and double value comes from ongl,  and yes it wont be a null, so
does not get validated.  I get the struts error though.  I have had to
change all my form beans to be Doubles.
https://struts.apache.org/core-developers/required-validator.html could do
with an update warning no not to use primitives.

Cheers Greg

Cheers Greg

On 23 February 2018 at 12:51, Yasser Zamani <ya...@apache.org> wrote:

>
>
> On 2/23/2018 2:40 PM, Greg Huber wrote:
> > We use  <field-validator type="required"> validator to make sure null is
> > not passed, but if I use a double it does not now validate, it wants a
> > Double for it to work.
> >
> > Has there been any changes, or has it always been like this?
>
> Did you mean it works in some versions as you expect?
>
> I think the primitive type double, cannot be null at all in java and
> automatically will be initialized to 0 by java i.e. you don't need a
> null validator in such situations. The non-primitive type Double, can.
> This may explain why when you change your type to Double it starts working.
>
> Regards.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

Re: Changes on the validator field-validator required

Posted by Yasser Zamani <ya...@apache.org>.

On 2/23/2018 2:40 PM, Greg Huber wrote:
> We use  <field-validator type="required"> validator to make sure null is
> not passed, but if I use a double it does not now validate, it wants a
> Double for it to work.
> 
> Has there been any changes, or has it always been like this?

Did you mean it works in some versions as you expect?

I think the primitive type double, cannot be null at all in java and
automatically will be initialized to 0 by java i.e. you don't need a
null validator in such situations. The non-primitive type Double, can.
This may explain why when you change your type to Double it starts working.

Regards.


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