PDA

View Full Version : Ext.data.DirectStore Usage



Whatty
27 Oct 2009, 7:08 AM
Good morning,

I have download ExtJS 3.0 and the ExtDirect pack for .NET and am trying to hook up a DirectStore to a simple bean via:



var _simpleStore = new Ext.data.DirectStore({
autoLoad: true,
directFn: LoginAction.getSupportedDatabases,
paramsAsHash: false,
idProperty: 'lang_id',
fields : [ 'name', 'className', 'resourceName' ]
})


and my bean looks like:



...
[DirectAction]
public class LoginAction
{

[DirectMethod]
public List<DBDescriptor> getSupportedDatabases() {
return ApplicationConfiguration.getInstance().getDbDescriptors();
}
...


however in FireBug when I debug it I am getting the LoginAction is not defined message.

What am I missing here.

Alternatively, does anyone have a working example of the ExtDirect .NET implementation with a DirectStore. The current example app does not include such an example.

Thanks in advance.

Whatty
27 Oct 2009, 10:58 AM
Well it seems that I forgot to include an import call in the top of my page.

<script type="text/javascript" src="ApiHandler.ashx"></script>

which maps the reference to my action appropriately, which I have confirmed by logging the API



provider Ext.app.REMOTING_API = {"type":"remoting","url":"/Web/DirectHandler.ashx","actions":{"SampleLoginAction":[{"name":"getSupportedDatabases","len":0,"formHandler":false}]}};


so now page is:



Ext.onReady(function(){

Ext.Direct.addProvider(Ext.app.REMOTING_API);

var _simpleStore = new Ext.data.DirectStore({
autoLoad: true,
directFn: SampleLoginAction.getSupportedDatabases,
paramsAsHash: false,
idProperty: 'name',
listeners: {
load: function(s, records){
Ext.MessageBox.alert( "Information", "Loaded " +
records.length + " records");
}},
fields : [ 'name', 'className', 'resourceName' ]
})

_simpleStore.load();



but id does not seem to be making the call across the pipe, and I have yet to be able to track down exactly where this happens.

Can someone please provide me some help on this, I know I am a newbie on this, but there is a fairly steep learning curve on this.

Thanks in advance.

Whatty
28 Oct 2009, 6:02 AM
Well it seems after much digging that when I moved the ApiHandler.ashx to the subdirectory "Web" and that the reference to the DirectHandler.ashx is a relative reference, thus



provider Ext.app.REMOTING_API = {"type":"remoting","url":"/Web/DirectHandler.ashx","actions":{"SampleLoginAction":[{"name":"getSupportedDatabases","len":0,"formHandler":false}]}};


was pointing to nowhere. I removed the leading "/Web" from the DirectHandler.ashx to get



provider Ext.app.REMOTING_API = {"type":"remoting","url":"DirectHandler.ashx","actions":{"SampleLoginAction":[{"name":"getSupportedDatabases","len":0,"formHandler":false}]}};


and it now works as expected.