[GeoNetwork-users] JsonStore problem

I am new to GN. A problem bugged me for a few days now, and would like to ask for your help.
I have created a json store "XXXStore.js" to return a json object by calling from a HTML page. It can work fine when I tested outside GeoNetwork app.

Then I put the 'XXXStore.js' under 'apps/js/GeoNetwork/lib/GeoNetwork/data/'. Here is how I did it:

1.) In "GeoNetwork.js", I added an entry "GeoNetwork/data/XXXStore.js" together with other GN stores scripts.
2.) In "SearchFormTools.js", I added a function "getXXXField()", which will call the "GeoNetwork.data.XXXStore(url)": xxxStore = GeoNetwork.data.XXXStore(url); xxxStore.load();

3.) In SearchApp.js, I added a checkbox group to populate data from the store.
Unfortunately, it looks the json store failed to be created. In Firebug, I caught that "xxxStore" is undefined.

Do I missed any step I need to add within GeoNetwork app? Why does it works outside GeoNetwork, but failed within GeoNetwork? Guess GN needs some extra setting?

any help is much appreciated.
Yan

I moved one step forward. In the XXXStore.js, after adding "new Ext.data.HttpProxy" after the 'proxy:', the data service could be successfully called, as I found it called in Firebug, and the json response. But it is only half the story. In the callback function, I could catch the 'success' is true, but the 'records' is empty, which means there is no data returned from the callback function. Here are my code:
XXXStore.jsGeoNetwork.data.XXXStore = function(myurl) {return new Ext.data.JsonStore( { storeId: 'mystore',
proxy: new Ext.data.HttpProxy({
method: 'GET',
url: myurl, reader: { type: 'json', root: 'results' } }),
fields: ['myid', 'myname'],
idProperty: 'myid', listeners: { load: function(store, records, success) {
if (success) {
alert("Store found: " + records.length);
} else {
alert("Store Failed");
}
}
});
}
In the 'generateAdvanceSearchForm' function within SearchApp.js,I do the following: var myurl = 'http://localhost:8080/examples/jsp/getmylist.jsp’;
var store = new GeoNetwork.data.XXXStore(myurl); store.load ({ scope: this,
callback: function (records, options, success) {
if (success) {
alert("Callback have: " + records.length);
} else {
alert("Callback Failed");
} });
When I load the page 'http://localhost:8080/geonetwork/srv/eng/search?debug=true’, I got the alert 'Store found: 0' and the 'Callback have: 0'.
Since I saw the 'getmylist.jsp' is called, I guess it might be a scope issue? If it is, how should I fix this?
appreciate any help on it.

      From: Jack HU <bytj@anonymised.com>
To: "geonetwork-users@lists.sourceforge.net" <geonetwork-users@anonymised.comeforge.net>
Sent: Thursday, February 5, 2015 2:07 PM
Subject: JsonStore problem
   
I am new to GN. A problem bugged me for a few days now, and would like to ask for your help.
I have created a json store "XXXStore.js" to return a json object by calling from a HTML page. It can work fine when I tested outside GeoNetwork app.

Then I put the 'XXXStore.js' under 'apps/js/GeoNetwork/lib/GeoNetwork/data/'. Here is how I did it:

1.) In "GeoNetwork.js", I added an entry "GeoNetwork/data/XXXStore.js" together with other GN stores scripts.
2.) In "SearchFormTools.js", I added a function "getXXXField()", which will call the "GeoNetwork.data.XXXStore(url)": xxxStore = GeoNetwork.data.XXXStore(url); xxxStore.load();

3.) In SearchApp.js, I added a checkbox group to populate data from the store.
Unfortunately, it looks the json store failed to be created. In Firebug, I caught that "xxxStore" is undefined.

Do I missed any step I need to add within GeoNetwork app? Why does it works outside GeoNetwork, but failed within GeoNetwork? Guess GN needs some extra setting?

any help is much appreciated.
Yan

seems GN uses the EXTJS v3.2.1, as far as I could search through the developer/user forum. checked the documents in ExtJs 3.2, and fixed the problem. could not use 'new Ext.data.HttpProxy'. removed it, and used 'url: myurl', which made it working.
      From: Jack HU <bytj@anonymised.com>
To: "geonetwork-users@lists.sourceforge.net" <geonetwork-users@anonymised.comeforge.net>
Sent: Tuesday, February 10, 2015 10:35 AM
Subject: Re: JsonStore problem
   
I moved one step forward. In the XXXStore.js, after adding "new Ext.data.HttpProxy" after the 'proxy:', the data service could be successfully called, as I found it called in Firebug, and the json response. But it is only half the story. In the callback function, I could catch the 'success' is true, but the 'records' is empty, which means there is no data returned from the callback function. Here are my code:
XXXStore.jsGeoNetwork.data.XXXStore = function(myurl) {return new Ext.data.JsonStore( { storeId: 'mystore',
proxy: new Ext.data.HttpProxy({
method: 'GET',
url: myurl, reader: { type: 'json', root: 'results' } }),
fields: ['myid', 'myname'],
idProperty: 'myid', listeners: { load: function(store, records, success) {
if (success) {
alert("Store found: " + records.length);
} else {
alert("Store Failed");
}
}
});
}
In the 'generateAdvanceSearchForm' function within SearchApp.js,I do the following: var myurl = 'http://localhost:8080/examples/jsp/getmylist.jsp’;
var store = new GeoNetwork.data.XXXStore(myurl); store.load ({ scope: this,
callback: function (records, options, success) {
if (success) {
alert("Callback have: " + records.length);
} else {
alert("Callback Failed");
} });
When I load the page 'http://localhost:8080/geonetwork/srv/eng/search?debug=true’, I got the alert 'Store found: 0' and the 'Callback have: 0'.
Since I saw the 'getmylist.jsp' is called, I guess it might be a scope issue? If it is, how should I fix this?
appreciate any help on it.

     From: Jack HU <bytj@anonymised.com>
To: "geonetwork-users@lists.sourceforge.net" <geonetwork-users@anonymised.comeforge.net>
Sent: Thursday, February 5, 2015 2:07 PM
Subject: JsonStore problem
   
I am new to GN. A problem bugged me for a few days now, and would like to ask for your help.
I have created a json store "XXXStore.js" to return a json object by calling from a HTML page. It can work fine when I tested outside GeoNetwork app.

Then I put the 'XXXStore.js' under 'apps/js/GeoNetwork/lib/GeoNetwork/data/'. Here is how I did it:

1.) In "GeoNetwork.js", I added an entry "GeoNetwork/data/XXXStore.js" together with other GN stores scripts.
2.) In "SearchFormTools.js", I added a function "getXXXField()", which will call the "GeoNetwork.data.XXXStore(url)": xxxStore = GeoNetwork.data.XXXStore(url); xxxStore.load();

3.) In SearchApp.js, I added a checkbox group to populate data from the store.
Unfortunately, it looks the json store failed to be created. In Firebug, I caught that "xxxStore" is undefined.

Do I missed any step I need to add within GeoNetwork app? Why does it works outside GeoNetwork, but failed within GeoNetwork? Guess GN needs some extra setting?

any help is much appreciated.
Yan