jmccormack
8 Jul 2009, 5:35 PM
Hi Everyone,
First time posting on the forum and a noob with Ext-GWT. I am really liking the Ext-GWT controls and such but I am running into some issues with the 2.x version.
Some background on what I am doing. I have a very basic php file that kicks out a json array. This all works correctly and does not appear to have any issues or at least none that I have found :-). What I am running into is that I have a testbed app that populates a Ext-GWT grid based on this json data.
This works as expected when use Ext-GWT 1.x but when I try it with 2.x I basically get nothing. The way I have confirmed this just by switching the GXT jar from a 1.x to a 2.x version of the jar and vice versa. If there is a better way to test differences between the 2 versions, please let me know.
So I guess my questions are, is 1.x not compatible with 2.x? If they are not 100% compatible, is there documentation that outlines the incompatibilities.
Has anyone else run into issues with migrating to 2.x with regards to the JsonReader (or anything else for that matter)?
Does anyone have any suggestions as to what might be going on?
I suspect the issue is in the JsonReader and the retrieval of that data but I am not 100% sure since I don't get any errors. Are there any tricks for debugging these kind of issues? I have firebug installed in firefox and it appears the request is not even being made for the data when using the 2.x version.
I would appreciate any help or suggestions and I have posted the code below.
Thanks,
Jason
Notes about the code. Since I am a noob I have been using the examples provided as a starting point as I get familiar with the libraries, so if it looks like familiar code that is why. I also have stripped out a bunch of code I had commented out so if I have an issues in the code sample that is likely the reason.
package testbed;
import java.util.ArrayList;
import java.util.List;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.data.BaseListLoader;
import com.extjs.gxt.ui.client.data.HttpProxy;
import com.extjs.gxt.ui.client.data.JsonReader;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.user.client.ui.RootPanel;
public class JSONGridTest
{
public void build()
{
LayoutContainer layout = new LayoutContainer();
layout.setLayout(new FlowLayout(10));
List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
columns.add(new ColumnConfig("first_name", "First Name", 100));
columns.add(new ColumnConfig("last_name", "Last Name", 165));
// create the column model
ColumnModel cm = new ColumnModel(columns);
// defines the xml structure
ModelType type = new ModelType();
type.root = "RECORDS";
type.addField("first_name", "first_name");
type.addField("last_name", "last_name");
// use a http proxy to get the data
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, "http://localhost/PHPExternalJSONData/service.php");
HttpProxy proxy = new HttpProxy(builder);
// need a loader, proxy, and reader
final BaseListLoader loader = new BaseListLoader(proxy, new JsonReader(type));
ListStore<ModelData> store = new ListStore<ModelData>(loader);
final Grid<ModelData> grid = new Grid<ModelData>(store, cm);
grid.setBorders(true);
grid.setLoadMask(true);
grid.getView().setEmptyText("Please hit the load button.");
ContentPanel panel = new ContentPanel();
panel.setFrame(true);
panel.setCollapsible(true);
panel.setAnimCollapse(false);
panel.setButtonAlign(HorizontalAlignment.CENTER);
panel.setHeading("JSON Table Demo");
panel.setLayout(new FitLayout());
panel.add(grid);
panel.setSize(575, 350);
// add buttons
Button load = new Button("Load JSON", new SelectionListener<ButtonEvent>()
{
public void componentSelected(ButtonEvent ce)
{
loader.load();
}
});
panel.addButton(load);
layout.add(panel);
RootPanel.get().add(layout);
}
}
First time posting on the forum and a noob with Ext-GWT. I am really liking the Ext-GWT controls and such but I am running into some issues with the 2.x version.
Some background on what I am doing. I have a very basic php file that kicks out a json array. This all works correctly and does not appear to have any issues or at least none that I have found :-). What I am running into is that I have a testbed app that populates a Ext-GWT grid based on this json data.
This works as expected when use Ext-GWT 1.x but when I try it with 2.x I basically get nothing. The way I have confirmed this just by switching the GXT jar from a 1.x to a 2.x version of the jar and vice versa. If there is a better way to test differences between the 2 versions, please let me know.
So I guess my questions are, is 1.x not compatible with 2.x? If they are not 100% compatible, is there documentation that outlines the incompatibilities.
Has anyone else run into issues with migrating to 2.x with regards to the JsonReader (or anything else for that matter)?
Does anyone have any suggestions as to what might be going on?
I suspect the issue is in the JsonReader and the retrieval of that data but I am not 100% sure since I don't get any errors. Are there any tricks for debugging these kind of issues? I have firebug installed in firefox and it appears the request is not even being made for the data when using the 2.x version.
I would appreciate any help or suggestions and I have posted the code below.
Thanks,
Jason
Notes about the code. Since I am a noob I have been using the examples provided as a starting point as I get familiar with the libraries, so if it looks like familiar code that is why. I also have stripped out a bunch of code I had commented out so if I have an issues in the code sample that is likely the reason.
package testbed;
import java.util.ArrayList;
import java.util.List;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.data.BaseListLoader;
import com.extjs.gxt.ui.client.data.HttpProxy;
import com.extjs.gxt.ui.client.data.JsonReader;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.user.client.ui.RootPanel;
public class JSONGridTest
{
public void build()
{
LayoutContainer layout = new LayoutContainer();
layout.setLayout(new FlowLayout(10));
List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
columns.add(new ColumnConfig("first_name", "First Name", 100));
columns.add(new ColumnConfig("last_name", "Last Name", 165));
// create the column model
ColumnModel cm = new ColumnModel(columns);
// defines the xml structure
ModelType type = new ModelType();
type.root = "RECORDS";
type.addField("first_name", "first_name");
type.addField("last_name", "last_name");
// use a http proxy to get the data
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, "http://localhost/PHPExternalJSONData/service.php");
HttpProxy proxy = new HttpProxy(builder);
// need a loader, proxy, and reader
final BaseListLoader loader = new BaseListLoader(proxy, new JsonReader(type));
ListStore<ModelData> store = new ListStore<ModelData>(loader);
final Grid<ModelData> grid = new Grid<ModelData>(store, cm);
grid.setBorders(true);
grid.setLoadMask(true);
grid.getView().setEmptyText("Please hit the load button.");
ContentPanel panel = new ContentPanel();
panel.setFrame(true);
panel.setCollapsible(true);
panel.setAnimCollapse(false);
panel.setButtonAlign(HorizontalAlignment.CENTER);
panel.setHeading("JSON Table Demo");
panel.setLayout(new FitLayout());
panel.add(grid);
panel.setSize(575, 350);
// add buttons
Button load = new Button("Load JSON", new SelectionListener<ButtonEvent>()
{
public void componentSelected(ButtonEvent ce)
{
loader.load();
}
});
panel.addButton(load);
layout.add(panel);
RootPanel.get().add(layout);
}
}