Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Boolean FormItem.getFilterWithValue() returns null

    Hi Isomorphic,

    ComboBoxItem.getFilterWithValue() has Boolean and not boolean return type. It sometimes is null for me, so !myComboBoxItem.getFilterWithValue() results in an NPE.

    Of course I can guard it, but as it never should return null IMO, it would be better if you changed the framework code. Also this would save lines of code for everyone.

    This is similar to the issue in e.g. this thread.

    Best regards
    Blama

    #2
    Thanks for the notification. We'll take a look.

    Regards
    Isomorphic Software

    Comment


      #3
      Hi Isomorphic,

      you never answered in this thread. Now one of my users stumped upon a similar case:

      BuiltInDS.java
      Code:
      package com.smartgwt.sample.client;
      
      import java.util.ArrayList;
      import java.util.List;
      
      import com.google.gwt.core.client.EntryPoint;
      import com.smartgwt.client.core.KeyIdentifier;
      import com.smartgwt.client.data.DSRequest;
      import com.smartgwt.client.data.DataSource;
      import com.smartgwt.client.types.ExportFormat;
      import com.smartgwt.client.util.PageKeyHandler;
      import com.smartgwt.client.util.Page;
      import com.smartgwt.client.util.SC;
      import com.smartgwt.client.widgets.IButton;
      import com.smartgwt.client.widgets.events.ClickEvent;
      import com.smartgwt.client.widgets.events.ClickHandler;
      import com.smartgwt.client.widgets.grid.ListGrid;
      import com.smartgwt.client.widgets.grid.ListGridField;
      import com.smartgwt.client.widgets.layout.VStack;
      
      public class BuiltInDS implements EntryPoint {
      	private ListGrid boundList;
      	private VStack vStack;
      	private IButton exportBtn;
      
      	public void onModuleLoad() {
      		KeyIdentifier debugKey = new KeyIdentifier();
      		debugKey.setCtrlKey(true);
      		debugKey.setKeyName("D");
      
      		Page.registerKey(debugKey, new PageKeyHandler() {
      			public void execute(String keyName) {
      				SC.showConsole();
      			}
      		});
      		
      		vStack = new VStack();
      		vStack.setHeight100();
      		vStack.setWidth100();
      		boundList = new ListGrid(DataSource.get("animals"));
      		boundList.setShowFilterEditor(true);
      		boundList.setHeight(400);
      		boundList.setCanEdit(true);
      		boundList.setAutoFetchData(true);
      
      		vStack.addMember(boundList);
      
      		exportBtn = new IButton("Export");
      		exportBtn.addClickHandler(new MyClickHandler());
      		vStack.addMember(exportBtn);
      		vStack.draw();
      	}
      
      	private class MyClickHandler implements ClickHandler {
      		@Override
      		public void onClick(ClickEvent event) {
      			DSRequest requestProperties = new DSRequest() {
      				{
      					setExportAs(ExportFormat.OOXML);
      					setExportFilename("export");
      				}
      			};
      			List<String> l = getVisibleFieldList(boundList);
      			requestProperties.setExportFields(l.toArray(new String[l.size()]));
      			boundList.exportClientData(requestProperties);
      		}
      	}
      
      	private List<String> getVisibleFieldList(ListGrid lg) {
      		List<String> l = new ArrayList<String>();
      		for (ListGridField lgf : lg.getFields())
      			if (!lgf.getHidden())
      				l.add(lgf.getName());
      		return l;
      	}
      };
      Dev Mode logs:
      Code:
      14:27:54.877 [ERROR] [builtinds] Uncaught exception escaped
      
      com.google.gwt.event.shared.UmbrellaException: Exception caught: null
          at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
          at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
          at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:72)
          at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
          at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:341)
          at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:222)
          at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:137)
          at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:589)
          at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:293)
          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:299)
          at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
          at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:72)
          at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
          at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:296)
          at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:551)
          at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:368)
          at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.NullPointerException: null
          at com.smartgwt.sample.client.BuiltInDS.getVisibleFieldList(BuiltInDS.java:72)
          at com.smartgwt.sample.client.BuiltInDS.access$1(BuiltInDS.java:69)
          at com.smartgwt.sample.client.BuiltInDS$MyClickHandler.onClick(BuiltInDS.java:63)
          at com.smartgwt.client.widgets.events.ClickEvent.dispatch(ClickEvent.java:111)
          at com.smartgwt.client.widgets.events.ClickEvent.dispatch(ClickEvent.java:1)
          at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
          at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
          at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
          at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
          at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
          at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
          at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:72)
          at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
          at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:341)
          at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:222)
          at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:137)
          at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:589)
          at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:293)
          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:299)
          at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
          at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:72)
          at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
          at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:296)
          at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:551)
          at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:368)
          at java.lang.Thread.run(Unknown Source)
      Click the button. lgf.getHidden() is null, therefore the "!" results in a NPE. This has worked before (until around ~2 weeks?) flawlessly.
      I'm using v10.0p_2015-08-21/PowerEdition Deployment 2015-08-21.

      Best regards
      Blama
      Last edited by Blama; 24 Aug 2015, 04:28.

      Comment


        #4
        Thanks for the reminder on getFilterWithValue() - we've made a change to avoid that returning null.
        Please try the next nightly build (Aug 26 or above).

        On the other issue - seems like ListGrid.fieldIsVisible() is the correct API to use here, rather than looking at ListGridField.hidden.

        Regards
        Isomorphic Software

        Comment

        Working...
        X