Thank you very much!! I got it working. What I'm not understanding though is, why the DataSource ds doesn't have any problem with being handled outside of the callback. I would greatly appreciate it if you could explain this to me.. Thanks!!
P.S I used to have do the exact same with the dataString using another class to call the RPC and assigning it to a class variable similar to here and then instantiating the class in the EntryPoint class exactly as i have done for the DataSource. DataSource works but not designStrings. Thank you in advance :) On Jul 8, 10:34 pm, Sean <slough...@gmail.com> wrote: > You're running into an async problem. > > The call back happens asynchronusly, meaning, just because you kick > off the RPC service does not mean that designStrings will have a value > in it before you execute the code after you kick off the RPC. > > Get rid of anything that uses designStrings outside of the callback or > loadDesigns. Looking over your code quickly, what you want to do is in > loadDesign, iterate through result and put it into your Combo Box. > > On Jul 8, 3:31 am, npradeeptha <nipuna.ro...@gmail.com> wrote: > > > > > Heres my code.. I'm using GWT 2.0.3 with smartGWT 2.2. I think this is > > a GWT related question.. > > > [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 > > > } > > > } > > > [/CODE] > > > 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!! -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.