Ext JS 6 Modern Set TabBar Scrollable

By default in Ext JS 6 Modern version (or Sencha Touch), the TabPanel’s TabBar is not scrollable. That means if opened tabs is too many that the TabBar will push the earlier tabs to left side, then they will become invisible anymore (because it’s not scrollable)

To make it scrollable, we need set tabBar.scrollable config to true when creating TabPanel

Then we can drag the TabBar to scroll it.

 

By default the scrollable is 'horizontal' , and of course you can set it to 'vertical' .

 

 

 

Ext JS 6 Duplicate Entity Name Error

When I reopened Account Profile tab after closing it, I got following error (shown in browser’s console)

Duplicate entity name “AccountProfileModelList”: AccountProfileModelList and AccountProfileModelList(…)

 

In this page, I defined a Model named AccountProfileModelList

 

When opening the Account Profile tab first time, the AccountProfileModelList will be defined. And when opening the tab second time, the AccountProfileModelList will be defined again. This is why the error appeared.

What’s interesting is that In Ext 5 above scenario won’t cause any error, but in Ext 6, a model cannot be defined twice anymore.

 

To fix this issue, we need use typeof(AccountProfileModelList) == 'undefined'  to check whether the model is already defined, if it’s defined the model creation code won’t be executed.

So the above code should be changed to

 

A more Ext way to detect whether a Ext class is already defined is using Ext.ClassManager.isCreated(className)

Above code can also be changed to

 

Ext JS 6 Invalid Component Id

In Ext 6, I got following error

ExtJs invalid component id “profile.ModifyUserBasicInfo”

 

Following is code producing the error

 

This error doesn’t appear in Ext 5, after upgrading to Ext 6, it appears now.

 

It is caused by the id property cannot contain “.” symbol, but the id property we used here is profile.ModifyUserBasicInfo

To fix this issue, we can replace all “.” to “-“.

 

Following link from describes the id property naming rule

http://docs.sencha.com/extjs/6.2.1/classic/Ext.window.Window.html#cfg-id

The original quote

Note: Valid identifiers start with a letter or underscore and are followed by (optional) additional letters, underscores, digits or hyphens.

 

 

 

MySQL find all MyISAM tables

The information_schema table saves information about databases, tables, columns, indexes and triggers, etc.

 

To list all MyISAM tables, we can use following SQL

 

And to find MyISAM tables in database wordpress

 

Next filter them with a table prefix wp_

Ext JS form load custom object

I have a custom object currentUser, it contains bank account name, mobile number,  and I want fill the form with currentUser’s properties.

 

To load a custom object,  first define a Model, then instantiate the Model with custom object, next call loadRecord with the model object. Note that I tried Ext.form.Panel loadRecord(), it’s not working for me, Ext.form.Basic should be used here. So we need call getForm() to get Ext.form.Basic

 

Another example

http://jsfiddle.net/el_chief/HBah5/4/

 

 

 

DeferredResult not working in Tomcat

The DeferredResult works on my local machine, but not work on the server machine.

On my local machine when a DeferredResult called setResult method, the response will return immediately. But on remote server machine, it only return the response to client after 30s (default timeout is 30s).

According to above posts, it may be caused by earlier version Tomcat 8 issue.

Then I tried jetty on remote server machine, it works. Next I checked the version by running CATALINA_BASE/bin/version.sh, it’s displaying

Server version: Apache Tomcat/8.0.14 (Debian)

And my local Tomcat version is 8.0.36

 

Then I upgrade the remote Tomcat version from 8.0.14 to 8.0.36 (upload my local tomcat to remote server) and try DeferredResult again, it works!

 

http://stackoverflow.com/questions/24619445/spring-async-deferredresult-not-working-in-tomcat-8

ExtJS Convert Query Parameter Object to URL

Assume we have a parameter object

 

To convert it to URL query, we can use following code

it will output

name=POS&min_price=10&start_date=2016-01-01

 

And to concatenate two URL part, we can use following code

It will build URL like following

http://test.com/products/export?name=POS&min_price=10&start_date=2016-01-01

 

 

 

No module named pefile

Today I want to build a python script to EXE file using PyInstaller. But after running PyInstaller, I got following error

No module named pefile

The full stack trace is

 

Starting from PyInstaller 3.2, a new module named pefile is introduced. This module is used to work with Windows binary file (EXE file, also called PE file). Before PyInstaller 3.2, PE related operation is done using its own module, like setting PE header and DOS header)

 

Solution

Assume the Python installation direcotry is C:\Python27.

Open Command Prompt window, and navigate to C:\Python27\Scripts

cd C:\Python27\Scripts

Then install pefile module using following command

pip install pefile

 

(pip is built into latest Python distribution, 2.7.12 for now)

Multiprocessing for Frozen Python

Recently I built a GUI application using PySide, and do some background calculation using multiprocessing. Using Python interpreter to run this application works smoothly. But if I freeze it to Windows executable file (exe) and run it, guess what, I got two main windows showing up!

 

After searching a while, I found following code should be added

It should be placed right after:

 

The freeze_support() is mainly used to pass initialization data from parent process to newly created process using pipe, including modules, process name, current working directory, etc. In Unix-based system this function is not needed, because fork will do these things for us (multiprocessing.Process will call os.fork() in start method on Linux)

 

the low-level implementation is in Lib/multiprocessing/forking.py and a wrapper in Lib/multiprocessing/__init__.py.

By reading the source code, we can see Python will detect –multiprocessing-fork in command line arguments to determine whether current process is child process or not. And the last command line argument is the pipe file handle. The data in main process is serialized using pickle, then pass to child process using pipe.

Shiboken Multiple Include Path on Windows

In shiboken documentation, it’s saying the separator of include path should be : (colon)

But on Windows every full path is containing colon (e.g. C:\Windows\cmd), it will mess with the colon separator.

In its source code printUsage() function I found it’s actually using a PATH_SPLITTER macro to represent the separator. And under windows it’s semicolon..

 

At past I’m using colon as separator:

–include-paths=D:\Qt\4.8.7\include\:D:\Qt\4.8.7\include\QtCore\:D:\Python27\Lib\site-packages\PySide\include\PySide

And I got lots of error messages like following:

type is specified in typesystem, but not defined

After replacing colon with semicolon, these errors are gone.