1 2 Previous Next 16 Replies Latest reply on Apr 9, 2010 4:04 AM by ilya_shaikovsky

    rich:listShuttle causes exception

    zjda

      Hi, I have a rich:listShuttle in a rich:modalPanel:

      <rich:listShuttle id="childrenListShuttle" sourceValue="#{childrenTable.unselectedPropertyBeans}"
       targetValue="#{childrenTable.selectedPropertyBeans}" var="prop" listHeight="300"
       sourceListWidth="200" targetListWidth="200" sourceCaptionLabel="Available Properties"
       targetCaptionLabel="Selected Properties" converter="propertyDefinitionBeanConverter">
       <rich:column style="text-align: left;">
       <f:facet name="header">
       <h:outputText value="Namespace" />
       </f:facet>
       <h:outputText value="#{prop.namespace}"></h:outputText>
       </rich:column>
       <rich:column style="text-align: left;">
       <f:facet name="header">
       <h:outputText value="Name" />
       </f:facet>
       <h:outputText value="#{prop.name}"></h:outputText>
       </rich:column>
      </rich:listShuttle>
      


      It works fine until I change the skin:

      <rich:menuItem submitMode="server">
       <h:commandLink value="Wine" immediate="true">
       <a4j:actionparam name="skin" value="wine" assignTo="#{sessionInfo.skin}" />
       </h:commandLink>
      </rich:menuItem>
      


      It throws an exception:


      java.lang.NullPointerException
      at org.richfaces.renderkit.ListShuttleRendererBase.encodeOneRow(ListShuttleRendererBase.java:158)
      at org.richfaces.renderkit.AbstractRowsRenderer.process(AbstractRowsRenderer.java:83)
      at org.richfaces.model.ListShuttleDataModel$1.process(ListShuttleDataModel.java:84)
      at org.ajax4jsf.model.SequenceDataModel.walk(SequenceDataModel.java:101)
      at org.richfaces.model.ListShuttleDataModel.walk(ListShuttleDataModel.java:78)
      at org.ajax4jsf.component.UIDataAdaptor.walk(UIDataAdaptor.java:1133)
      at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:104)
      at org.richfaces.renderkit.ListShuttleRendererBase.encodeRows(ListShuttleRendererBase.java:116)
      at org.richfaces.renderkit.html.ListShuttleRenderer.doEncodeChildren(ListShuttleRenderer.java:254)
      at org.richfaces.renderkit.html.ListShuttleRenderer.doEncodeChildren(ListShuttleRenderer.java:244)
      at org.richfaces.renderkit.ListShuttleRendererBase.encodeChildren(ListShuttleRendererBase.java:245)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
      at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
      at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
      at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:200)
      at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:195)
      at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
      at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
      at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
      at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:279)
      at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
      at org.richfaces.renderkit.html.ModalPanelRenderer.doEncodeChildren(ModalPanelRenderer.java:368)
      at org.richfaces.renderkit.html.ModalPanelRenderer.doEncodeChildren(ModalPanelRenderer.java:363)
      at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
      at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
      at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
      at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:530)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
      at java.lang.Thread.run(Thread.java:619)


      Is something wrong with my code or is it a bug in Richfaces?

      Thanks,
      -ZJ

        • 1. Re: rich:listShuttle causes exception
          nbelaevski

          Hi ZJ,

          Code looks ok, can you please provide info about RF version?

          • 2. Re: rich:listShuttle causes exception
            zjda

            Hi Nick,

            I have tried 3.3.1GA and 3.3.2GA and the problem occurs on both of them. The problem is not 100% reproducible. If I change skin 10 times, it may throw the exception 8 or 9 times. Sometimes the ui displays HTTP 500 error when it throws the exception, but it will display the page correctly after clicking the browser Refresh button.

            Thank you for looking at the issue.

            -ZJ

            • 3. Re: rich:listShuttle causes exception
              ilya_shaikovsky

              please change

              <rich:menuItem submitMode="server">
               <h:commandLink value="Wine" immediate="true">
               <a4j:actionparam name="skin" value="wine" assignTo="#{sessionInfo.skin}" />
               </h:commandLink>
              </rich:menuItem>
              


              with
              <rich:menuItem submitMode="none">
               <h:commandLink value="Wine" immediate="true">
               <a4j:actionparam name="skin" value="wine" assignTo="#{sessionInfo.skin}" />
               </h:commandLink>
              </rich:menuItem>
              

              or just
              <rich:menuItem submitMode="server" value="Wine" immediate="true">
               <a4j:actionparam name="skin" value="wine" assignTo="#{sessionInfo.skin}" />
              </rich:menuItem>
              


              • 4. Re: rich:listShuttle causes exception
                zjda

                Hi Ilya,

                I tried your both solutions and either of them would be able to resolve the issue.

                Thanks,
                -ZJ

                • 5. Re: rich:listShuttle causes exception
                  ilya_shaikovsky

                  could you please create simple war sample for me?

                  • 6. Re: rich:listShuttle causes exception
                    ilya_shaikovsky

                    oops.. thought that you not resolved the problem :)

                    • 7. Re: rich:listShuttle causes exception
                      zjda

                      Hi Ilya,

                      Do you mean that you have found the cause of the issue and a solution to it? It will take me a pretty long time to create a simple war file since my schema is complicated. But I can zip the related source code and send to you if you need.

                      Interestingly, the problem has never happened again after I used your suggestion.

                      Thanks,
                      -ZJ

                      • 8. Re: rich:listShuttle causes exception
                        ilya_shaikovsky

                        No I meant that I misunderstood your comment from the beginning and thought that the problem is still unsolved. Then understand that it was solved.

                        • 9. Re: rich:listShuttle causes exception

                          I have almost the same problem.

                           

                           

                           

                          I found that this issue is not reproducable for firefox. I check it for ie 6, ie7, opera and didn't check for ie8.

                           

                           

                           

                          In my case the listShuttle located in modalPopup . After popup is shown and then closed  and then container of popup ajax rerendered I get the same exception.

                           

                           

                           

                          I've downloaded sources of richfaces 3.3.3.cr1 and tryed to investigate the problem.

                           

                           

                           

                          I've found that this exception is rise when some how ajax starts two threads. In both of them there is run through the collection of elements. But one of them is started earlier and finish ealier. I supose that after the finish of one thread the collection of attributes is cleared and another thread trys to get attributes wich are empty and there how the NPE rise.

                           

                           

                           

                           

                           

                          One sollution is to not  rerender the container of popup and another is to change code of ListShuttleRendererBase from

                          ComponentVariables variables = ComponentsVariableResolver.getVariables(this, table);
                          SelectionState selectionState = (SelectionState) variables.getVariable(SELECTION_STATE_VAR_NAME);
                          ItemState itemState = getItemState(context, table, variables);

                          boolean active = itemState.isActive();
                          boolean selected = itemState.isSelected();
                          selectionState.addState(selected);

                           

                           

                          to

                           

                           

                          ComponentVariables variables = ComponentsVariableResolver.getVariables(this, table);
                          SelectionState selectionState = (SelectionState) variables.getVariable(SELECTION_STATE_VAR_NAME);
                          ItemState itemState = getItemState(context, table, variables);

                          boolean active = (itemState == null) ? false : itemState.isActive();
                          boolean selected = (itemState == null) ? false : itemState.isSelected();
                          if( selectionState != null ) selectionState.addState(selected);

                          • 10. Re: rich:listShuttle causes exception

                            Anyway I need a response from richfaces developers.

                            Because changing of standart libraries is not so god way to solve the problems.

                            • 11. Re: rich:listShuttle causes exception
                              ilya_shaikovsky

                              I think you should investigate that

                              I've found that this exception is rise when some how ajax starts two threads.

                              from the beggining.

                               

                              Show your code.

                              • 12. Re: rich:listShuttle causes exception

                                <h:dataTable id="expTypeAllocationTable"
                                value="#{invoiceAllocationMethod.expenseTypeListEditor.expenseTypeEditors}"
                                var="expenseTypeEditor" cellpadding="0" cellspacing="0"
                                style="width: 100%; border: 1px solid #8D8D81;"
                                styleClass="bg-white">
                                ...

                                <td align="right" valign="top"><a4j:commandButton
                                value="Funds selection" id="selectFunds"
                                disabled="#{!sec:isUserHasInvoicePermission('INV_ALLOCATE') or expenseTypeEditor.disabled}"
                                styleClass="butt-small"
                                action="#{invoiceAllocationMethod.expenseTypeListEditor.setCurrentExpenseTypeEditor}"
                                onclick="addOrUpdateDataToForm(this.form, 'expenseCode', '#{expenseTypeEditor.guid}');"
                                oncomplete="openFundSelection();"
                                reRender="fund-selection">
                                <f:param name="expenseCode" value="#{expenseTypeEditor.guid}" />
                                </a4j:commandButton></td>

                                 

                                 

                                ...

                                 

                                <tr>
                                <td align="left" valign="top">
                                <h:inputText
                                id="straightSelection"
                                disabled="#{!sec:isUserHasInvoicePermission('INV_ALLOCATE')
                                or invoiceAllocationMethod.reclassRefundDisable
                                or expenseTypeEditor.readonly
                                or expenseTypeEditor.changeableSurvivedExpense}"
                                styleClass="input-disabled"
                                rendered="#{!expenseTypeEditor.model.allocAmountSelection}"
                                style="width: 150px;"
                                value="#{expenseTypeEditor.methodSelectionEditor.allocationPct.straight}">
                                <f:converter converterId="pctConverter" />
                                </h:inputText>
                                <h:inputText
                                id="straightSelectionAmount"
                                disabled="#{!sec:isUserHasInvoicePermission('INV_ALLOCATE')
                                or invoiceAllocationMethod.reclassRefundDisable
                                or expenseTypeEditor.readonly
                                or expenseTypeEditor.changeableSurvivedExpense}"
                                styleClass="input-disabled"
                                rendered="#{expenseTypeEditor.model.allocAmountSelection}"
                                style="width: 150px;"
                                value="#{expenseTypeEditor.methodSelectionEditor.allocationAmount.straight}">
                                <f:converter converterId="amountConverter" />
                                <a4j:support event="onblur"
                                reRender="expTypeAllocationTable"
                                action="#{expenseTypeEditor.changeAllocationValue}"/>
                                </h:inputText>
                                </td>
                                <td align="left" valign="top">
                                <h:inputText id="NSASelection"
                                disabled="#{!sec:isUserHasInvoicePermission('INV_ALLOCATE')
                                or invoiceAllocationMethod.reclassRefundDisable
                                or expenseTypeEditor.readonly
                                or expenseTypeEditor.changeableSurvivedExpense}"
                                styleClass="input-disabled"
                                rendered="#{!expenseTypeEditor.model.allocAmountSelection}"
                                style="width: 150px;"
                                value="#{expenseTypeEditor.methodSelectionEditor.allocationPct.NSA}">
                                <f:converter converterId="pctConverter" />
                                <a4j:support event="onblur"
                                reRender="expTypeAllocationTable"
                                action="#{expenseTypeEditor.changeAllocationValue}"/>
                                </h:inputText>
                                <h:inputText id="NSASelectionAmount"
                                disabled="#{!sec:isUserHasInvoicePermission('INV_ALLOCATE')
                                or invoiceAllocationMethod.reclassRefundDisable
                                or expenseTypeEditor.readonly
                                or expenseTypeEditor.changeableSurvivedExpense}"
                                styleClass="input-disabled"
                                rendered="#{expenseTypeEditor.model.allocAmountSelection}"
                                style="width: 150px;"
                                value="#{expenseTypeEditor.methodSelectionEditor.allocationAmount.NSA}">
                                <f:converter converterId="amountConverter" />
                                <a4j:support event="onblur"
                                reRender="expTypeAllocationTable"
                                action="#{expenseTypeEditor.changeAllocationValue}"/>
                                </h:inputText>
                                </td>
                                </tr>

                                ...

                                </h:dataTable>

                                • 13. Re: rich:listShuttle causes exception

                                  In my case I shouldn't rerender component on last focus and find some another way to do it.

                                  In common case the main thing why it's happens is that two ajax calls runs one after another in different threads.

                                  It means that UI developers are forced to not do this if they are make UI to rerender listShuttle.

                                  IMHO it's not so good.

                                   

                                  P.S.

                                  I use modal panel to coverup page during axaj calls to prevent multiple calls.

                                  The reason why this bad situation with listShuttle did not happen on firefox is that firefox shows cover before giving focus to anther component as against to IE.

                                  If this cover will not be used the user could click a lot of components and server will be full of such parallel requests so the situation will be much more terrible than this.

                                  And again i want to say that such limitations makes a lot of trubble to ui designers and as the result to end user.

                                   

                                  P.P.S

                                  I don't now why two parallel request have the SAME collection on server to run...

                                  • 14. Re: rich:listShuttle causes exception
                                    ilya_shaikovsky

                                    It means that UI developers are forced to not do this if they are make UI to rerender listShuttle.

                                    IMHO it's not so good.

                                    ...

                                    If this cover will not be used the user could click a lot of components and server will be full of such parallel requests so the situation will be much more terrible than this.

                                    If the developer defined ajax requests to be sent on events like keyup or blur at all the fileds of the forum - he should understand that this will cause server requests flood. It's not about just lit shuttle component, having such concurency you could get different problems in different situations. It's about page-server interactions design. In your situation I think you should read about ajax requests queuing mechanism  in RichFaces and about a4j:queue tag. It should solve all such problems.

                                    1 2 Previous Next