tags:

views:

37

answers:

1

I already know that ExtJs is a framework to build RIA and it doesn't fit well into a defined page layout. My applications is one page only where the main content is dynamic (from Ajax call)

<html>
    <head> some stuff</head>
    <body>
    <div class = “header”> some stuff </div>
    <div class=”wrap”>
     <div class=”mainContent” id=”main”></div>
     <div class=”sidebar” id=”side”></div>
    </body>
    </html>

what I need to do is build contents on main and side. mainContent can have different inner layout depending on the stuff I need to display

i.e. (I need to display an home page, a category page and article page)

// mainContent for home page:

<div class=”mainContent” id=”main”>
 <div class=”mainBox” id=”mB”> some stuff and some other divs</div>
 <div class=”leftBox” id=”lB”> some stuff and some other divs</div>
<div class=”rightBox” id=”rB”> some stuff and some other divs</div>
</div>

// mainContent for category page:

<div class=”mainContent” id=”main”>
 <div class=”categoryHeader” id=”ch”>
  some stuff
  <div class=”categoryContent” id=”cc”>
  some stuff
</div>
</div>
 <div class=”subCategoryHeader” id=”sch”> 
  some stuff
<div class=”subCategoryContent” id=”cc”>
  some stuff
</div>
</div>
<div class=”articles” id=”art”> 
 <div class=”artHeader” id=”aah”>some stuff</div>
<div class=”artContent” id=”aac”>some stuff</div>
</div>
</div>

// mainContent for article  page:

<div class=”mainContent” id=”main”>
 <div class=”articleHeader” id=”aH”> some stuff</div>
 <div class=”articleHeader” id=”aC”> some stuff</div>
<div class=”articleComments” id=”aCC”> some stuff</div>
</div>

My approach:

I’m using an Ext.Container with card layout with three items, one for each page: i.e.:

mainContent = new Ext.Container({
// some cfg options
items: [{xtype: ‘homepage’},{xtype:’categories’},{xtype:’articles’}]    
})

where

MyApp.homePage = Ext.extend(Ext.Container, {
  onRender: function(ct) {
    this.el = ct.createChild({
      children: [
        {cls: 'mainBox', id:’mB’},
        {cls: 'leftBox', id:’lB’},
        {cls: 'rightBox', id:’rB’},
      ]
    });
    MyApp.homePage.superclass.onRender.apply(this, arguments);
  }
});
Ext.reg('‘homepage’', MyApp.homePage);

// same idea for the other xtypes

Question is:

What is the best way to build subpage components (mainbox, leftbox, rightbox, etc..) keeping into account that for each component I need an Ajax call (i.e. leftBox can be the last 5 articles).

Thanks

P.S. I don't want to use jQuery or similar stuff.

A: 

First, there's rarely a case for subclassing Container unless you're really creating a fairly low-level component. For what you're doing, you should probably be using Panel instead as it has more functionality.

Second, based on your description it sounds like you should be using a BorderLayout (layout:'border') for the panel containing your subpage components. Have you looked at that layout style?

bmoeskau