Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

NPE in FormItem::getAttributeAsBoolean(String property, boolean allowNull)

$
0
0
Be sure your post includes:

1. the *complete* SmartGWT version
SmartClient Version: v9.1p_2014-09-03/Pro Deployment (built 2014-09-03)

2. browser(s) and version(s) involved
Tested with Internet Explorer 11.0.9600.17239 (11.0.11 KB2976627)

5. if there is a JavaScript error, the stack trace logged in the Developer Console (see FAQ)
Tested in Dev mode only.

Code:

00:07:02.212 [ERROR] Uncaught exception escaped
com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses        at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)        at com.smartgwt.client.core.DataClass.fireEvent(DataClass.java:506)        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:59)        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:39)        at java.lang.reflect.Method.invoke(Method.java:612)        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)        at com.google.gwt.core.client.impl.Impl.apply(Impl.java)        at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)        at sun.reflect.GeneratedMethodAccessor46.invoke(Unknown Source)        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:39)        at java.lang.reflect.Method.invoke(Method.java:612)        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)        at java.lang.Thread.run(Thread.java:735) Caused by: java.lang.NullPointerException: null        at com.smartgwt.client.widgets.form.fields.FormItem.getAttributeAsBoolean(FormItem.java:5223)

FormItem.java:
Code:

5220    public Boolean getAttributeAsBoolean(String property, boolean allowNull) {
5221        if (isCreated()) {
5222            Boolean value =  _getAttributeAsBoolean(property);
5223            return value == null && !allowNull ? false : value;
5224        } else {
5225            return JSOHelper.getAttributeAsBoolean(jsObj, property, allowNull);
5226        }
5227    }

6. sample code if applicable

Code:

    TextItem aTextItem = new TextItem("TextItem", "Text Item");

    . . .

    Boolean undefinedAttribute = aTextItem.getAttributeAsBoolean("undefinedAttribute", true);


7. Fix

Changing line 5223 to the following fixes this:

Code:

    return (value != null ? value : (allowNull ? null : false) );
This seems to suggest that the null value is tripping-up the unboxing/boxing.

Viewing all articles
Browse latest Browse all 4756

Trending Articles