Results 1 to 6 of 6
  1. #1
    pinotje's Avatar
    pinotje is offline Member
    Join Date
    Dec 2010
    Location
    Belgium
    Posts
    14
    Rep Power
    0

    Default How to run a "Add"-method from a method?

    Hi all,


    I've a Java code (GWT):

    Java Code:
    package com.practicum.client.out;
    
    import java.util.ArrayList;
    import com.google.gwt.core.client.GWT;
    import com.google.gwt.user.client.rpc.AsyncCallback;
    import com.google.gwt.user.client.ui.Widget; 
    import com.google.gwt.visualization.client.DataTable;
    import com.google.gwt.visualization.client.AbstractDataTable.ColumnType;
    import com.google.gwt.visualization.client.visualizations.corechart.AxisOptions;
    import com.google.gwt.visualization.client.visualizations.corechart.ColumnChart;
    import com.google.gwt.visualization.client.visualizations.corechart.CoreChart;
    import com.google.gwt.visualization.client.visualizations.corechart.Options;
    import com.practicum.client.Product;
    import com.practicum.client.rpc.ProductService;
    import com.practicum.client.rpc.ProductServiceAsync;
    
    
    public class DataOutColumnChart {
    	private DataTable data = DataTable.create();
    	private Options options = CoreChart.createOptions();
    	private final ProductServiceAsync productService = GWT.create(ProductService.class);
    	
    	public DataOutColumnChart(Runnable runnable) {
    	}
    
    	public Widget createColumnChartView() {
    		/* create a datatable */
    		data.addColumn(ColumnType.STRING, "Price");
    		data.addColumn(ColumnType.NUMBER, "EUR");
    		addData("A for Apple", 123); // THIS WORKS
    		addData("B for Boy", 123); // THIS WORKS
    
    		/* create column chart */
    		options.setWidth(400);
    		options.setHeight(300);
    		options.setBackgroundColor("#e8e8e9");
    		AxisOptions vAxisOptions = AxisOptions.create();
    	    vAxisOptions.setMinValue(0);
    	    options.setVAxisOptions(vAxisOptions);
    	   
    		return new ColumnChart(data, options);
    	}
    
    
    	public void getWinkels() {
    		productService.getWinkels(new AsyncCallback<ArrayList<Product>>() {
    			public void onFailure(Throwable caught) {
    			}
    
    			public void onSuccess(ArrayList<Product> result) {
    				for (Product p : result) {
    					addData("C for Candy", 123); // THIS DONT WORK?
    					System.out.println(p.getWinkel()); // THIS WORKS
    				}
    			}
    		});
    	}
    	
    	
    	public void addData(String winkel, int prijs) {
    		int rownr = data.addRow();
    		data.setValue(rownr, 0, winkel);
    		data.setValue(rownr, 1, prijs);
    	}
    	
    }
    Can someone explain me why line 30 and 31 works,
    but line 51 not works? Simply nothing happens on line 52...

    I've tried anything... :(

    Thanks in advance!

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default Re: How to run a "Add"-method from a method?

    Fully explain what "not works" means. How do you know "nothing happens". Try adding a print statement to the addData method. Also, you could try creating a SSCCE to demonstrate your problem.

  3. #3
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default Re: How to run a "Add"-method from a method?


  4. #4
    pinotje's Avatar
    pinotje is offline Member
    Join Date
    Dec 2010
    Location
    Belgium
    Posts
    14
    Rep Power
    0

    Default Re: How to run a "Add"-method from a method?

    Quote Originally Posted by Junky View Post
    Fully explain what "not works" means. How do you know "nothing happens". Try adding a print statement to the addData method. Also, you could try creating a SSCCE to demonstrate your problem.
    I'm 100% sure line #52 not work,
    because if it works, it will shown a "C for Candy" bar in the GWT's ColumnChart,
    and furthermore line 30 and 31 works perfect, so why line #52 doesn't work?

    I think it has something to do with line #19....
    Maybe it must be "public" instead of "private".
    Or maybe it must be "private final static etc..."
    Sorry I'm a noob in Java... =P

    Thanks in advance...
    Last edited by pinotje; 12-02-2011 at 04:50 AM.

  5. #5
    pinotje's Avatar
    pinotje is offline Member
    Join Date
    Dec 2010
    Location
    Belgium
    Posts
    14
    Rep Power
    0

    Default Re: How to run a "Add"-method from a method?

    Quote Originally Posted by Junky View Post
    Yes it is the same question, but it's posted on another Java forum website.
    So that is allowed, am I right?

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: How to run a "Add"-method from a method?

    Quote Originally Posted by pinotje View Post
    Yes it is the same question, but it's posted on another Java forum website.
    So that is allowed, am I right?
    It won't get you banned from the forum, if that's what you mean, but it's not appreciated when you do this and don't notify us that you've done this. Cross-posting can frustrate anyone who tries to help you only to find out later that the same answer was given hours ago in a cross-posted thread. No one likes wasting their time, especially a volunteer. The polite thing to do would be to at least provide links in both cross-posts to each other.

Similar Threads

  1. How Does Java Find the "main" Method?
    By bobg in forum New To Java
    Replies: 3
    Last Post: 05-16-2011, 04:09 AM
  2. Reflection Invoking method of "super" class
    By Shellback3 in forum Advanced Java
    Replies: 2
    Last Post: 01-31-2011, 04:50 PM
  3. Replies: 12
    Last Post: 10-10-2010, 11:17 PM
  4. Replies: 3
    Last Post: 05-25-2009, 08:50 PM
  5. Replies: 2
    Last Post: 04-28-2009, 04:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •