PDA

View Full Version : Direct API In Designer



thermiteplasma
27 Mar 2010, 8:39 PM
Just wondering if anyone has got Ext Direct to work in the designer. When i put in api url in the "Ext Direct Api" field in the preferences, it just says Specification failed to load ???

Is this url dependant at all on the urlPrefix field??

aconran
27 Mar 2010, 9:43 PM
It is not dependent on the urlPrefix. You can put a full path in the Ext Direct API.

The Ext.Direct stack which you are running must support the format=json parameter to return JSON rather than standard JS.

thermiteplasma
27 Mar 2010, 10:13 PM
Sorry, but i dont really understand.

I just looked through the docs looking how to set the "format=json" parameter.
No good.

This is the output from my api call.


Agt.rpc.REMOTING_API = {"url":"\/direct\/router","type":"remoting","actions":{"Setup":[{"name":"getAllAgents","len":4},{"name":"saveAgent","len":0,"formHandler":true},{"name":"loadAgent","len":1},{"name":"deleteAgent","len":1},{"name":"getAllCustomers","len":4},{"name":"saveCustomer","len":0,"formHandler":true},{"name":"loadCustomer","len":1},{"name":"deleteCustomer","len":1},{"name":"getAllSalesPersons","len":4},{"name":"saveSalesPerson","len":0,"formHandler":true},{"name":"loadSalesPerson","len":1},{"name":"deleteSalesPerson","len":1},{"name":"getAllAreasPaged","len":4},{"name":"getAllAreas","len":0},{"name":"saveArea","len":0,"formHandler":true},{"name":"loadArea","len":1},{"name":"deleteArea","len":1}],"Games":[{"name":"GetGamesCombo","len":1},{"name":"GetGameVariantsCombo","len":1},{"name":"GetGame","len":1},{"name":"GetGameVariants","len":3},{"name":"getGames","len":4},{"name":"updateGame","len":0,"formHandler":true},{"name":"loadGame","len":1},{"name":"getGameBcvs","len":1},{"name":"createBcv","len":1},{"name":"updateBcv","len":1},{"name":"deleteBcv","len":1},{"name":"getJackpotProfiles","len":1},{"name":"updateJackpotProfile","len":0,"formHandler":true},{"name":"deleteJackpotProfile","len":1},{"name":"getVariations","len":1},{"name":"createVariation","len":1},{"name":"updateVariation","len":1},{"name":"deleteVariation","len":1}],"CallReports":[{"name":"getAllSalesPersons","len":0},{"name":"getSummary","len":7},{"name":"getByCustomer","len":1},{"name":"getAllByRep","len":1},{"name":"getAll","len":5},{"name":"getTreeNodes","len":1}],"General":[{"name":"GetUserDetails","len":0},{"name":"getCustomersCombo","len":3},{"name":"getSalesRepsCombo","len":0},{"name":"getModelsCombo","len":0},{"name":"getGameTypesCombo","len":0},{"name":"getPartsCombo","len":0}],"Quotes":[{"name":"getAll","len":5},{"name":"getTreeNodes","len":1},{"name":"save","len":0,"formHandler":true},{"name":"submitQuote","len":1},{"name":"approveQuote","len":1},{"name":"rejectQuote","len":2},{"name":"loadQuote","len":1}]},"namespace":"Agt.rpc"};

aconran
27 Mar 2010, 10:16 PM
The latest Ext.Direct specs support a url parameter of format=json.

This would cause the direct api generator to valid JSON.

"Agt.rpc.REMOTING_API" would be put in the JSON packet as a key of descriptor.

For example


{"descriptor":"Agt.rpc.REMOTING_API","url":"\/direct\/router","type":"remoting","actions":{"Setup":[{"name":"getAllAgents","len":4},{"name":"saveAgent","len":0,"formHandler":true},{"name":"loadAgent","len":1},{"name":"deleteAgent","len":1},{"name":"getAllCustomers","len":4},{"name":"saveCustomer","len":0,"formHandler":true},{"name":"loadCustomer","len":1},{"name":"deleteCustomer","len":1},{"name":"getAllSalesPersons","len":4},{"name":"saveSalesPerson","len":0,"formHandler":true},{"name":"loadSalesPerson","len":1},{"name":"deleteSalesPerson","len":1},{"name":"getAllAreasPaged","len":4},{"name":"getAllAreas","len":0},{"name":"saveArea","len":0,"formHandler":true},{"name":"loadArea","len":1},{"name":"deleteArea","len":1}],"Games":[{"name":"GetGamesCombo","len":1},{"name":"GetGameVariantsCombo","len":1},{"name":"GetGame","len":1},{"name":"GetGameVariants","len":3},{"name":"getGames","len":4},{"name":"updateGame","len":0,"formHandler":true},{"name":"loadGame","len":1},{"name":"getGameBcvs","len":1},{"name":"createBcv","len":1},{"name":"updateBcv","len":1},{"name":"deleteBcv","len":1},{"name":"getJackpotProfiles","len":1},{"name":"updateJackpotProfile","len":0,"formHandler":true},{"name":"deleteJackpotProfile","len":1},{"name":"getVariations","len":1},{"name":"createVariation","len":1},{"name":"updateVariation","len":1},{"name":"deleteVariation","len":1}],"CallReports":[{"name":"getAllSalesPersons","len":0},{"name":"getSummary","len":7},{"name":"getByCustomer","len":1},{"name":"getAllByRep","len":1},{"name":"getAll","len":5},{"name":"getTreeNodes","len":1}],"General":[{"name":"GetUserDetails","len":0},{"name":"getCustomersCombo","len":3},{"name":"getSalesRepsCombo","len":0},{"name":"getModelsCombo","len":0},{"name":"getGameTypesCombo","len":0},{"name":"getPartsCombo","len":0}],"Quotes":[{"name":"getAll","len":5},{"name":"getTreeNodes","len":1},{"name":"save","len":0,"formHandler":true},{"name":"submitQuote","len":1},{"name":"approveQuote","len":1},{"name":"rejectQuote","len":2},{"name":"loadQuote","len":1}]},"namespace":"Agt.rpc"}


This allows the designer to introspect the Direct router for the API with standard JSON.

thermiteplasma
28 Mar 2010, 1:40 AM
Thanks. I should be right now.

Cheers

thermiteplasma
28 Mar 2010, 12:36 PM
Still no good.

My server is now returning valid json like so.


{"url":"\/direct\/router","type":"remoting","actions":{"Setup":[{"name":"getAllAgents","len":4},{"name":"saveAgent","len":0,"formHandler":true},{"name":"loadAgent","len":1},{"name":"deleteAgent","len":1},{"name":"getAllCustomers","len":4},{"name":"saveCustomer","len":0,"formHandler":true},{"name":"loadCustomer","len":1},{"name":"deleteCustomer","len":1},{"name":"getAllSalesPersons","len":4},{"name":"saveSalesPerson","len":0,"formHandler":true},{"name":"loadSalesPerson","len":1},{"name":"deleteSalesPerson","len":1},{"name":"getAllAreasPaged","len":4},{"name":"getAllAreas","len":0},{"name":"saveArea","len":0,"formHandler":true},{"name":"loadArea","len":1},{"name":"deleteArea","len":1}],"Games":[{"name":"GetGamesCombo","len":1},{"name":"GetGameVariantsCombo","len":1},{"name":"GetGame","len":1},{"name":"GetGameVariants","len":3},{"name":"getGames","len":4},{"name":"updateGame","len":0,"formHandler":true},{"name":"loadGame","len":1},{"name":"getGameBcvs","len":1},{"name":"createBcv","len":1},{"name":"updateBcv","len":1},{"name":"deleteBcv","len":1},{"name":"getJackpotProfiles","len":1},{"name":"updateJackpotProfile","len":0,"formHandler":true},{"name":"deleteJackpotProfile","len":1},{"name":"getVariations","len":1},{"name":"createVariation","len":1},{"name":"updateVariation","len":1},{"name":"deleteVariation","len":1}],"CallReports":[{"name":"getAllSalesPersons","len":0},{"name":"getSummary","len":7},{"name":"getByCustomer","len":1},{"name":"getAllByRep","len":1},{"name":"getAll","len":5},{"name":"getTreeNodes","len":1}],"General":[{"name":"GetUserDetails","len":0},{"name":"getCustomersCombo","len":3},{"name":"getSalesRepsCombo","len":0},{"name":"getModelsCombo","len":0},{"name":"getGameTypesCombo","len":0},{"name":"getPartsCombo","len":0}],"Quotes":[{"name":"getAll","len":5},{"name":"getTreeNodes","len":1},{"name":"save","len":0,"formHandler":true},{"name":"submitQuote","len":1},{"name":"approveQuote","len":1},{"name":"rejectQuote","len":2},{"name":"loadQuote","len":1}]},"namespace":"Agt.rpc","descriptor":"Agt.rpc.REMOTING_API"}

Still says Ext.Direct Remoting Specification Failed To Load

aconran
28 Mar 2010, 6:46 PM
Are you putting the full path? Is the api reachable via a browser?

thermiteplasma
29 Mar 2010, 1:45 AM
Sure am. The json above was from the browser.

I am putting in the fullpath

i.e. http://ainsworthsales.local/direct/api

