7 Replies Latest reply on May 18, 2010 4:59 AM by Hendrik Wimmer

    NullPointerException on column resize (Extenddatatable)

    Olli H. Newbie

      Hi,

      sometimes i am getting an NullPointerException after resizing the column of an extenddatatable. But it is not reproducible. Sometimes it works, but sometimes it fails.

      Does anyone have an idea?

      The problem seems to be in the changeColumnSize method in the ExtendDataTableState class.

      String[] newWidths = newValue.split(";");
       int index = 0;
      for (Iterator<UIColumn> iter = extendedDataTable.getSortedColumns(); iter.hasNext();) {
       UIComponent col = (UIComponent) iter.next();
       if (col.isRendered()){
       String colId = col.getId();
       value.put(colId, newWidths[index++]);
       }//if
       }//fo
      


      the newWidths array seems to be out of bounds..!!

      java.lang.ArrayIndexOutOfBoundsException: 2
       org.richfaces.component.ColumnsSizeState.changeColumnSize(ExtendedDataTableState.java:337)
       org.richfaces.component.ExtendedDataTableState.changeColumnSize(ExtendedDataTableState.java:173)
       org.richfaces.component.UIExtendedDataTable.processColumnResize(UIExtendedDataTable.java:186)
       org.richfaces.component.UIExtendedDataTable.broadcast(UIExtendedDataTable.java:101)
       org.ajax4jsf.component.UIDataAdaptor.broadcast(UIDataAdaptor.java:1364)
       org.ajax4jsf.component.UIDataAdaptor.broadcast(UIDataAdaptor.java:1364)
       org.ajax4jsf.component.UIDataAdaptor.broadcast(UIDataAdaptor.java:1364)
       org.ajax4jsf.component.UIDataAdaptor.broadcast(UIDataAdaptor.java:1364)
       org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
       org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
       org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
       org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:409)
       com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:101)
       com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
       com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
       org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
       org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
       org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
       org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
      
      


        • 2. Re: NullPointerException on column resize (Extenddatatable)
          Olli H. Newbie

          Hi

          here it is.

          HtmlExtendedDataTable table = new HtmlExtendedDataTable();
          IdUtils.assignId(table);
          
          table.setVar("items");
          table.setRowKeyVar("rkv");
          table.setValueExpression("selection",ViewUtil.createValueExpression("#{"+beanID+"_modelbean"+".selection}",SimpleSelection.class));
          table.setValueExpression("tableState",ViewUtil.createValueExpression("#{"+beanID+"_modelbean"+".tableState}",String.class));
          table.setValueExpression("binding",ViewUtil.createValueExpression("#{"+beanID+"_modelbean"+".table}",HtmlExtendedDataTable.class));
          table.setValueExpression("componentState",ViewUtil.createValueExpression("#{"+beanID+"_modelbean"+".componentState}",DataComponentState.class));
          table.setSortMode("single");
          table.setEnableContextMenu(false);
          table.disableGrouping();
          
          table.setHeight("165px");
          int tableWidth = list.size()*100;
          table.setWidth(tableWidth+"px");
          
          String headerLabel;
          
          HtmlColumn c =null;
          for (EntityMetaFieldVO entiyMetaFieldVO : list) {
          
          c = new HtmlColumn();
          IdUtils.assignId(c);
          c.setSortExpression("#{items.fields['"+entiyMetaFieldVO.getField()+"'].value}");
          c.setSortable(false);
          c.setValueExpression("sortBy",ViewUtil.createValueExpression("#{items.fields['"+entiyMetaFieldVO.getField()+"'].value}"));
          c.setWidth("100");
          
          HtmlOutputText text = new HtmlOutputText();
          text.setValueExpression(CommonConstants.ATTRIBUTE_VALUE, ViewUtil.createValueExpression("#{items.fields['"+entiyMetaFieldVO.getField()+"'].value}"));
          c.getChildren().add(text);
          
          table.getChildren().add(c);
          }


          • 3. Re: NullPointerException on column resize (Extenddatatable)
            Ilya Shaikovsky Master

            and which is the scope of the bean which hold binding?

            • 4. Re: NullPointerException on column resize (Extenddatatable)
              Olli H. Newbie

              the bean is in session scope

              • 5. Re: NullPointerException on column resize (Extenddatatable)
                Ilya Shaikovsky Master

                should be request. JSF components recreated on every request so storing them in session scoped objects could cause different issues.

                • 6. Re: NullPointerException on column resize (Extenddatatable)
                  Olli H. Newbie

                  thanx ilya

                  I put the bean in request scope. But the same behavior as with session scope.

                  Any other idea?

                  • 7. Re: NullPointerException on column resize (Extenddatatable)
                    Hendrik Wimmer Newbie

                    Hi there,

                     

                    I have the same problem here.

                    The bean that holds the binding-attribute is in request scope. I get a similar exception:

                     

                    Caused by: java.lang.ArrayIndexOutOfBoundsException: 3
                        at org.richfaces.component.ColumnsSizeState.changeColumnSize(ExtendedDataTableState.java:337)
                        at org.richfaces.component.ExtendedDataTableState.changeColumnSize(ExtendedDataTableState.java:173)
                        at org.richfaces.component.UIExtendedDataTable.processColumnResize(UIExtendedDataTable.java:186)
                        at org.richfaces.component.UIExtendedDataTable.broadcast(UIExtendedDataTable.java:101)
                        at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:329)
                        at org.ajax4jsf.component.AjaxViewRoot.broadcastEventsForPhase(AjaxViewRoot.java:304)
                        at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:261)
                        at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:417)
                        at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
                        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
                        ... 31 more