PDA

View Full Version : [4.1.3] Missing dependencies for Ext.data.Model



Zadneram
29 Oct 2012, 6:15 AM
REQUIRED INFORMATION


Ext version tested:

Ext 4.1.0
Ext 4.1.2
Ext 4.1.3


Browser versions tested against:

Firefox 16


Description:

Creating an instance of a class that derives from Ext.data.Model requires both 'Ext.data.reader.Json' and 'Ext.data.writer.Json' by default (as they are the default reader and writer) but these are not required by Ext.data.Model.


Steps to reproduce the problem:

Create an instance of a class that inherits from Ext.data.Model without first loading the JSON reader or writer classes


The result that was expected:

The reader and writer classes are in the list of dependencies for Ext.data.Model


The result that occurs instead:

The reader and writer classes are not in the list of dependencies and Ext.Loader attempts to synchronously load them. This doesn't work when synchronous loading is disabled.
In particular, when trying to 'build' and compress our javascript into a single file using the Sencha SDK tools, the reader and writer classes aren't put in the right place in the file, causing our site to fail to load.


Test Case:

The following just creates a grid property model (just as a class that inherits from Ext.data.Model). Nothing to see except the warning messages in the console.



<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Json Reader/Writer Test</title>

<script type="text/javascript" src="/ext4.1.3/ext-dev.js"></script>

<link rel="stylesheet" href="/ext4.1.3/resources/css/ext-all.css" type="text/css">

<script type="text/javascript">
Ext.require([
'Ext.data.Model',
'Ext.grid.property.Property'
]);

Ext.onReady(function(){
Ext.create('Ext.grid.property.Property');
});
</script>

</head>
<body>
</body>
</html>



HELPFUL INFORMATION

Debugging already done:

It looks like this has been a problem prior to 4.1.3 but have only noticed it on upgrading to 4.1.3 so possibly another class was loading the reader and writer previously...
Get the following warning in the console (and an equivalent one for the writer):





[Ext.Loader] Synchronously loading 'Ext.data.reader.Json'; consider adding Ext.require('Ext.data.reader.Json') above Ext.onReady

Possible fix:

Add reader and writer classes to list of dependencies for Ext.data.Model

mitchellsimoens
29 Oct 2012, 2:44 PM
The model shouldn't require it, the proxy should. The reader/writer isn't used on the model, it's used on the proxy.

Zadneram
30 Oct 2012, 12:43 AM
Fair point. Can the proxy require the reader/writer then please?

westy
21 May 2013, 12:38 AM
This is now fine in 4.2.1.744