How to Extend our own class in ExtJS4 - extjs4

I have created the class in Ext JS 4, and now I want to extend that in another class. I use extend properties, to extend the class. But I am not able to extend the class. Do I want to use require to include the class file. But I keep both the files in the same directory.

Define source paths for ExtJS to locate your source files.
Ext.Loader.setConfig({
enabled: true,
paths: {
'[your namespace prefix here]': '[physical path]'
}
});
Then define Ext.require or requires section in subclass to enable automatic path resolution.
Read this link for more info.
Example
Base class: file located at folder root/view/common/Picker.js
Ext.define('RL.view.common.Picker', {
extend: "Ext.form.field.Picker",
...
}
Sub class: file located at folder root/view/selection/DriverTreeCombo.js
Ext.define('RL.view.selection.DriverTreeCombo', {
extend: "RL.view.common.Picker",
requires: ['Ext.tree.Panel', 'RL.view.common.TreeBase'],
...
}
I have namespace as RL.xxx.xxx and RL is supposed to be the root folder. Now I can define Loader configuration as below
Ext.Loader.setConfig({
enabled: true,
paths: {
'RL': '/root'
}
})
Loader configuration should be set before 'Ext.onReady(...)' function call. Going through examples folder in ExtJS package would help you to see how this is done.
Further reading:
The Class System
Dynamic Loading and new class system

Related

PHP/Laravel can not resolve parent Class

Using php 7, Laravel 5.5. All models are in default app/ folder, Prototype is in app/ folder too. Nothing was moved
What is most frustrating - this worked all right for controllers (everything is in their default folders)
My Prototype Class:
class Prototype extends Model
{
//other code
}
My child Class:
class Tree extends Prototype
{
//other code
}
Exception:
include(/var/www/html/app/Prototypephp): failed to open stream: No such file or directory
I need help to fix this issue. Thanks!
After a few hrs of working over this issue solved it by moving Prototype Class to other namespace (and folder). Did the same to PrototypeController for code readability.

Load qml component/file from local file system

My application has the following structure:
There is a main.cpp which loads a file named main.qml from a qrc file.
Contents of the qrc:
/qml/main.qml
/qml/CustomUiElement.qml
/qml/WidgetQmlInQrc.qml
In this main.qml, i'm loading other qml components/files, which are also stored in the qrc. This works as expected.
main.qml
Component.onCompleted:{
var component=Qt.createComponent("WidgetQmlInQrc.qml")
widget=component.createObject(mainWindow,params)
}
I'd like to use qml components/files stored on the local filesystem in my main.qml.
Local qml file: /mnt/plugin/WidgetQmlExternal.qml
import QtQuick 2.0;
Rectangle {
color:"green";
CustomUiElement {
}
}
First i tried to extend the qml import path:
viewer->engine()->addImportPath("/mnt/plugin/");
This did not work.
After that i tried to load the component by using the full path.
Now the WidgetQmlExternal.qml is found and loaded, but it can't find the CustomUiElement.qml because the external qml can't access files in the qrc.
Component.onCompleted:{
var component=Qt.createComponent("/mnt/plugin/WidgetQmlExternal.qml")
widget=component.createObject(mainWindow,params)
}
How can i solve this issue / what do i have to change of the structure of my application to be able to load external components, which again reuse some of my custom components?
I also struggled with this until I realised that you can simply prefix the url to force it to look at the local file system, e.g.
Loader {
source: "file:/mnt/plugin/WidgetQmlExternal.qml"
}
Using this approach, the component loaded by the Loader will be able to access other components withing the QRC as well. Hope that helps.
Here are some options that come to mind:
Load the internal, QRC-based QML file with a Loader
WidgetQmlExternal.qml:
import QtQuick 2.0
Rectangle {
anchors.fill: parent
color: "red"
Loader {
source: "qrc:/WidgetQmlInQrc.qml"
}
}
Interestingly, Qt itself exposes certain assets this way.
Expose the internal, QRC-based QML files as a QML module
You can read more about this here.

using multiple translation files in aurelia i18N

I have a working app using aurelia-i18n. I would like to split translation.json file into multiple files like nav.json, message.json, etc but I am not sure how to do it.
This is how it looks right now.
locale
|-en
|- translation.json
But I want to change it to this way.
locale
|-en
|- nav.json
|- message.json
Is it possible to do it? If so, how do I configure it and access values in each file?
You can have multiple resource files and these are called namespaces in the i18next library (by default you only have one namespace which is called: translation) which is used by aurelia i18N.
You just need to list your namespaces when configuring the plugin with the namespaces and defaultNs properties inside the ns option:
.plugin('aurelia-i18n', (instance) => {
// adapt options to your needs (see http://i18next.com/pages/doc_init.html)
instance.setup({
resGetPath : 'locale/__lng__/__ns__.json',
lng : 'de',
attributes : ['t','i18n'],
ns: {
namespaces: ['nav', 'message'],
defaultNs: 'message'
},
getAsync : true,
sendMissing : false,
fallbackLng : 'en',
debug : false
});
});
See also the documentation of i18next and this related github issue: Using namespaces

Is it possible to load an aliased module?

I have a module "default/foo/bar" and a module "agency/foo/bar". I setup an alias to load the agency module instead of the default module. Yet I still want "agency/foo/bar" to load "default/foo/bar" but that's not possible because of the alias. Is there a way to accomplish this?
Here's actual snippets:
aliases: [
["gis/ol/config", "agency/ol/config"],
["aliased/gis/config", "gis/ol/config"]
],
Try to load the original module but it doesn't work..config is an Object:
define(["aliased/gis/config"], function (config) { // config is an object });
I find that using map instead of aliases is much clearer and easier to understand:
map: {
'*': {
'gis/ol/config': 'agency/ol/config'
},
'agency/ol/config': {
'gis/ol/config': 'gis/ol/config'
}
}
This configuration causes all modules to load 'agency/ol/config' in place of 'gis/ol/config', except for 'agency/ol/config' which will load 'gis/ol/config' as 'gis/ol/config'.

how to use store define in store folder

I'm new to sencha-touch. I was wondering how to properly use the file structure in sencha-touch. For example, under the app folder there's your controller, model, profile, store, view folders. If I define a store, for example under the the store folder I create a file named search.js
Ext.define('Volunteer.store.search'{
extend: 'Ext.data.Store',
requires: ['Volunteer.model.person'],
config:{
model: 'Volunteer.model.person'
}
});
How do I use this store in a different file?
Add your store in app.js file stores: ['search'] and different file you call Ext.getStore('search');. If not found, you need add search.js into index.html