Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Jun 2008
    Posts
    35
    Vote Rating
    0
    MartinElkjaer is on a distinguished road

      0  

    Default [FNR] Chart: Bind empty store giving a nullpointer exception

    [FNR] Chart: Bind empty store giving a nullpointer exception


    Hi,

    Before upgrading to GXT 2.1 it was possible to bind an empty store to a ChartConfig - but after upgrade it gives me a Nullpointer exception:

    Code:
    java.lang.NullPointerException: null
    	at com.extjs.gxt.charts.client.model.DataProvider.getMaxYValue(DataProvider.java:161)
    	at com.extjs.gxt.charts.client.model.ChartModel.updateYScale(ChartModel.java:464)
    When looking at DataProvider in SVN I see a fix changing maxYValue and minYValue from double to Double - why ? The getters still returns a double...

    The following testcase works in 2.0.1, but not 2.1:


    Code:
    public class ChartDemo extends ContentPanel {
    	
    	 ListStore<BeanModel> store = null;
    	
    	public ChartDemo() {		
    		
    		final MemoryProxy<List<TrainingSum>> proxy = new MemoryProxy<List<TrainingSum>>(null);
    	    final BaseListLoader<ListLoadResult<BeanModel>> loader = new BaseListLoader<ListLoadResult<BeanModel>>(proxy, new BeanModelReader());
    	    store = new ListStore<BeanModel>(loader);		
    
    		String url = GWT.getHostPageBaseURL() + "chart/open-flash-chart.swf";
    		GWT.log(url, null);
    		final Chart chart = new Chart(url);
    
    		ChartModel model = new ChartModel("Sample by Month", "font-size: 14px; font-family: Verdana; text-align: center;");
    		model.setBackgroundColour("#fefefe");
    		model.setLegend(new Legend(Position.TOP, true));
    		model.setScaleProvider(ScaleProvider.ROUNDED_NEAREST_SCALE_PROVIDER);
    		
    
    	    BarChart bar = new BarChart(BarStyle.GLASS);  
    	    bar.setColour("#00aa00");  
    	    BarDataProvider barProvider = new BarDataProvider("sum", "month");  
    	    barProvider.bind(store);  
    	    bar.setDataProvider(barProvider);  
    
    	    
    	    LineChart line = new LineChart();  
    	    line.setAnimateOnShow(true);  
    	    line.setText("Average");  
    	    line.setColour("#FF0000");  
    	    LineDataProvider lineProvider = new LineDataProvider("sum");  
    	    lineProvider.bind(store);  
    	    line.setDataProvider(lineProvider);  
    	    model.addChartConfig(line);  
    	    model.addChartConfig(bar); 
    	    
    	    chart.setChartModel(model);
    	    chart.setSize(300, 300);
    	    add(chart, new RowData(1,1));
    		
    	    
    	    Button btnLoad = new Button("Load data");
    	    btnLoad.addSelectionListener(new SelectionListener<ButtonEvent>() {
    			
    			@Override
    			public void componentSelected(ButtonEvent ce) {
    				store.removeAll();
    				proxy.setData(createTestData());
    				loader.load();
    			}
    		});
    	    
    	    add(btnLoad);
    	    
    	    Button btnClear = new Button("Delete data");
    	    btnClear.addSelectionListener(new SelectionListener<ButtonEvent>() {
    			@Override
    			public void componentSelected(ButtonEvent ce) {
    				store.removeAll();
    			}
    		});
    	    add(btnClear);
    		
    	}
    
    
    	private List<TrainingSum> createTestData() {
    		List<TrainingSum> res = new ArrayList<TrainingSum>();
    		res.add(new TrainingSum(1,15d));
    		res.add(new TrainingSum(2,12d));
    		return res;			
    	}
    	
    	class TrainingSum implements BeanModelTag, Serializable{
    
    
    
    		/**
    		 * 
    		 */
    		private static final long serialVersionUID = 1L;
    		private Double sum;
    		private int month;
    		
    		public TrainingSum(int month, Double value) {
    			setMonth(month);
    			setSum(value);
    			
    			// TODO Auto-generated constructor stub
    		}
    
    		public void setSum(Double sum) {
    			this.sum = sum;
    		}
    
    		public Double getSum() {
    			return sum;
    		}
    
    		public void setMonth(int month) {
    			this.month = month;
    		}
    
    		public int getMonth() {
    			return month;
    		}
    		
    		
    	}

  2. #2
    Sencha User
    Join Date
    Jun 2008
    Posts
    35
    Vote Rating
    0
    MartinElkjaer is on a distinguished road

      0  

    Default


    Hi,

    Changing the getter and setter in Dataprovider fixes my problem - don't know if this is the correct way :-) :
    Code:
      protected double getMaxYValue() {
        return maxYValue==null?0d:maxYValue;
      }
    
      protected double getMinYValue() {
        return minYValue==null?0d:minYValue;
      }
    -Martin

  3. #3
    Ext User
    Join Date
    Mar 2008
    Location
    Berlin, Germany
    Posts
    58
    Vote Rating
    0
    HerrB is on a distinguished road

      0  

    Default


    Thx, I've seen the problem, but thanks to you, at least there is a fast workaround.

    Eventually, changing getMaxYValue and getMinYValue to Double might be an alternative solution (haven' checked, yet). Maybe changing minYValue and maxYValue itself to Double solves our other problem (y axis starts almost always at 0) - I will take a look tomorrow...

    Regards,

    HerrB

  4. #4
    Sencha User
    Join Date
    Jun 2008
    Posts
    35
    Vote Rating
    0
    MartinElkjaer is on a distinguished road

      0  

    Default


    Anyone ? Maybe the GXT team could confirm if it is a bug ?

    -Martin

  5. #5
    Ext User
    Join Date
    Mar 2008
    Location
    Berlin, Germany
    Posts
    58
    Vote Rating
    0
    HerrB is on a distinguished road

      0  

    Default


    I'm not from the team, but I could confirm: It's a bug. minYValue and maxYValue were defined as native double in previous versions. Now, they are Double objects and as they are null until the first calculation has been made, (double)return of null gets you the exception.

    Your workaround should be fine for the time being. I hope to find time on the weekend to play around with the new code...

    Regards,

    HerrB

  6. #6
    Ext User
    Join Date
    Dec 2009
    Posts
    8
    Vote Rating
    0
    bbg5ne is on a distinguished road

      0  

    Default


    Hi!
    I have the same problem, but in my case I'm sure the store is not empty, but it's very big.
    I don't know if the reason is the same.

    The error is this:
    Code:
    10:47:54.425 [ERROR] [jardin] Uncaught exception escaped
    java.lang.NullPointerException: null
        at com.extjs.gxt.charts.client.model.DataProvider.getMaxYValue(DataProvider.java:161)
        at com.extjs.gxt.charts.client.model.ChartModel.updateYScale(ChartModel.java:464)
        at com.extjs.gxt.charts.client.Chart.processModel(Chart.java:245)
        at com.extjs.gxt.charts.client.Chart.setChartModel(Chart.java:168)
        at it.fub.jardin.client.mvc.JardinController.onShowChart(JardinController.java:924)
        at it.fub.jardin.client.mvc.JardinController.handleEvent(JardinController.java:297)
        at com.extjs.gxt.ui.client.mvc.Dispatcher.dispatch(Dispatcher.java:244)
        at com.extjs.gxt.ui.client.mvc.Dispatcher.dispatch(Dispatcher.java:172)
        at com.extjs.gxt.ui.client.mvc.Dispatcher.forwardEvent(Dispatcher.java:96)
        at it.fub.jardin.client.widget.JardinSelectColumnsForChartPopUp$1.onClick(JardinSelectColumnsForChartPopUp.java:122)
        at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:54)
        at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:1)
        at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.fireEvent(HandlerManager.java:65)
        at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.access$1(HandlerManager.java:53)
        at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:178)
        at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:52)
        at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
        at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:100)
        at com.extjs.gxt.ui.client.widget.WidgetComponent.onBrowserEvent(WidgetComponent.java:88)
        at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1307)
        at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1263)
        at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        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:157)
        at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1713)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
        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:188)
        at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        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:157)
        at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1668)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
        at java.lang.Thread.run(Thread.java:619)
    and the code is:

    Code:
    private void onShowChart(ArrayList<String> dataToChart) {
    
        /*
         * Prendi il tabItem per recuperare la toolbar (formato d'esportazione) e la
         * grid (config dei record da esportare, colonne visibili e criteri di
         * ricerca)
         */
        Integer resultset = Integer.valueOf(dataToChart.get(1));
        String title = dataToChart.get(2);
        String value = dataToChart.get(3);
        ChartType type = ChartType.valueOf(dataToChart.get(0));
    
        JardinTabItem item = view.getItemByResultsetId(resultset);
    
        /* Prendi la griglia */
        JardinGrid grid = item.getGrid();
    
        /* Prendi gli ID delle prime due colonne visibili */
        ColumnModel columnModel = grid.getColumnModel();
        String cx = title;
        String cy = value;
    
        String url = "resources/chart/open-flash-chart.swf";
    
        Chart chart = new Chart(url);
        chart.setBorders(false);
    
        String resultsetAlias = user.getResultsetFromId(resultset).getAlias();
        ChartModel cm = new ChartModel(resultsetAlias);
        cm.setBackgroundColour("#ffffff");
        
        SearchParams searchParams = grid.getSearchparams();
        ListStore<BaseModelData> store = view.getStore(searchParams);
        store.getLoader().load();
        switch (type) {
        case BAR:
          FilledBarChart bar = new FilledBarChart();
          bar.setAnimateOnShow(true);
          bar.setTooltip("#val#");
          BarDataProvider bdp = new BarDataProvider(cy, cx);
          bdp.bind(store);
          System.out.println(store);
          bar.setDataProvider(bdp);
          cm.setScaleProvider(ScaleProvider.ROUNDED_NEAREST_SCALE_PROVIDER);
          cm.addChartConfig(bar);
          break;
        case PIE:
        default:
          PieChart pie = new PieChart();
          pie.setAlpha(0.5f);
          pie.setNoLabels(false);
          pie.setTooltip("#label# #val#<br>#percent#");
          pie.setGradientFill(true);
          pie.setColours(chartColors);
          PieDataProvider pdp = new PieDataProvider(cy, cx);
          pdp.bind(store);
          pie.setDataProvider(pdp);
          cm.addChartConfig(pie);
          break;
        }
        chart.setChartModel(cm);
    
        Dialog d = new Dialog();
        d.getButtonBar().removeAll();
        d.setMaximizable(true);
        d.setHeading("Grafico " + resultsetAlias);
        d.setIconStyle("icon-chart");
        d.setLayout(new FitLayout());
        d.setSize(500, 500);
        d.add(chart);
        d.show();
      }
    The very strange thing is if I create a piechart or a barchart with the same store, the first will show without any problem, whereas the second show me the "java.lang.NullPointerException: null".

    How can I solve it?

    Thanks
    Mk

  7. #7
    Ext User
    Join Date
    Dec 2009
    Posts
    8
    Vote Rating
    0
    bbg5ne is on a distinguished road

      0  

    Default


    If I remove the line cm.setScaleProvider(ScaleProvider.ROUNDED_NEAREST_SCALE_PROVIDER);

    It shows me the barchart, but the bars are too long and they exceed the chart area.

    Does anyone know how to solve it?

    Thanks
    Mk

  8. #8
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    One solution was already presented in this thread. IT will be fixed with the next release.

  9. #9
    Ext User
    Join Date
    Dec 2009
    Posts
    8
    Vote Rating
    0
    bbg5ne is on a distinguished road

      0  

    Default


    ops, to change the getter and setter in Dataprovider do I have to create the gxt.jar.
    How?
    I put src folder in a new project in eclipse workspace and I right click on this project:
    export->jar file
    Am I wrong?
    Thanks
    Mk

  10. #10
    Ext User
    Join Date
    Mar 2008
    Location
    Berlin, Germany
    Posts
    58
    Vote Rating
    0
    HerrB is on a distinguished road

      0  

    Default


    No, just create the exact extgwt package structure in your project (com.ext ... etc.), copy and insert the DataProvider.class into your project and change the code. Running your app will use your "fixed" version of the class instead of the original one.

    Note, that this will get you problems with newer releases of Ext GWT (as your version has to be updated - if still neccessary - by yourself).

    Regards,

    HerrB

Similar Threads

  1. Replies: 4
    Last Post: 28 Apr 2010, 3:55 AM
  2. [FNR] Exception on tracking hierarchy.
    By nika.setar in forum Ext GWT: Bugs (2.x)
    Replies: 1
    Last Post: 29 Mar 2010, 8:50 AM
  3. [3.x r5790] Ext.chart.Chart.onDestroy causes exception in IE6
    By jay@moduscreate.com in forum Ext 3.x: Bugs
    Replies: 1
    Last Post: 16 Dec 2009, 5:38 AM
  4. Replies: 2
    Last Post: 10 Dec 2009, 9:23 AM
  5. Paging toolBar not doing bind() when store is empty
    By varsha.kothari in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 28 Aug 2008, 6:49 AM

Thread Participants: 6

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi