10 Replies Latest reply on Jan 20, 2011 11:41 AM by yyq2009

    Is it a bug or I did something wrong?

    yyq2009

      I hava an input component that has required property and a richfaces panel with a datatable nested in a form. In every row of databable, there is an input component, I want to delete user 7 and I also want the data I typed in  are kept in input components after I deleted the user 7.

      Snap1.gif

      My page:

      <h:form id="mainForm">

                      <h:inputText value="#{testBean.key}" required="true"/>

                      <rich:panel id="panel1" header="User" style="width:270px;">

                          <h:dataTable value="#{testBean.list}" var="u">

                              <h:column>

                                  <f:facet name="header">

                                      <h:outputText value="ID"/>

                                  </f:facet>

                                  <h:outputText value="#{u.id}"/>

                              </h:column>

                             

                                <h:column>

                                  <f:facet name="header">

                                      <h:outputText value="Name"/>

                                  </f:facet>

                                  <h:outputText value="#{u.name}"/>

                              </h:column>

                             

                              <h:column>

                                  <f:facet name="header">

                                      <h:outputText value="Info."/>

                                  </f:facet>

                                  <h:inputText value="#{u.info}"/>

                              </h:column>

                             

                              <h:column>

                                  <f:facet name="header">

                                      <h:outputText value="Operation"/>

                                  </f:facet>

                                  <a4j:commandLink value="Del"

                                                action="#{testBean.deleteUser}"

                                                ajaxSingle="true"

                                                process="panel1"

                                                reRender="panel1"/>

                              </h:column>

                          </h:dataTable>

                      </rich:panel>

                  </h:form>

       

      Managed bean is very simple.

       

      The problem is : after I deleted user 7 in the datatable,  user 8 (row) also deleted at the same time, it is say that the action execute twice when I  deleting the user 7.

      Snap2.gif

      If I removed the property process="panel1" of the a4j:commanLink, user 7 deleted correctly, but the data I typed didn't kept.

      Snap3.gif

      JSF 1.2  RichFaces 3.3 Final

        • 1. Is it a bug or I did something wrong?
          ilya40umov

          As I understood you can't remove ajaxSingle="true" because you don't need all inputs to be submitted. Am I right?

          Could you debug the fist case? May be you can work around this adding some flag into request scope to avoid duplicate deletes.

          • 2. Is it a bug or I did something wrong?
            yyq2009

            Ilya Sorokoumov, thanks for your reply.

             

            You are right, I needn't all inputs to be submitted, at least the input out of the panel needn't. I debuged the first case, I found that, web client just requests  once, at the server side, in JSF life cycle, the action executed twice in some reason.

            Maybe it is a bug of the property "process",  I set id "panel1" to the property "process" of the a4j commandlink ,which is in the rich panel "panel1", that cause the  twice execution.

             

            I can't debug deep for more information.

            • 3. Is it a bug or I did something wrong?
              ilya40umov

              As I said you can try "some flag into request scope to avoid duplicate deletes." as a temporal workaround. And I guess you should wait for the RF developers answer(They know their features better).

              • 4. Is it a bug or I did something wrong?
                ilya_shaikovsky

                Unfortunatelly can't provide simple solution. And the reason is - you do not want to process all the inputs when deleting so set ajaxSingle. But in the same time you want to reRender the whole table (and have no other way to remove the whole row).. So the new table which replaces the old one in DOM contains values from server side (previous one before clicking delete.)... So have two ways - process all the table. Or work at some pure client side update solution(to remove row via oncomplete custom javaScript rather then using our reRender mechanism)

                • 5. Is it a bug or I did something wrong?
                  yyq2009

                  Hi, Ilya Shaikovsky, thanks for your relpy.

                   

                  You say there are two ways to resolve the problem, could you please show me some simple code? Java or javascript code are all better.

                   

                  How can I use customer javascrtip to remove the row? To do that, I have to calculate the id of the rows after the deleted row, because the component tree of jsf had changed and the id of the rows are calculated again, I can do that, but lots of javascript code is not what I expected. Maybe, there is a elegant way.

                   

                  Looking forward  to your  reply.

                  • 6. Is it a bug or I did something wrong?
                    ilya_shaikovsky

                    as I written simplest solution to remove ajaxSingle.. But all the inputs will get validated and perform model updates.

                     

                    I have no prototypes for JS solution and really need time to think on some.. For now too much on the plate with CR and Final release works :/

                    • 7. Is it a bug or I did something wrong?
                      yyq2009

                      OK. Thanks.

                       

                      But I want to know the reason of twice execution in my first case, could you explain it?

                      • 8. Is it a bug or I did something wrong?
                        ilya_shaikovsky

                        could you please check the same with rf dataTable. Does it reproduced also? rf dataTable implemented considering partial process/update features of a4j controls.

                        • 9. Is it a bug or I did something wrong?
                          yyq2009

                          OK. I know the ajaxKeys of rf datatable can do partial update. I'll try it later.

                            Thanks.

                          • 10. Is it a bug or I did something wrong?
                            yyq2009

                            I hava tried the rf datatable, it has the same result as sun jsf datatable and apache myfaces datatable. Twice execution still exists. The ajaxKeys of rf datatable just partial update, but to delete a row from table, I have to rerender the whole table, then my typed data lost, if I process the whole table, the twice execution comes up.

                            Any new ideas?