struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lyallex <lyal...@gmail.com>
Subject Handling Integer overflows
Date Wed, 05 Nov 2008 15:59:57 GMT
Hi

Please be aware that I understand completely WHY the following is
happening (Integer overflow)
This question is about how to handle it.

I have a form that has an input field

<s:textfield name="creditcount"/>

In my action I have the fiollowing field

public Integer creditcount;

If I enter the String "2147482647" (equivalent to Integer.MAX_VALUE)
then this is converted into the Integer 2147482647 as expected.

If I enter the String "4294967298" this is converted to the Integer 2
(Like I say, I understand why this is happening)

What I need to happen is that if the String contains a value that is
out of range I don't even want the creditcount field in the action to
be set.

I have written a custom validator but it appears that the value is set
on the action before this gets called.

Is there some way I can 'intercept' this String and ignore it (i.e
don't even set the action field) if it is going to cause an overflow.

Thanks
Lyallex

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


Mime
View raw message