im near to finish my app and when try to put in onlin server i find some problems...
My proxy don't work with ajax issue, i need to put jsonp and configure my drupal to use JsonP.
Before:
proxy: {
type: 'ajax',
url: 'http://mydomain/json-art',
reader: {
type: 'json',
rootProperty: 'nodes'
},
}
After:
proxy: {
type: 'jsonp',
url: 'http://mydomain/json-art',
callbackKey: 'callback',
reader: {
type: 'json',
rootProperty: 'nodes'
},
}
Then in Drupal 7 put... JsonP prefix: Ext.data.JsonP.callback1
And.. all works fine.
But.. I have 4 Stores in my app, and try to reply this configuration in my other stores. And only works for the first one. I try to change the callback1 to callback2, callback3, etc.. but always have the same error:
Object [object Object] has no method 'callback4'
I don't know whats the correct way to use callbackKey in my app, pls help me!!!!
Thx
What I figure from "the internet", the drupal JSONP Prefix is either a set string to use, or the name of the url variable to check. If you set the JSON Prefix to "callback", it should work fine. This is because the the Sencha JsonP call will auto-append a url parameter named "callback", which contains the name of the function to call (typically Ext.data.JsonP.callback#number#.
Note that your solution is not even right for one datastore. Not entirely sure why you get the behaviour you get, but each JsonP call should have a different callback functionname.
There is no need to specify a callback (if it's even possible, not sure) in a proxy. Just get rid of the 'callbackKey' param and it should work. Sencha automatically places a callback parameter when using jsonp.
Related
I have a problem in getting list of users using $resource.
I am making a webservice call using $resource to get list of users. It works most of the time, but when ever the response takes some time I am getting 500 internal server error.
The code I am using to call the webservice:
$resource("user/referral/getUserList", {}, {
query: {
method: 'GET'
}
})
I will be grateful for your help.
It looks like you are missing a "/" at the left.
user/referral/getUserList
Please keep this as well if you want to have the result as an array.
'query': {method:'GET', isArray:true}
I had the same problem in Glassfish.
It's a bug in Glassfish 4.1.1 https://java.net/jira/browse/JERSEY-2888
I was able to fix it in this way:
In glassfish/modules/org.eclipse.persistence.moxy.jar fix META-INF/MANIFEST.MF Just append the following to Import-Package:
,org.xml.sax.helpers,javax.xml.parsers;resolution:=optional,javax.naming;resolution:=optional
in 72 line and restart GF
In every sencha request there are an extra parameter _dc. Please have took at the following image.
I want to remove this parameter for every request. So, please help me to do that.
Thank You...
_dc - this is "disable cache". You can disable this noCache parameter in proxy in your store\model. Example:
Ext.define('your model name', {
extend: 'Ext.data.Model',
fields: [...],
proxy: {
url: 'getcandidateblock',
noCache: false
}
})
But it's bad idea for ALL get requests to server.
Use 'noCache' config in your store's proxy
To disable the '_dc' query param, set this to false.
From Sencha Doc,
noCache - Disable caching by adding a unique parameter name to the request. Set to false to allow caching. Defaults to true.
I just don't understand how ExtJS is building these routes, or how I can stop all of it.
For example, if I'm using a proxy like:
{
type: 'rest',
url: '/user',
noCache: false,
reader: { type: 'json', successProperty: 'success' }
}
I would expect requests like GET /user or POST /user/123 as is the case with restfull apis.
Instead I get stuff like GET /user/root?node=root or GET user?page=1&start=0&limit=25.
Is there a way to get ExtJS to stop adding all these extra params?
The tree store defines a default root id if you don't care of that yourself.
The page and start params are added by the paging toolbar in the grid. Your REST implementation should not be bothered by extra parameters. You can also disable them if you turn paging off.
I am adapting a tutorial to change from localstorage to use a java servlet but i am having some problems. I am trying to update the changes a user makes by calling sync() but i am getting these errors.
[WARN][Ext.data.Operation#process] Unable to match the record that came back from the server.
I tried seeing if the updated values where being send to the servlet
String name = request.getParameter("name");
is null. How do I send the updated values back the server and read them? I tried looking for a sencha touch + servlets tutorial but can't find anything
this is my sync code
var showsStore = Ext.getStore("Shows");
if (null == showsStore.findRecord('name', currentShow.data.name)) {
showsStore.add(currentShow);
}
showsStore.sync();
The expected return for a store sync is an array of JSON records, or nothing.
Add this to your data store
writer: {
type: 'json',
rootProperty: 'data',
encode: true,
writeAllFields: true
},
I am doing a project were I am trying to make the backend with playframework and the frontend with Extjs.
I can retrieve the data from the server with Json and show it in a grid with all it's fields.
The problem comes when I try to modify, remove or add any record.
The request sent by Ext: DELETE lista?_dc=1318409614652
(I solved _dc with "noCache: false" over the proxy)
The request right now is: DELETE lista
The request I need is: DELETE lista/"parameter of the object like ID or name"
Do you have any idea about this? If you need any information let me know
Thanks in advance!
I suppose you are not yet using the Rest proxy (of ExtJS) for this, but you should, as it does exactly what you are asking for. You set it up with an url like /lista in your case. Now, when you delete a record, the proxy automatically sends a DELETE request to the url, appending it with the id. Check out the documentation (linked above) for more info - you can control the url generation a little bit, but in your case it looks like you can do with the default options.
even if you don't want to use Rest Proxy, you use still use Ext.Ajax.request like below.
Ext.Ajax.request({
waitMsg: "Saving... Please wait",
url: "myserverscript.php",
method: "POST",
params: {
action: "delete",
id: myForm.down('#id').getValue(),
data: jsonData
}
});