1. #1
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    1
    Arno.Nyhm is on a distinguished road

      0  

    Default ArrayIndexOutOfBoundsException: -1 with wrong AutoExpandColumn

    ArrayIndexOutOfBoundsException: -1 with wrong AutoExpandColumn


    it would be nice if the autoexpandcolumn would be ignored or a good error message would appear if the autoexpandcolumn not match exactly the column id

    if you have a indexoutofbounds exeption in some isHidden function then it is difficult to find out why.


    PHP Code:
    // GridView.java
    protected void autoExpand(boolean preventUpdate) {
        if (!
    userResized && grid.getAutoExpandColumn() != null) {
          
    int tw cm.getTotalWidth(false);
          
    int aw grid.getWidth(true) - getScrollAdjust();
          if (
    tw != aw) {
            
    int ci cm.getIndexById(grid.getAutoExpandColumn()); // <-- this returns -1 if the column is not found
            
    if (cm.isHidden(ci)) {  // <----- here it try to find if tis hidden cm.isHidden(-1)
              
    return;
            }
        
        
    // ColumnModel.java
    public boolean isHidden(int colIndex) {
        return 
    configs.get(colIndex).isHidden(); // <----- and here i get a index out of bound exception
      

    to reproduce add this to any grid example:

    PHP Code:
    grid.setAutoExpandColumn("unknowncolumnname"); 
    PHP Code:
    [ERRORUnable to load module entry point class org.yournamehere.client.MainEntryPoint (see associated exception for details)
    java.lang.ArrayIndexOutOfBoundsException: -1
        at java
    .util.ArrayList.get(ArrayList.java:324)
        
    at com.extjs.gxt.ui.client.widget.grid.ColumnModel.isHidden(ColumnModel.java:379)
        
    at com.extjs.gxt.ui.client.widget.grid.GridView.autoExpand(GridView.java:680)
        
    at com.extjs.gxt.ui.client.widget.grid.GridView.layout(GridView.java:502)
        
    at com.extjs.gxt.ui.client.widget.grid.Grid.onResize(Grid.java:720)
        
    at com.extjs.gxt.ui.client.widget.BoxComponent.setSize(BoxComponent.java:563)
        
    at com.extjs.gxt.ui.client.widget.BoxComponent.afterRender(BoxComponent.java:635)
        
    at com.extjs.gxt.ui.client.widget.grid.Grid.afterRender(Grid.java:611)
        
    at com.extjs.gxt.ui.client.widget.Component.render(Component.java:961)
        
    at com.extjs.gxt.ui.client.widget.Layout.renderComponent(Layout.java:258)
        
    at com.extjs.gxt.ui.client.widget.Layout.renderAll(Layout.java:249)
        
    at com.extjs.gxt.ui.client.widget.Layout.onLayout(Layout.java:230)
        
    at com.extjs.gxt.ui.client.widget.layout.FitLayout.onLayout(FitLayout.java:58)
        
    at com.extjs.gxt.ui.client.widget.Layout.layout(Layout.java:96)
        
    at com.extjs.gxt.ui.client.widget.Layout$2.handleEvent(Layout.java:59)
        
    at com.extjs.gxt.ui.client.util.DelayedTask$1.run(DelayedTask.java:30)
        
    at com.extjs.gxt.ui.client.util.DelayedTask.delay(DelayedTask.java:52)
        
    at com.extjs.gxt.ui.client.widget.Layout.onResize(Layout.java:240)
        
    at com.extjs.gxt.ui.client.widget.Layout$1.handleEvent(Layout.java:52)
        
    at com.extjs.gxt.ui.client.widget.Layout$1.handleEvent(Layout.java:1)
        
    at com.extjs.gxt.ui.client.event.BaseObservable.callListener(BaseObservable.java:176)
        
    at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:96)
        
    at com.extjs.gxt.ui.client.widget.Component.fireEvent(Component.java:444)
        
    at com.extjs.gxt.ui.client.widget.BoxComponent.setSize(BoxComponent.java:572)
        
    at com.extjs.gxt.ui.client.widget.BoxComponent.afterRender(BoxComponent.java:635)
        
    at com.extjs.gxt.ui.client.widget.ScrollContainer.afterRender(ScrollContainer.java:194)
        
    at com.extjs.gxt.ui.client.widget.Component.render(Component.java:961)
        
    at com.extjs.gxt.ui.client.widget.Layout.renderComponent(Layout.java:258)
        
    at com.extjs.gxt.ui.client.widget.Layout.renderAll(Layout.java:249)
        
    at com.extjs.gxt.ui.client.widget.Layout.onLayout(Layout.java:230)
        
    at com.extjs.gxt.ui.client.widget.layout.RowLayout.onLayout(RowLayout.java:225)
        
    at com.extjs.gxt.ui.client.widget.layout.FillLayout.onLayout(FillLayout.java:80)
        
    at com.extjs.gxt.ui.client.widget.Layout.layout(Layout.java:96)
        
    at com.extjs.gxt.ui.client.widget.Container.doLayout(Container.java:348)
        
    at com.extjs.gxt.ui.client.widget.Container.layout(Container.java:444)
        
    at com.extjs.gxt.ui.client.widget.LayoutContainer.layout(LayoutContainer.java:241)
        
    at com.extjs.gxt.ui.client.widget.Container.doLayout(Container.java:364)
        
    at com.extjs.gxt.ui.client.widget.Container.layout(Container.java:444)
        
    at com.extjs.gxt.ui.client.widget.LayoutContainer.layout(LayoutContainer.java:241)
        
    at com.extjs.gxt.ui.client.widget.Container.layout(Container.java:427)
        
    at com.extjs.gxt.ui.client.widget.LayoutContainer.layout(LayoutContainer.java:236)
        
    at com.extjs.gxt.ui.client.widget.Window.layout(Window.java:488)
        
    at com.extjs.gxt.ui.client.widget.Window.afterShow(Window.java:816)
        
    at com.extjs.gxt.ui.client.widget.Window.show(Window.java:791)
        
    at org.yournamehere.client.MainEntryPoint.onModuleLoad(MainEntryPoint.java:98)
        
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        
    at java.lang.reflect.Method.invoke(Method.java:597)
        
    at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:326)
        
    at com.google.gwt.dev.shell.BrowserWidget.attachModuleSpace(BrowserWidget.java:343)
        
    at com.google.gwt.dev.shell.ie.BrowserWidgetIE6.access$300(BrowserWidgetIE6.java:37)
        
    at com.google.gwt.dev.shell.ie.BrowserWidgetIE6$External.gwtOnLoad(BrowserWidgetIE6.java:77)
        
    at com.google.gwt.dev.shell.ie.BrowserWidgetIE6$External.invoke(BrowserWidgetIE6.java:161)
        
    at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
        
    at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
        
    at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
        
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
        
    at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
        
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
        
    at com.google.gwt.dev.SwtHostedModeBase.processEvents(SwtHostedModeBase.java:235)
        
    at com.google.gwt.dev.HostedModeBase.pumpEventLoop(HostedModeBase.java:558)
        
    at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405)
        
    at com.google.gwt.dev.HostedMode.main(HostedMode.java:232
    This forum needs your help: you got hints from the community and now you have fixed your code? dont just reply with "now its fixed" or "i found the error"! please take the time to post also an detailed answer with the working code.

    GreaseMonkey Script for a GXT-only Forum: it hides ExtJs here: New Posts • Search Results • Advanced Search form • Category overview http://www.extjs.com/forum/showthrea...041#post410041

  2. #2
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    1
    Arno.Nyhm is on a distinguished road

      0  

    Default


    add this exception:

    PHP Code:
    if (ci == -1) throw new RuntimeException("AutoExpandColumn '" grid.getAutoExpandColumn() + "' not found in ColumnModel"); 
    or check the id:

    PHP Code:
             if (ci == -|| cm.isHidden(ci)) {
               return;
            } 
    This forum needs your help: you got hints from the community and now you have fixed your code? dont just reply with "now its fixed" or "i found the error"! please take the time to post also an detailed answer with the working code.

    GreaseMonkey Script for a GXT-only Forum: it hides ExtJs here: New Posts • Search Results • Advanced Search form • Category overview http://www.extjs.com/forum/showthrea...041#post410041

  3. #3
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Throwing an exception is a bad idea. This would be compiled down to javascript and would increase the filesize, which is uneeded.

  4. #4
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    1
    Arno.Nyhm is on a distinguished road

      0  

    Default


    but throwing an ArrayIndexOutOfBoundsException is also not a good solution. so ignoring this autoexpand with "if (ci == -1 || cm.isHidden(ci)) {" is then the best solution... or not?
    This forum needs your help: you got hints from the community and now you have fixed your code? dont just reply with "now its fixed" or "i found the error"! please take the time to post also an detailed answer with the working code.

    GreaseMonkey Script for a GXT-only Forum: it hides ExtJs here: New Posts • Search Results • Advanced Search form • Category overview http://www.extjs.com/forum/showthrea...041#post410041

  5. #5
    Ext User fother's Avatar
    Join Date
    Sep 2007
    Location
    Brazil
    Posts
    744
    Vote Rating
    -1
    fother is an unknown quantity at this point

      0  

    Default


    work as intend..

    javadoc: The id of a column in this grid that should expand to fill unused space (pre-render). This id can not be 0.

    if the id dont exist.. return an ArrayIndexOutOfBoundsException

  6. #6
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    1
    Arno.Nyhm is on a distinguished road

      0  

    Default


    if you are new to grids and you make you first grid and you have this mistake in spelling then you spend hours of debugging just to find out its a spelling bug in this line...

    so a better hint would be nice in this place.

    would you realy guess from the stacktrace that this error comes from the missing autoexpandcolumn?
    This forum needs your help: you got hints from the community and now you have fixed your code? dont just reply with "now its fixed" or "i found the error"! please take the time to post also an detailed answer with the working code.

    GreaseMonkey Script for a GXT-only Forum: it hides ExtJs here: New Posts • Search Results • Advanced Search form • Category overview http://www.extjs.com/forum/showthrea...041#post410041

  7. #7
    Ext User fother's Avatar
    Join Date
    Sep 2007
    Location
    Brazil
    Posts
    744
    Vote Rating
    -1
    fother is an unknown quantity at this point

      0  

    Default


    I agree if you because I pass for the same problem kkkk

    if use assert?

  8. #8
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    1
    Arno.Nyhm is on a distinguished road

      0  

    Default


    assert is also possible.

    any message is welcome ;-)
    This forum needs your help: you got hints from the community and now you have fixed your code? dont just reply with "now its fixed" or "i found the error"! please take the time to post also an detailed answer with the working code.

    GreaseMonkey Script for a GXT-only Forum: it hides ExtJs here: New Posts • Search Results • Advanced Search form • Category overview http://www.extjs.com/forum/showthrea...041#post410041

  9. #9
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    An assert is the only way to go and i added it.

  10. #10
    Ext User fother's Avatar
    Join Date
    Sep 2007
    Location
    Brazil
    Posts
    744
    Vote Rating
    -1
    fother is an unknown quantity at this point

      0  

    Default


    when java its compiled to javascript.. the assert "go to"?

Thread Participants: 2