I actually figured something out to make it work but I am curious if I
am using it correctly.
Here is the code that I am using to setup the store:
-------------
final RecordDef recordDef = new RecordDef(new FieldDef[]{
new IntegerFieldDef("id"),
new StringFieldDef("title"),
new StringFieldDef("description"),
new StringFieldDef("skill"),
new StringFieldDef("nationality"),
new StringFieldDef("dishtype"),
new IntegerFieldDef("servings"),
new StringFieldDef("author"),
new DateFieldDef("created_at", "created_at",
"timestamp")
});
JsonReader reader = new JsonReader(recordDef);
reader.setRoot("recipe");
// reader.setId("id");
DataProxy dataProxy = new ScriptTagProxy("http://localhost/
recipevault_feed/getrecipe.php");
final Store store = new Store(dataProxy, reader, false);
StoreListenerAdapter listenerAdapter = new StoreListenerAdapter
() {
public void onLoad(Store store, Record[] records) {
loadForm(store);
}
};
----------
Then I have this code for the "load" button:
-------------
final Button loadBtn = new Button("Load", new
ButtonListenerAdapter() {
public void onClick(Button button, EventObject e) {
store.load();
GWT.log("store size "+store.getCount(),null);
submitBtn.enable();
}
});
...
}
private void loadForm(Store store) {
try {
this.getForm().loadRecord(store.getRecordAt(0));
} catch (Exception ex) {
GWT.log("loadForm(Store store)", ex);
}
}
-------------
I figured out that I needed to load the form from the Store listener
onLoad(). Does that seem correct?
>From my attempts at debugging, the store would be empty after calling
store.load() the first time. But, then when I would hit the load
button again, the store would have information in it.
On Nov 13, 6:12 pm, "Dariusz Borowski" <[EMAIL PROTECTED]> wrote:
> Do you have some code, we can take a look?
>
> I don't know how you are fetching the data, but you are probably using the
> AsyncCallback(). If so, then the success result is a jsonData. To see the
> changes, you need to commit the changes. Something like this:
>
> public void onSuccess( Object result ) {
> jsonData = result.toString();
> store.loadJsonData( jsonData, true );
> // this is important to see the data
> store.commitChanges();
>
> }
>
> Dariusz
>
> On Thu, Nov 13, 2008 at 10:59 PM, Brian H. Mayo <[EMAIL PROTECTED]>wrote:
>
>
>
> > I would like to ask for help debugging a non-loading store.
>
> > I am using JSON, have setup my RecordDef and created an onLoad method
> > in a listener adaptor to the Store.
>
> > When I perform the store.load() and then check the count, it is 0.
> > But, my debug output statements in the listener adapter say the store
> > has a count of 1.
>
> > How does the store go from having 1 record as reported by the onLoad
> > method on the listener to 0 records after the store.load() call
> > completes.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"GWT-Ext Developer Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/gwt-ext?hl=en
-~----------~----~----~----~------~----~------~--~---