subhrajyotim / gwt-mobile-webkit

Automatically exported from code.google.com/p/gwt-mobile-webkit
0 stars 0 forks source link

HostedModeException when calling getInt on a column with a null value #22

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
If ran in hosted mode, calling getInt() on a column with a null value creates a 
HostedModeException. Functions as expected when deployed to server.

Please see attached project.

What is the expected output? What do you see instead?
expected: return a null value, what happens: HostedModeException

What version of the product are you using? On what operating system?
GWT 2.0.4
gwt-mobile-webkit 1.5.1
Win7 x64

Please provide any additional information below.
extract the archive and run the file HelloDatabase-compile.cmd in the 
launch-scripts folder. then run HelloDatabase-shell.cmd. load app, click 
button, check shell window for exception.

alternatively, to see it function correctly, run HelloDatabase-run.cmd and 
navigate to url.

Original issue reported on code.google.com by aj.gray...@gmail.com on 22 Jul 2010 at 3:26

Attachments:

GoogleCodeExporter commented 9 years ago
updated the zip

Original comment by aj.gray...@gmail.com on 22 Jul 2010 at 3:31

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by bguijt on 21 Aug 2010 at 9:04

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
it appears as thought doing anything with a numeric value that can also be null 
is causing a problem. for example, say you have an optional column named "Age" 
in a table named Persons. You create your Person class extending 
JavaScriptObject and add this method:

public native int getAge() /*-{return this.Age;}-*/;

if you call getAge() and the value is null in the db, you get a 
HostedModeException.

It makes sense to get that exception as an int can't be null so, i'm not sure 
you can actually "fix" this.

i have come up with a workaround though it's not ideal:

private native int getAgeJsVal() /*-{
   var ret = -1;
   if ( this.Age )
   {
      ret = this.Age;
   }
   return ret;
}-*/;

then, create a public method like so:

public Integer getAge()
{
   return getAgeJsVal() == -1 ? null : getAgeJsVal();
}

Original comment by aj.gray...@gmail.com on 31 Aug 2010 at 7:48