CC crashes when integer field has 10 or more characters

Hi all,

CommCare crashes in build 1.0.X whenever 10 or more digits are entered into
an integer field throwing an “Illegal Argument
java/lang/IllegalArgumentException”. Is it possible to create a text field
that defaults to numeric entry? Is it possible to restrict entry to 10
characters during entry rather than through post-validation?

Thanks,
Jon

Jon,

You’ve touched on the problem here, it’s an integer field, so 10 digits is
overflowing the size of the field. It’s not possible as of yet to create a
text field that defaults to numeric entry, we’re still trying to figure out
how to support that in a cross-platform compliant way.

You should be able to restrict entry to 10 numbers using a regular
expression, but it’s kind of a high level constraint, so the users might
have a problem proceeding in some strange edge cases. There’s currently no
support for input masks (IE: simply not letting the user input the 11th
character)

-Clayton

··· On Mon, Dec 6, 2010 at 5:28 AM, Jonathan Payne wrote:

Hi all,

CommCare crashes in build 1.0.X whenever 10 or more digits are entered into
an integer field throwing an “Illegal Argument
java/lang/IllegalArgumentException”. Is it possible to create a text field
that defaults to numeric entry? Is it possible to restrict entry to 10
characters during entry rather than through post-validation?

Thanks,
Jon

Attached the rms files and jad/jar…

ANC_error.zip (613 KB)

··· On Mon, Dec 6, 2010 at 5:28 AM, Jonathan Payne wrote:

Hi all,

CommCare crashes in build 1.0.X whenever 10 or more digits are entered into
an integer field throwing an “Illegal Argument
java/lang/IllegalArgumentException”. Is it possible to create a text field
that defaults to numeric entry? Is it possible to restrict entry to 10
characters during entry rather than through post-validation?

Thanks,
Jon

That’s what I suspected. I’ll solve on my end, but probably a good idea to
catch that exception.

Thanks,
Jon

··· On Mon, Dec 6, 2010 at 11:21 AM, Clayton Sims wrote:

Jon,

You’ve touched on the problem here, it’s an integer field, so 10 digits is
overflowing the size of the field. It’s not possible as of yet to create a
text field that defaults to numeric entry, we’re still trying to figure out
how to support that in a cross-platform compliant way.

You should be able to restrict entry to 10 numbers using a regular
expression, but it’s kind of a high level constraint, so the users might
have a problem proceeding in some strange edge cases. There’s currently no
support for input masks (IE: simply not letting the user input the 11th
character)

-Clayton

On Mon, Dec 6, 2010 at 5:28 AM, Jonathan Payne paynejd@gmail.com wrote:

Hi all,

CommCare crashes in build 1.0.X whenever 10 or more digits are entered
into an integer field throwing an “Illegal Argument
java/lang/IllegalArgumentException”. Is it possible to create a text field
that defaults to numeric entry? Is it possible to restrict entry to 10
characters during entry rather than through post-validation?

Thanks,
Jon

Yeah, I thought we actually had a while ago, it must have snuck back in.
Definitely something that shouldn’t throw an exception.

-Clayton

··· On Tue, Dec 7, 2010 at 2:31 AM, Jonathan Payne wrote:

That’s what I suspected. I’ll solve on my end, but probably a good idea to
catch that exception.

Thanks,
Jon

On Mon, Dec 6, 2010 at 11:21 AM, Clayton Sims csims@dimagi.com wrote:

Jon,

You’ve touched on the problem here, it’s an integer field, so 10 digits is
overflowing the size of the field. It’s not possible as of yet to create a
text field that defaults to numeric entry, we’re still trying to figure out
how to support that in a cross-platform compliant way.

You should be able to restrict entry to 10 numbers using a regular
expression, but it’s kind of a high level constraint, so the users might
have a problem proceeding in some strange edge cases. There’s currently no
support for input masks (IE: simply not letting the user input the 11th
character)

-Clayton

On Mon, Dec 6, 2010 at 5:28 AM, Jonathan Payne paynejd@gmail.com wrote:

Hi all,

CommCare crashes in build 1.0.X whenever 10 or more digits are entered
into an integer field throwing an “Illegal Argument
java/lang/IllegalArgumentException”. Is it possible to create a text field
that defaults to numeric entry? Is it possible to restrict entry to 10
characters during entry rather than through post-validation?

Thanks,
Jon

A few more thoughts on this… This applies to several fields, but the one
i’m thinking about most is the phone number. Here it is 10 digits, so it
won’t work in the integer field unless we’re lucky enough that it begins
with 12. Here are the options I can think of, in order of preference:

  1. Is the “long” variable type supported? This could do the trick.

  2. Another alternative is the float field. There is no error when entering
    10 or more digits, but it switches to scientific format with 10 digits or
    more. I haven’t looked into the accuracy of the variable, but is float
    accurate up to 10 digits and is there a way to force it to display all 10
    numbers rather than display in scientific format after entry?

  3. Text field will work, but will require extra steps to switch to number
    format, and will allow non-numeric characters to be entered until validation
    occurs, which is pretty annoying. Clayton, you already addressed this and it
    sounds like it might be a ways off before CommCare can support setting input
    type to numeric by default?

