Im using smartGWT 2.2 with Firefox 3.6 and eclipse IDE
My EntryPoint class shows as following
I have commented on the code where it works and goes wrong.. The CallBack works perfectly but the variable is always null. Please explain whats going on. Thanks!!
My EntryPoint class shows as following
Code:
/** * */ package org.gwt.venus.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.RootPanel; /** * @author npradeeptha * */ import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.DateRange; import com.smartgwt.client.data.RelativeDate; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.ComboBoxItem; import com.smartgwt.client.widgets.form.fields.DateRangeItem; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; public class VenusData implements EntryPoint { /* (non-Javadoc) * @see com.google.gwt.core.client.EntryPoint#onModuleLoad() */ VenusDataSource vds = new VenusDataSource(); private RpcCallServiceAsync rpc = RpcInit.initRpc(); String[] designstrings = null; @Override public void onModuleLoad() { // TODO Auto-generated method stub initializeDesignsArray(); DataSource ds = vds.getDs(); VLayout layout = new VLayout(8); HLayout searchFields = new HLayout(); searchFields.setBackgroundColor("Cyan"); DynamicForm searchForm = new DynamicForm(); ComboBoxItem cmbDesigns = new ComboBoxItem("cmbDesigns", "Design"); ComboBoxItem cmbCriteria = new ComboBoxItem("cmbCriteria", "Criteria"); cmbDesigns.setWidth("*"); cmbCriteria.setWidth("*"); cmbDesigns.setType("comboBox"); //cmbDesigns.setValueMap(designstrings); cmbCriteria.setValueMap("FAST","HARSHA_FAST","NIJ_1"); // Inline FilterEditor Example (MiniDateRangeItem) final DateRangeItem rangeItem = new DateRangeItem("Date"); rangeItem.setWidth("*"); rangeItem.setShowTitle(false); rangeItem.setAllowRelativeDates(true); DateRange dateRange = new DateRange(); dateRange.setRelativeStartDate(new RelativeDate("m")); dateRange.setRelativeEndDate(new RelativeDate("m")); rangeItem.setValue(dateRange); searchForm.setNumCols(6); searchForm.setFields(cmbDesigns,cmbCriteria, rangeItem); searchFields.addMember(searchForm); // Create a ListGrid displaying data from the worldDS and also displaying a FilterEditor final ListGrid dataGrid = new ListGrid(); dataGrid.setWidth(655); dataGrid.setHeight(240); searchFields.setWidth(650); ListGridField builds = new ListGridField("build", "Build"); builds.setWidth(130); ListGridField criteria = new ListGridField("criteria", "Criteria"); ListGridField design = new ListGridField("design", "Design"); ListGridField lut = new ListGridField("lut", "LUT"); ListGridField date = new ListGridField("date", "Date"); ListGridField lut4 = new ListGridField("lut4", "Eq LUT4"); ListGridField ble = new ListGridField("ble", "BLE FFs"); ListGridField slack = new ListGridField("slack", "Slack"); dataGrid.setFields(builds,criteria,design,date,slack,lut,lut4,ble); dataGrid.setDataSource(ds); dataGrid.setAutoFetchData(true); System.out.println(designstrings.length); //*** Gives a null pointer error. cmbDesigns.setValueMap(designstrings); //does not set any values since designstrings is null. layout.addMember(searchFields); layout.addMember(dataGrid); layout.draw(); RootPanel.get("content").add(layout); } public void initializeDesignsArray(){ rpc.getDesign(new AsyncCallback<Design[]>() { @Override public void onFailure(Throwable caught) { System.out.println("Design callback failed"); } @Override public void onSuccess(Design[] result) { //System.out.println(result.length); String[] designs = new String[result.length]; for(int i=0; i<designs.length; i++){ designs[i] = result[i].design; System.out.println(designs[i]); // Prints the items so the callback works and gets data.. } loadDesigns(designs); } }); } public void loadDesigns(String[] result) { designstrings = result; System.out.println(designstrings.length); //works too } }
Comment