You found a bug! We've classified it as a bug in our system. We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Jan 2009
    Location
    Manchester, UK
    Posts
    21
    Vote Rating
    0
    ody is on a distinguished road

      0  

    Default [CLOSED]Ext.History.init() bug?

    [CLOSED]Ext.History.init() bug?


    Just attempted to use Ext.History (ext 3.2.1), and get this error when calling init (from chrome) :

    PHP Code:
    Uncaught TypeErrorCannot read property 'value' of null
    startUp ext
    -all-debug.js:30124
    init ext
    -all-debug.js:30176
    (anonymous function) index.html:17
    call 
    Plain index.html included nothing but:
    PHP Code:
     <script type="text/javascript">
      
    Ext.onReady(function(){
       
    Ext.History.init();
      });
     
    </script> 
    The fix as I would guess it, would be to change line 30145 (in ext-all-debug.js) from:

    PHP Code:
    fieldId'x-history-field'
    to

    PHP Code:
    fieldId: {value 'x-history-field'}, 
    Which appears to work for me, at least.
    Last edited by ody; 23 Sep 2010 at 6:22 AM. Reason: forgot to mention the name of the file that the change needs to be made in.

  2. #2
    Sencha User
    Join Date
    Jan 2009
    Location
    Manchester, UK
    Posts
    21
    Vote Rating
    0
    ody is on a distinguished road

      0  

    Default


    Actually, it looks like it is something to do with the DOM element id:x-history-field not existing .. which I can see CSS for but nothing that creates the element. If I create a div in the body with id x-history-field all works as expected.

  3. #3
    Sencha User
    Join Date
    Jan 2009
    Location
    Manchester, UK
    Posts
    21
    Vote Rating
    0
    ody is on a distinguished road

      0  

    Default


    I've put this in at line 30165ish:

    PHP Code:
    if(!hiddenField || hiddenField == null)
    {
        
    Ext.DomHelper.append('body', {tag'div'id"x-history-field"});
        
    hiddenField Ext.getDom(Ext.History.fieldId);

    I'm new to all this so not really sure if this is the best possible fix, would love some input either way.

  4. #4
    Sencha User
    Join Date
    Aug 2009
    Posts
    480
    Vote Rating
    1
    plalx has a spectacular aura about plalx has a spectacular aura about

      0  

    Default


    It is not a bug, Ext.History class is designed that way.

    By looking at a part of init() code:
    Code:
    hiddenField = Ext.getDom(Ext.History.fieldId);
    if (Ext.isIE) {
        iframe = Ext.getDom(Ext.History.iframeId);
    }
    There is nothing creating the element, letting that task up to the developer.

    It would still be a valid question to ask why they choosed not to create elements required by Ext.History automatically...

  5. #5
    Sencha User
    Join Date
    Jan 2009
    Location
    Manchester, UK
    Posts
    21
    Vote Rating
    0
    ody is on a distinguished road

      0  

    Default


    ExtJS is to good, I keep making assumptions it's taking care of things.

  6. #6
    Sencha User
    Join Date
    Aug 2009
    Posts
    480
    Vote Rating
    1
    plalx has a spectacular aura about plalx has a spectacular aura about

      0  

    Default


    Quote Originally Posted by ody View Post
    I've put this in at line 30165ish:.
    You should never directly modify the ext code since you will lose changes when updating the library.

    You should simply override the class methods that you want using Ext.override().

    In this specific case, you could only add this code to the Ext.onReady() function:

    *Note: Ext.History class needs an hidden input field, not a div element.

    Code:
    Ext.DomHelper.append('body', {tag: 'input', type:'hidden', id: "x-history-field"});
    You can also create an interceptor to Ext.History.init() function that would create the element before processing the function.

    Code:
    //Something like this
    
    Ext.History.init = Ext.History.init.createInterceptor(function(){
           Ext.DomHelper.append('body', {tag: 'input', type:'hidden', id: "x-history-field"});
    });
    Look at the createInterceptor doc here.

  7. #7
    Sencha User
    Join Date
    Jan 2009
    Location
    Manchester, UK
    Posts
    21
    Vote Rating
    0
    ody is on a distinguished road

      0  

    Default


    thanks scarsick! funnily I've learnt a lot by not RTFM :P

  8. #8
    Sencha User
    Join Date
    Jan 2009
    Location
    Manchester, UK
    Posts
    21
    Vote Rating
    0
    ody is on a distinguished road

      0  

    Default


    This interceptor function has given me an idea..

    PHP Code:
    Ext.ns('Ext.Debug');
    Ext.Debug = function(){

        
    Ext.History.init Ext.History.init.createInterceptor(function(){
            
    hiddenField Ext.getDom(Ext.History.fieldId);
            if(!
    hiddenField || hiddenField == null)
            {
                
    alert('Ext.History.init: no hidden field defined.');
                return  
    false;
            }

            return 
    true;
        });

        
    Ext.apply Ext.History.init.createInterceptor(function(ocdefaults){
            if(
    typeof o != "object" || typeof c != "object")
            {
                
    alert('Ext.apply: arguments must be of type object.');
                return 
    false;
            }
            return 
    true;
        });

    }(); 
    Every time I run into problems like these I'll simply add a test case to Ext.Debug. This can then be used by others to quickly pick up on common mistakes.

    I've got this feeling that someone is going to tell me this has already been done :-D

  9. #9
    Sencha User
    Join Date
    Aug 2009
    Posts
    480
    Vote Rating
    1
    plalx has a spectacular aura about plalx has a spectacular aura about

      0  

    Default


    I like the idea... this pattern could almost be used in the entire framework to give custom error messages that would help fixing bugs, without having the code polluted with error checking code.

  10. #10
    Sencha User
    Join Date
    Jan 2009
    Location
    Manchester, UK
    Posts
    21
    Vote Rating
    0
    ody is on a distinguished road

      0  

    Default


    Do you or any mods/devs know the best way to get something like this off the ground? I know I could slap it on googlecode and add test cases as I stumble over the ExtJS library but that doesn't feel like it would be the best way forward.

    Maybe starting a new thread somewhere asking for input from the community?

Similar Threads

  1. Replies: 2
    Last Post: 20 Aug 2010, 7:07 AM
  2. Ext.History IE back/forward bug
    By ykoehler in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 23 Mar 2010, 9:15 AM
  3. [INFOREQ] Ext.History bug
    By poopsmith in forum Ext 3.x: Bugs
    Replies: 2
    Last Post: 12 Mar 2010, 12:43 PM
  4. [2.3.0] Ext.History Encoding Bug
    By Teimur in forum Ext 2.x: Bugs
    Replies: 1
    Last Post: 4 Feb 2010, 8:40 AM
  5. [CLOSED] DateField Init Bug
    By TheBuzzer in forum Ext GWT: Bugs (1.x)
    Replies: 1
    Last Post: 3 Sep 2008, 8:11 AM

Thread Participants: 1