Has anyone else dealt with this problem and have ideas for a solution?

Finally, it should be high priority to handle the IllegalArgumentException.
There is no way in the interface to restrict the data that is entered to be
within the range supported by the int variable type, so this could happen on
any integer field in any form.

Thanks,
Jon

··· On Tue, Dec 7, 2010 at 3:31 AM, Jonathan Payne wrote:

That’s what I suspected. I’ll solve on my end, but probably a good idea to
catch that exception.

Thanks,
Jon

On Mon, Dec 6, 2010 at 11:21 AM, Clayton Sims csims@dimagi.com wrote:

Jon,

You’ve touched on the problem here, it’s an integer field, so 10 digits is
overflowing the size of the field. It’s not possible as of yet to create a
text field that defaults to numeric entry, we’re still trying to figure out
how to support that in a cross-platform compliant way.

You should be able to restrict entry to 10 numbers using a regular
expression, but it’s kind of a high level constraint, so the users might
have a problem proceeding in some strange edge cases. There’s currently no
support for input masks (IE: simply not letting the user input the 11th
character)

-Clayton

On Mon, Dec 6, 2010 at 5:28 AM, Jonathan Payne paynejd@gmail.com wrote:

Hi all,

CommCare crashes in build 1.0.X whenever 10 or more digits are entered
into an integer field throwing an “Illegal Argument
java/lang/IllegalArgumentException”. Is it possible to create a text field
that defaults to numeric entry? Is it possible to restrict entry to 10
characters during entry rather than through post-validation?

Thanks,
Jon

Answers (helpful for the immediate use cases) are below. The long term
solution here will probably be supporting the definition of custom types
somewhere in the XForm, which is the standard approach for these kinds of
data type validation checks, but for now I think it makes sense to focus on
using what’s available and supporting the Long or decimal datatype better.

-Clayton

A few more thoughts on this… This applies to several fields, but the one
i’m thinking about most is the phone number. Here it is 10 digits, so it
won’t work in the integer field unless we’re lucky enough that it begins
with 12. Here are the options I can think of, in order of preference:

  1. Is the “long” variable type supported? This could do the trick.

It looks like ‘long’ is a supported datatype. Also: xsd:decimal in the
specification has to support a minimum of 18 digits, so it might be a good
candidate

  1. Another alternative is the float field. There is no error when entering
    10 or more digits, but it switches to scientific format with 10 digits or
    more. I haven’t looked into the accuracy of the variable, but is float
    accurate up to 10 digits and is there a way to force it to display all 10
    numbers rather than display in scientific format after entry?

There’s almost certainly a way to force it to display all 10 numbers, yeah.

  1. Text field will work, but will require extra steps to switch to number
    format, and will allow non-numeric characters to be entered until validation
    occurs, which is pretty annoying. Clayton, you already addressed this and it
    sounds like it might be a ways off before CommCare can support setting input
    type to numeric by default?

Yeah, the number of platforms where setting numbers to be the default entry
mode would be meaningful is pretty small, so we’d have to work in a trigger
or a hint somewhere that that is the case.

Has anyone else dealt with this problem and have ideas for a solution?

Finally, it should be high priority to handle the IllegalArgumentException.
There is no way in the interface to restrict the data that is entered to be
within the range supported by the int variable type, so this could happen on
any integer field in any form.

Agreed, either the interface shouldn’t let you input an invalid integer, or
the error shouldn’t be thrown as an exception.

··· On Tue, Dec 7, 2010 at 10:58 AM, Jonathan Payne wrote:

Thanks,
Jon

On Tue, Dec 7, 2010 at 3:31 AM, Jonathan Payne paynejd@gmail.com wrote:

That’s what I suspected. I’ll solve on my end, but probably a good idea to
catch that exception.

Thanks,
Jon

On Mon, Dec 6, 2010 at 11:21 AM, Clayton Sims csims@dimagi.com wrote:

Jon,

You’ve touched on the problem here, it’s an integer field, so 10 digits
is overflowing the size of the field. It’s not possible as of yet to create
a text field that defaults to numeric entry, we’re still trying to figure
out how to support that in a cross-platform compliant way.

You should be able to restrict entry to 10 numbers using a regular
expression, but it’s kind of a high level constraint, so the users might
have a problem proceeding in some strange edge cases. There’s currently no
support for input masks (IE: simply not letting the user input the 11th
character)

-Clayton

On Mon, Dec 6, 2010 at 5:28 AM, Jonathan Payne paynejd@gmail.comwrote:

Hi all,

CommCare crashes in build 1.0.X whenever 10 or more digits are entered
into an integer field throwing an “Illegal Argument
java/lang/IllegalArgumentException”. Is it possible to create a text field
that defaults to numeric entry? Is it possible to restrict entry to 10
characters during entry rather than through post-validation?

Thanks,
Jon