PDA

View Full Version : Running an EXT JS 4.x Application (MVC) without a web server



marksdean
24 Aug 2012, 9:19 AM
Scenario

I need to deploy an offline application to a group of users (I will periodically update their data which will most likely be JSON files deployed to their EXT JS application folder).

I do not want the users to need to run a web server on their machines (PC/Mac laptops).

The store is loaded using a relative URL:
Ext.define('Ext4Example.store.Stocks', {
extend:'Ext.data.Store',
model:'Ext4Example.model.Stock',
autoLoad:true,
listeners:{
load:function (store, records, successful, eOpts ) {
console.log('Stocks load: ' + successful);
}
},
proxy:{
type:'ajax',


url:'app/store/data.json',


reader:{
type:'json',
listeners:{
exception:function (reader, response, error, eOpts) {
console.log('proxy reader: ' + error);
}
}
}
}
});

Is it possible to run the EXT JS 4.x application without a web server?

I took a simple existing MVC demo application from Loaine Groner (thanks) which populates a grid from inline data, and modified it to read from the local file system.

If I run the application from a file URI:

file://localhost/Library/WebServer/Documents/loiane-extjs4-mvc-basic-array-grid-8676e2b/index.html

the store throws a load exception. However I can see that the data is being response contains the JSON data.

If I run the application from an http URI the grid populates without error.

http://localhost/loiane-extjs4-mvc-basic-array-grid-8676e2b/index.html

Are there any strategies that will allow this? Are there any EXT JS extensions that provide for this? Is node.js a possible solution?

Any thoughts are appreciated.

I have attached the modified sample code (you'll need to add the extjs folder to the root directory of the app).

Thanks,
Mark

(http://localhost/loiane-extjs4-mvc-basic-array-grid-8676e2b/index.html)

scottmartin
24 Aug 2012, 2:51 PM
The simple answer is you need to have a web server. If you are simply bent on not having one, here is a few articles:

http://www.sencha.com/forum/showthread.php?207842
http://www.quora.com/Node-js/Can-node-js-replace-Apache
http://stackoverflow.com/questions/5346055/can-i-replace-apache-with-node-js
http://stackoverflow.com/questions/8695471/how-to-build-a-website-on-node-js

Regards,
Scott.