1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    41
    Vote Rating
    0
    barrygently is on a distinguished road

      0  

    Default BorderLayout fails to layout if no config for region

    BorderLayout fails to layout if no config for region


    If I have a BorderLayout thus:

    Code:
              layout = new YAHOO.ext.BorderLayout (document.body, {
                         hideOnLayout: true,
                         west: {
    	                    split:true,
    	                    initialSize: 200,
    	                    minSize: 175,
    	                    maxSize: 400,
    	                    collapsible: true,
                                autoScroll: true,
                                titlebar: true,
                                collapsible: true
    	                   },
    	             center: {
    	                      autoScroll:true
                                 }
    	                });
              layout.beginUpdate();
    	  layout.add('north', new YAHOO.ext.ContentPanel('menu', {}));
    	  layout.add('west', new YAHOO.ext.ContentPanel('navigation', {}));
              layout.add('center', new YAHOO.ext.ContentPanel('main', {closable: false}));
              layout.endUpdate ();
    It will fail when trying to add the "north" region. To get it to work you have to add an empty config:

    Code:
    north: {}
    Of course if I could do:

    Code:
    north: { content: new YAHOO.ext.ContentPanel('menu', {}) }
    That would be even better

    Gary

  2. #2
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    How are you defining a region with no config and getting the error? I don't see it in your code.

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    58
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Of course it will fail if you add a ContentPanel to the "north" region, and you have not configured a "north" region!

  4. #4
    Ext User
    Join Date
    Mar 2007
    Posts
    41
    Vote Rating
    0
    barrygently is on a distinguished road

      0  

    Default


    Well perhaps there is some confusion on my part, but it's not obvious that the config is there to also define the regions (the documentation doesn't mention that).

    In other words, if you are adding to a region that has no config it would be nice then if it "auto" configured that region for you, i.e. added it.

    At the moment to define the region you have to add an empty config, which is a little incongruous.

    Gary

  5. #5
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    The purpose of the config is to DEFINE the region. Yeah, the code could guess that you want to auto configure a region that you didn't define, but then next week somebody's going to say,

    'I inadvertently added something to a region I didn't define, and it auto-added it - why doesn't it throw an exception?'.

    I don't think it's a big deal to specify 'north: {}', then it's obvious looking at that piece of code what the layout is.

  6. #6
    Ext User
    Join Date
    Mar 2007
    Posts
    41
    Vote Rating
    0
    barrygently is on a distinguished road

      0  

    Default


    Code:
    I don't think it's a big deal to specify 'north: {}', then it's obvious looking at that piece of code what the layout is.
    That depends upon your point of view.

    Code:
    'I inadvertently added something to a region I didn't define, and it auto-added it - why doesn't it throw an exception?'.
    That couldn't happen because if they called layout.add then they will be explicitly specifying the region it gets added to.

    As I said, I was thrown off by the name of the parameter and that it doesn't tell you that you have to use the config to define the regions you want to use.

    Gary

  7. #7
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    The config defines the regions you want. Implicitly creating a region (or anything else) is generally bad practice. It makes things difficult to debug. If you want a region, you need to define it.

  8. #8
    Ext User
    Join Date
    Mar 2007
    Posts
    41
    Vote Rating
    0
    barrygently is on a distinguished road

      0  

    Default


    Code:
    Implicitly creating a region (or anything else) is generally bad practice.
    I'd disagree there and would point out that you implicitly create tabs when multiple content panels are added to a region.

  9. #9
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    What I was referring to was implicitly correcting programming mistakes. For example, you don't define a region and then try to add a panel to the undefined region. That's a programmer mistake. The reason for the config is to define what regions you want.

    The auto creation of tabs is not implicit, that's the only way it functions with multiple panels. There is no other option.

  10. #10
    Ext User
    Join Date
    Mar 2007
    Posts
    41
    Vote Rating
    0
    barrygently is on a distinguished road

      0  

    Default


    Again I'd disagree that it's a programmers mistake because it's making the programmer do the work twice. When they do layout.add they have to explicitly state which region they want to add to. To force them to define a "null" configuration (which isn't documented) for a region when they are explicitly requesting the addition to that region is problematic.

    Also consider, as a comparison the java.awt.BorderLayout, you do not have to explicitly "pre-define" which regions you are gonna be working with because the regions are already present.

    Remember that the mistake you are wanting to prevent isn't documented, which is why I got tripped up by it. The name of the parameter is "config", indicating configuration NOT specification/definition. Also, by explicitly adding content to a region I know I'm not making a mistake.

Similar Threads

  1. document for these config parameters in BorderLayout?
    By wq7278 in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 7 Mar 2007, 10:15 AM
  2. Don't want border of a layout region
    By wavel in forum Ext 1.x: Help & Discussion
    Replies: 4
    Last Post: 26 Feb 2007, 9:17 PM
  3. Collapse layout region on load
    By Tym in forum Ext 1.x: Help & Discussion
    Replies: 9
    Last Post: 17 Feb 2007, 9:20 PM
  4. change layout region config?
    By seldon in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 11 Dec 2006, 12:40 PM

Thread Participants: 4