5 Replies Latest reply on Dec 1, 2011 5:02 AM by rednose

    Preserving extendeddatatable nested in tabpanel

    rednose

      I want to create a web application that works similiar to a file explorer like dolphin, where you can have several tabs that contain tables to display some files. But when resizing the column width it comes to an error. To do so I create a page using this code

       

      {code:xml}

      <h:form id="tabsForm">

      <rich:tabPanel

                id="tabPanel"

                switchType="ajax"

                itemChangeListener="#{yTabPanelBean.activeItemChanged}"

                activeItem="#{yTabPanelBean.selectedTab}">

       

      <rich:tab

                name="t1"

                header="tab 1">

      <rich:extendedDataTable>

      <rich:column>

                <f:facet name="header">header</f:facet>

      </rich:column>

      </rich:extendedDataTable>

      </rich:tab>

      <rich:tab

                name="t2"

                header="tab 2">

      <rich:extendedDataTable>

      <rich:column>

      <f:facet name="header">header2</f:facet>

      </rich:column>

      </rich:extendedDataTable>

      </rich:tab>

      </rich:tabPanel>

      </h:form>

      {code}

       

      and

       

      {code}

      @ManagedBean

      @SessionScoped

      public class YTabPanelBean {

       

        private String selectedTab = "t1";

       

                public Object getSelectedTab() { return selectedTab;}

                public void setSelectedTab(Object selectedTab) { this.selectedTab = (String) selectedTab;}

       

        public void activeItemChanged(ItemChangeEvent event) {

                          FacesContext

                                              .getCurrentInstance()

                                              .getExternalContext()

                                              .log("YTabPanelBean.activeItemChanged: \n\t" + event.getOldItemName()

                                                                  + " ---> " + event.getNewItemName());

                          setSelectedTab(event.getNewItemName());

                }

      }

      {code}

       

      The error can be created following this

      One of the tabs is selected

      then I resize the column width of the displayed table

      then I switch to the other tab

      then I resize the column of the new table

      and see an NullPointerException thrown in SortingFilteringRowsRenderer.updateAttribute(). However when refreshing the page after switching tabs no exception is thrown.

       

      Is there something wrong with my code?

       

      updateAttribute() is called from ExtendedDataTableRenderer.updateWidthOfColumns(). When I observe this method I can see that 'widthEntry' carries an id. I inspected the ids in both cases, when the application is running without showing an error (i.e. with refreshing) in comparison to the other case with error and found that there must be the problem.

      In case the exception will be thrown its still the id that corresponds to the previously selected tab.

       

      Do I have to change something or is it richfaces? Any suggestion?

        • 1. Re: Preserving extendeddatatable nested in tabpanel
          mcmurdosound

          It's reproducible:

          Schwerwiegend: The log message is null.

          java.lang.NullPointerException

              at org.richfaces.renderkit.SortingFilteringRowsRenderer.updateAttribute(SortingFilteringRowsRenderer.java:135)

              at org.richfaces.renderkit.ExtendedDataTableRenderer.updateWidthOfColumns(ExtendedDataTableRenderer.java:831)

              at org.richfaces.renderkit.ExtendedDataTableRenderer.doDecode(ExtendedDataTableRenderer.java:814)

              at org.richfaces.renderkit.RendererBase.decode(RendererBase.java:80)

              at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:787)

              at org.richfaces.component.UIDataAdaptor.processDecodes(UIDataAdaptor.java:823)

              at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176)

              at org.richfaces.component.AbstractTogglePanel.processDecodes(AbstractTogglePanel.java:206)

              at org.richfaces.context.PartialViewExecuteVisitCallback.visit(PartialViewExecuteVisitCallback.java:53)

              at org.richfaces.context.BaseExtendedVisitContext.invokeVisitCallback(BaseExtendedVisitContext.java:321)

              at org.richfaces.component.AbstractTogglePanel.visitTree(AbstractTogglePanel.java:693)

              at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)

              at javax.faces.component.UIForm.visitTree(UIForm.java:344)

              at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)

              at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)

              at org.richfaces.context.ExtendedPartialViewContextImpl.executeComponents(ExtendedPartialViewContextImpl.java:237)

              at org.richfaces.context.ExtendedPartialViewContextImpl.processPartialExecutePhase(ExtendedPartialViewContextImpl.java:217)

              at org.richfaces.context.ExtendedPartialViewContextImpl.processPartial(ExtendedPartialViewContextImpl.java:196)

              at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:931)

              at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)

              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

              at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

              at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)

              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)

              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

              at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)

              at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)

              at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)

              at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)

              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)

              at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)

              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)

              at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)

              at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)

              at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)

              at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)

              at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)

              at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)

              at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)

              at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)

              at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)

              at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)

              at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)

              at com.sun.grizzly.ContextTask.run(ContextTask.java:71)

              at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)

              at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)

              at java.lang.Thread.run(Thread.java:722)

           

          Richfaces: 4.1.0.20111014-M3

           

          I'll try the latest snapshot....

          • 2. Re: Preserving extendeddatatable nested in tabpanel
            mcmurdosound

            No, it's the same with the current Snapshot. Even setting sortBy and sortOrder for each column does not help. Strangely enough, selecting an entry in each table seems to help for one or two tabswitches, but then the error will occur again.

             

            You could set a breakpoint into SortingFilteringRowsRenderer.java (line 135) or follow the call hierarchy:

             

            https://github.com/richfaces/components/blob/develop/iteration/ui/src/main/java/org/richfaces/renderkit/SortingFilteringRowsRenderer.java

             

            protected void updateAttribute(FacesContext context, UIComponent component, String attribute, Object value) {

            line 135-->        Object oldValue = component.getAttributes().get(attribute); <-- Line 135

                    if ((oldValue != null && !oldValue.equals(value)) || (oldValue == null && value != null)) {

                        ELContext elContext = context.getELContext();

             

            component could be null.

            • 3. Re: Preserving extendeddatatable nested in tabpanel
              rednose

              Now I looked up the POST-request using firebug. After resizing the column I can find an integer succeeded by 'px' there. The next id preceeding this width is the id that is shown in 'widthEntry' in the method 'updateWidthOfColumns()'.

               

              So when selecting an entry in each tables seems to help I guess that an variable update on the client happens too late.

              • 4. Re: Preserving extendeddatatable nested in tabpanel
                mcmurdosound

                I've tried again but it seems that even two tables on one page are causing the same trouble.

                • 5. Re: Preserving extendeddatatable nested in tabpanel
                  rednose

                  I guess that the problems are caused by the same bug as described in discussion 'frozenColumns does not work when there are more than one extendedDataTable in the page'.