dlouwers
30 Mar 2010, 5:52 AM
I didn't see the descriptor parameter in your json response:

{ "descriptor":"Agt.rpc.REMOTING_API", ... }Best,

Dirk Louwers

thermiteplasma
30 Mar 2010, 2:11 PM
its there, at the end of the json.

Its was working in 1.0.0.3, but now its not again in 1.0.0.4

aconran
30 Mar 2010, 7:07 PM
The Designer does not reinterrogate the Ext.Direct api after opening a project.

It will work the first time and then afterwards breaks. We will fix this issue.

konstruktor
31 Mar 2010, 3:21 AM
I tried it with JS api:

Ext.app.ANALYTICS_API = {"url":"\/extdirect.php\/dsExtDirect\/router","type":"remoting","actions":{"api":[{"name":"multiply","len":1}]},"namespace":"myNs"};

and also with the JSON api:

{"url":"\/extdirect.php\/dsExtDirect\/router","type":"remoting","actions":{"api":[{"name":"multiply","len":1}]},"namespace":"myNs","descriptor":"Ext.app.ANALYTICS_API"}

no luck.

whats wrong?

form ext direct api setting i put: ANALYTICS_API

any idea?

thanks.

aconran
31 Mar 2010, 7:58 AM
@konstruktor Put in the url that points to your api descriptor in json format (it will automatically pass ?format=json) as the file that generates the JS and JSON api are typically the same.

axpa
30 Apr 2010, 2:39 AM
Hi,
Any clues about this problem? (I have left export path = . and I have the url prefix ending with slash.)

I'm using xds-1.0.0.9 on win xp SP 3 and I get an Error.
An error has occured on line 2 in undefined. SyntaxError Parse Error.

When adding ?format=json to my apiurl I get, its "valid" json and I have the descriptor and namespace:

{"url":"\/traxtion\/public\/extdirect","type":"remoting","actions":{"AxpaConfig":[{"name":"getAll","len":1,"serverMethod":"getallAction"}],"AxpaStrings":[{"name":"getAll","len":1,"serverMethod":"getallAction"}],"AxpaAcl":[{"name":"getAllRights","len":1,"serverMethod":"getallrightsAction"}],"AxpaTree":[{"name":"getNodes","len":1,"serverMethod":"getnodesAction"}],"AxpaDummy":[{"name":"formPanel","len":1,"serverMethod":"formPanelAction"},{"name":"imageList","len":1,"serverMethod":"imagelistAction"},{"name":"gridList","len":1,"serverMethod":"gridlistAction"},{"name":"nodeimageList","len":1,"serverMethod":"nodeimagelistAction"}]},"descriptor":"Axpa.API","namespace":"Axpa"}

jarrednicholls
30 Apr 2010, 11:00 AM
axpa, we're looking into the issues with interrogating the Ext.Direct APIs, as well as loading data through a DirectStore. Keep an eye out in the Change Log, http://www.extjs.com/products/designer/changelog.php. Thanks.

axpa
2 May 2010, 10:28 PM
jarred, thanks for the heads up, I'll keep an eye out in the changelog

heratech
17 Oct 2010, 10:39 AM
Hi,
Any update with this?
Thanks

heratech
17 Oct 2010, 10:48 AM
Update: for me it seems to rely on the file being a .php extension (or maybe just having an extension)?
I am using cakephp (i just finished work on ext direct stack that I will release soon). my path is http://localhost/extdirect/api
In the apache logs I can see it accessing /extdirect/api?format=json_dc=4629086928692 but ext designer refuses to accept it (pops up setting window again).
If i copy the json output into a file called api.php and put it into say a folder called /designertest (so path is http://localhost/designertest/api.php) it works fine.

jarrednicholls
18 Oct 2010, 5:34 AM
Hi heratech,

The Direct API does work, as you have seen. There should not be any discrimination on an extension vs an extensionless endpoint (e.g., the Rails direct router works fine). I'm interested that your apache logs show a request for /extdirect/api?format=json_dc=4629086928692 when it is suppose to be /extdirect/api?format=json&_dc=4629086928692 (notice the ampersand). The _dc parameter is just a side-effect of the cache busting mechanism in Ext.Ajax (Ext.data.Connection), and is not a part of the actual URL request that's made to load the Direct API. Are you sure it's not putting the ampersand in there...perhaps a copy/paste issue, HTML encoding issue, or the Apache logs may just be omitting it?

You mentioned you're doing your own Direct stack...the Designer does rely on the formatting functionality in the Direct spec, where the client can request either the default format (much like an JSON-P call...JS method call that can be evaluated as the "src" to a script tag), or the JSON format (hence the format=json parameter). Does your stack handle that? The Designer requires the stack to return in JSON format.