How to load some namespace in Extjs? - extjs4

I'm trying to load "Ext.ux.CheckColumn" and using the following code:
Ext.Loader.setConfig({enabled: true});
Ext.Loader.setPath('Ext.ux', '../ux');
Ext.require(['Ext.ux.CheckColumn', '*']);
The Ext scripts are located at:
/Scripts/Library/Ext
The ux folder is at:
/Scripts/Library/Ext/ux
My script in which I'm using loader is located at:
/Scripts/MyApp/Module/jsFile.js
And my web page is located at:
/moudleFolder/mypage.aspx
I'm getting error: namespace is undefined
PS: I'm using Ext4 and I'm using the above code snippet outside of ready method

Note that all relative paths are relative to the current HTML document.(docs)
So, I believe in your case you should replace your path with:
Ext.Loader.setPath('Ext.ux', '../Scripts/Library/Ext/ux');

Related

Can't find static assets from express/npm module

tldr;
My project is an NPM module that is used by an ExpressJS server. The server needs to specify an endpoint and my module will do the rest. How do I get my module to load the correct html page and grab the correct js/css files from the correct path?
The Problem
I'm running into a problem where I can see the directory structure of the site, using the serveIndex library, and all the files are in their correct directories but for some reason when I try to load any of the files, whether from the serveIndex view or from the actual endpoint where it should load, I get nothing but 404 errors.
Here's an example if someone wanted to use this NPM module from their project.
app.js (their server)
const express = require('express')
const { adminAreaConfig } = require('express-admin-area')
const app = express()
const adminArea = adminAreaConfig(express) // my module being passed the "express" library
app.use('/admin', adminArea) // specify a URL to use my module
app.listen(3000, () => console.log('\n\nServer Online\n\n'))
Here's an image of my projects dir structure after it's been built.
Going off of a console.log(__dirname), which returns <long path string>/express-admin-area/build/src, I then tell my module, using the express reference passed by the actual server in the code above, to look in the views directory with
... import libraries etc ...
const adminAreaConfig = express => {
const adminArea = express.Router()
adminArea.use('/', express.static(__dirname + '/views') // sets my modules views to the "http://localhost:3000/admin" path
adminArea.use('/dirs', serveIndex(__dirname)) // will get into this later
... some other stuff like exports etc ...
This then attempts to load the index.html file in the express-admin-area/build/src/views directory but fails because it can't locate the CSS and JS files inside express-admin-area/build/src/views/static/css or .../js.
First, I know it fails because instead of looking for http://localhost:3000/admin/static/css/styles.css it looks for http://localhost:3000/static/css/styles.css, so that's another problem I need to solve entirely.
Second, looking back at the small code sample above, adminArea.use('/dirs', serveIndex(__dirname)), I'm using the serveIndex library in an attempt to view the directory structure. If I go to http://localhost:3000/admin/dirs I get the correct directories and files in the browser
But now, if I try to view an actual file I'm met with the error Cannot GET /admin/dir/main.js for example if I were to go to http://localhost:3000/admin/dir/main.js, but I can continue going deeper in the directories if I wanted such as the controllers or routes directories from the image.
What I want
I need a way to get these static assets to load. If I point my module to a basic html page with a simple <h1>Hello, World!</h1> then that's what Ill get but trying to load any outside scripts/stylesheets is when I get the 404 errors and nothing loads.
I'll be answering my own question.
The solution is actually pretty simple. The view layer of this module is handled by React, CRA to be specific. CRA will look for some specific environment variables, one of them being PUBLIC_URL. All I had to do was
Create a .env file in the root directory of my CRA
add PUBLIC_URL="/admin"
Afterward, it's just rebuilding the project, yarn build, and reset the server. CRA will then look at http://localhost:3000/admin/static/... instead of http://localhost:3000/static/... for static assets.

JS file loading failed in in oracle apex application

I have added a java script file, named 'dtformat.js' in my oracle apex application. The file was added inside the Static Application Files directory.
I added the file in my page using the code
<script src="#APP_IMAGES#dtformat.js" type="text/javascript"> </script>
The console log shows an error,
Loading failed for the <script> with source “#WORKSPACE/r/140/files/static/v74/dtformat.js”. 1 f:471
Then I found something at the location of static files. The size of the uploaded file shows 833, all the other files show 100KB,21KB,300KB as the file size, but this file- dtformat.js shows 833 and not 833KB. KB is excluded. What might be causing this error?
The problem is the path: why #WORKSPACE string is in the path?
#WORKSPACE/r/140/files/static/v74/dtformat.js

AWS Lambda package-deployed functions require() of a relative path, not found

I have a zip file containing the following structure (this is the root of the archive, not nested in a top-level folder, which I understand is a common cause of errors for aws-s3-lambda deployments):
- support/
- shared.js
- one.js
- two.js
and then in one.js and two.js:
var shared = require("./support/shared");
// ...
When I run this code locally, it works. I use the aws-sdk to upload the zip file to AWS-S3 and then use aws.lambda.createFunction() to create a function with that name and handler and everything. The created function DOES show up in my Lambda dashboard, but when I test it, I get "Cannot find module './support/shared'". I have also tried var shared = require("./support/shared.js"); and that gives "Cannot find module './support/shared.js'".
This is for runtime node6.10. The filename cases are correct for case-sensitive lambda.
Shouldn't this work?? What's the gotcha?
Is there a way to verify the file structure that Lambda is working in to show that the additional ./support/shared.js file actually made it to the working directory or whatever it uses?
The gotcha is that the zip file created on a windows machine has the wrong chmod permissions set in it for when AWS unpacks it. The files are there, but inaccessible but node just gives a generic warning about not found instead of that the folder access is denied.

Sencha EXT JS making Ext.ux.panel.PDF to work

I have planned to use the Ext.ux.panel.PDF extension https://github.com/SunboX/ext_ux_pdf_panel for my app but cannot make it to work inside my Sencha Architect 3.0.
I have downloaded the files and put the js file in my project directory /ext/src/ux/panel/PDF.js. In the apllication I have put the require line on the top level under Application
Ext.application({
requires: [
'Ext.window.MessageBox',
'Ext.ux.panel.PDF'
], ...
But when I want to instantiate the pdf panel with the code from the example I keep getting this error:
Uncaught Error: The following classes are not declared even if their files have been loaded: 'Ext.ux.panel.PDF'. Please check the source code of their corresponding files for possible typos: 'ext/src/ux/panel/PDF.js
Please advise.
EDIT: I have tried using a loader but the error is still present
Ext.Loader.setConfig({
enabled: true,
paths: {
Ext: 'ext/src'
}
});
The error you get means, that the file ext/src/ux/panel/PDF.js does not contain valid javascript. I tested this extension, and I don't get that error.
It the file is empty, you will get this error only, if it contains invalid javascript, this should be the second error, while the first will complain about the syntax error.
If the file is missing, you'll get another error.
Have a close look at the file, maybe it got corrupted while downloading or unzipping the extension. Or you edited it by error and introduced an error.
try to add below code on top of your Ext.application({ ~~~ source
Ext.Loader.setPath({
'Ext.ux' : 'YOURPATH(ABSOLUTE OR RELATIVE)/ext/src/ux'
});

Ploblem including a file- Titanium

I get an error while i try to include the js file which is in the same folder. I tried cleaning my project but was of no use.
The console says "error loading path".
Please help.
var db={}
Titanium.include('windows/gallery');
var displayButton= Ti.UI.createButton({
title:'Display',
onClick:function(){
db.gallery.open();
}
});
I have used open function which opens the file. The open file works has no problem.
usually, we use require('files/myFile'), where :
Resources/files/myFile.js is the path (note that require doesn't use the .js)
The js file is NOT at the same level that app.js, but included in Resource folder.
So here, you should do
Titanium.require('windows/gallery');
instead of
Titanium.include('windows/gallery');
By the way, the previous method was Titanium.include('windows/gallery.js');
Note the .js at the end of the include version.
Is it a mobile or desktop version ?