I use showcase SmartGwt for Mobile ( http://smartgwt-mobile.smartclient.com/#Widgets ) with Phonegap. I see example of fetch data from JSON (DataBinding-> CRUD Operations). It works very nice, but I would like to fetch data from external server. When I change an addres to my domain I see in my app " No items to show".
How Can I fetch data from external server and display in my app ?
Code:
private static final DataSourceField CODE_FIELD = new DataSourceField("countryCode", "Country Code"),
NAME_FIELD = new DataSourceField("countryName", "Country Name"),
POPULATION_FIELD = new DataSourceField("population", "Population"),
AREA_FIELD = new DataSourceField("area", "Total Area"),
INDEPENDENCE_FIELD = new DataSourceField("independence"),
GOVERNMENT_FIELD = new DataSourceField("government", "Government");
static {
CODE_FIELD.setPrimaryKey(true);
POPULATION_FIELD.setType("int");
AREA_FIELD.setType("float");
INDEPENDENCE_FIELD.setType("date");
}
public CRUDOperations(String title) {
super(title);
setWidth("100%");
VLayout layout = new VLayout();
layout.setWidth("100%");
layout.setAlign(Alignment.CENTER);
final DataSource countryDS = new DataSource("CRUD_countries");
final TableView tableView = new TableView();
tableView.setAlign(Alignment.CENTER);
setActions(new Action(IconResources.INSTANCE.add()) {
@Override
public void execute(ActionContext context) {
tableView.addData(new Record());
context.getControl().disable();
}
}, new Action(IconResources.INSTANCE.refresh()) {
@Override
public void execute(ActionContext context) {
tableView.updateData(new Record());
context.getControl().disable();
}
}, new Action(IconResources.INSTANCE.stop()) {
@Override
public void execute(ActionContext context) {
tableView.removeData(new Record());
context.getControl().disable();
}
});
tableView.setTitleField(CODE_FIELD.getName());
tableView.setShowNavigation(false);
tableView.setSelectionType(SelectionStyle.SINGLE);
tableView.setTableMode(TableMode.GROUPED);
tableView.setDataFetchMode(FetchMode.BASIC);
countryDS.setFields(CODE_FIELD, NAME_FIELD, POPULATION_FIELD, AREA_FIELD, INDEPENDENCE_FIELD, GOVERNMENT_FIELD);
countryDS.setFetchDataURL("http://example.com/data.js");
tableView.setDataSource(countryDS);
tableView.fetchData();
layout.addMember(tableView);
addMember(layout);
}