PDA

View Full Version : Cannot override Ext.String (Sencha cmd)



dfrederick
21 May 2014, 9:54 AM
We have an override for Ext.String that adds a couple methods. It's presence in the workspace dir or app dir causes the concatenated output file to be in the wrong order. i.e. Ext.Base is used by Ext.Class, but Ext.Class comes before it.
Here's our override, I've tried to figure out why this would happen, but I'm not able to make any sense out of it. I even generated a new app and added this file to it (although nothing is using it) an the issue still occurs.



Ext.define('Ringtail.Common.override.String', {
override: 'Ext.String',
requires: ['Ext.String'],

/**
* will return what was passed in if it is falsy otherwise will do a normal trim
* @param the string to be trimmed * @return the falsy value passed in or trimmed string */
nullSafeTrim: function (string) {
if (!string) {
return string;
}
return Ext.String.trim(string);
},
titleCase: function (value) {
var parts = value.split(' '),
length = parts.length,
i,
returnValue = '';
for (i = 0; i < length; i += 1) {
returnValue += Ext.String.capitalize(parts[i]);
returnValue += (i < length - 1) ? ' ' : ''; // Add trailing space if more parts to be added
}
return returnValue;
}
});





49070

mitchellsimoens
22 May 2014, 6:30 AM
Ext.String does not use Ext.define and therefore is not overridable via Ext.define using the override property.

Still using Ext.define, you can add methods like so:


Ext.define('Override.String', {
requires : [
'Ext.String'
]
}, function() {
delete Override.String;

Ext.String.nullSafeTrim = function(string) {
if (!string) {
return string;
}
return Ext.String.trim(string);
};
});

dfrederick
22 May 2014, 10:28 AM
Thanks Mitchell. =D>

mankz
22 May 2014, 10:44 AM
Shouldn't the override implementation handle this though? Should be easy for it to 'do the right thing'?

LesJ
22 May 2014, 10:47 AM
Ext.String does not use Ext.define...[/code]

Is there any particular reason why Ext.define is not used?

alfonso.nishikawa
14 Feb 2017, 1:02 PM
@mitchellsimoens: creating a code package it shows the following error:


Sencha Cmd v6.2.0.103
[INF] Processing Build Descriptor : default
[ERR] C2008: Requirement had no matching files (Ext.String) -- /home/alfonso/git/ExtJSPackages/packages/local/nishilua-escaped-binds/overrides/String.js:21:10
[ERR]
[ERR] BUILD FAILED

From the code:


Ext.define('Nishilua.String', {
requires : [
'Ext.String'
],
compatibility: '6.0.1.250'

}, function() {

delete Nishilua.String;

/**
* Regular expression that matches the characters to escape: '.', '\', '{', '}', '!' and ':'
*/
var escapeBindRe = /(\.|\\|\{|}|!|:)/g ;

...

Any idea?

It happens in ExtJS 6, but is related to this (although this belongs to ExtJS 5).


Thanks!

alfonso.nishikawa
9 Apr 2017, 2:59 PM
The solution to my problem where "Ext.String" is not found is shown in this other thread: https://www.sencha.com/forum/showthread.php?309236-quot-sencha-package-build-quot-with-Sencha-Cmd-6-and-extJS-6-does-not-recognize-Ext-Component&p=1129313&viewfull=1#post1129313

@keckeroo told to put the following in package.json:


"framework": "ext",
"toolkit": "classic",
"theme": "ext-theme-classic"