| Summary: Advanced Application Design |
| Author: Ext community (번역 : Rhio.Kim) |
| Published: Unkown |
| Ext Version: 1.1 |
Languages: English Korean
|
더글러스 크록포드에 의해서 고안된 Module Pattern은 웹 어플리케이션을 가장 강력하고 유연하게 만드는 설계 방법입니다..
여러분은 여기에서 몇 가지 방법을 찾을 수 있을 것입니다.
고급 레벨에서 모든 애플리케이션은 HTML 의 document.body를 캡슐화하기 위해 Ext.Viewport를 사용해야 합니다.
당신의 애플리케이션 오브젝트는 Viewport에 아규먼트화 될 것입니다.
MyApp = function(){ var count = 0; // Private Variable for the module. Not accessible from outside var increaseCount = function(){ // Private function. Not accessible from outside count++; }; var navigationTree = new Ext.tree.TreePanel({ region: 'west', loader: new Ext.tree.TreeLoader({ url: 'getMenu.php' }), root: new Ext.tree.TreeNode({ id: 'root' } }); var centerRegion = new Ext.Container({ region: 'center', autoEl: {tag: 'div'}, layout: 'fit' }); // MyApp 오브젝트에 할당되어진 함수로부터 반환하는 것 // 애플리케이션은 추가적인 특별한 기능들을 갖는 Viewport return new Ext.Viewport({ layout: 'border', items: [{ region: 'north', height: 100, el: 'header-element-id' // Incorporate existing header }, navigationTree, centerRegion ], // The following properties comprise the apps public interface init : function(){ // Can be called from outside // Here comes the initialisation code }, loadComponent: function(url) { // Your code to load a component into '''centerRegion''' }, getCount : function(){ // Privileged method. Can be called from outside return count; }, checkCount : function(){ increaseCount(); if (this.getCount() > 10) alert("count is greater than 10"); } } }();
기본적인 예제에서처럼, 공개된 인터페이스의 public 메소드로 private 변수와 함수에 접근할 것입니다.