9 Replies Latest reply: May 20, 2013 9:37 AM by Jan Vervecken RSS

    Why sum field in master VO didnot change when a new row add in detail VO?

    BAO.SZ
      hi,experts.
      In adf-inside-essential, i get to know a declaretive way to implement total for a master form from a detail table, see:
      http://download.oracle.com/otn_hosted_doc/jdeveloper/11gdemos/ADF_Insider_Essentials/ImplementingTotals/ImplementingTotals.html,
      and it works for me: whenever i change the number value on detailed table and leave the field, the caculated total value in the master form will be changed.

      but this doesnot work when a new record was added to the detail table and edit the number field. --it doesnot work even after submit the newly added record.

      Edited by: BAO.SZ on 2013-4-26 上午11:40
      =============
      Some detail:
      Sum field in master VO1: CalAmount, which is a transient attribute, with default value set to (expression):
      VO2.sum("(Amount == null) ? 0:Amount"),
      where Amount is the number attribute in detailed VO2.

      It works when change the VO2.Amount and leave this field on page.
      But it didnot work(CalAmount didnot change) when a new row was added to VO2 and Amount has new value.

      Anyone can help?
      Thanks.

      Edited by: BAO.SZ on 2013-5-12 上午4:28
        • 1. Re: Why sum field in master VO didnot change when a new row add in detail VO?
          Jan Vervecken
          hi 'BAO.SZ'

          Using JDeveloper 11.1.2.3.0 I have tried to implement what is being described in the ADF Insider Essentials recording on "Implementing a total"
          at http://download.oracle.com/otn_hosted_doc/jdeveloper/11gdemos/ADF_Insider_Essentials/ImplementingTotals/ImplementingTotals.html
          in the example application
          at http://www.consideringred.com/files/oracle/2013/Thread2529569ImplementingTotalsApp-v0.01.zip

          For a new row, I seem to be able to reproduce the behaviour you describe,
          see the screencast at http://screencast.com/t/Uw13l1jif

          As DeDe Morton is the name mentioned at the beginning of the ADF Insider Essentials recording maybe someone can contact her and point her to your question in this forum thread.

          regards
          Jan Vervecken
          • 2. Re: Why sum field in master VO didnot change when a new row add in detail VO?
            Jeet_A
            Hi,

            Are you able to see the updated Salary for newly inserted record after committing the new record into database ?

            Thanks,
            Jit
            • 3. Re: Why sum field in master VO didnot change when a new row add in detail VO?
              BAO.SZ
              Hi,Jan and appsjit

              In my example, after I create a new row for detail VO2, the calculated sum field in VO1 didnot change, and when i go to anther row to edit the "old row" value and leave that field, then the calculated sum will be changed include take account the newly added row's value. (as showed in Jan's video)

              and I commit data which is success, and the rows' values showed OK.

              Then I edit the value VO2.Amount of the newly added row, the calculated sum didnot change yet. (*Can Jan make a test in your example for this point?*)
              and I commit again, an error message was popup, saying:
              +"Cannot find row in VO2 with keywords oracle.jbo.Key[null AAAFh7AAEAAACZaAAC ]"+
              where AAAFh7AAEAAACZaAAC is the rowid of the newly added row which has commited to database.
              (Besides VO2.rowid, there is another Primary key field in VO2.id which is populated by a database trigger from sequence).

              and I rollback data, the page showed all rows include the newly added row before the latest edition.

              I think maybe an possible cause for the above issue is:
              Because there is another primary key VO2.id which is populated by a database trigger from sequence, when I commit data, the value of VO2.id has created but not showed in page. Then when I begin to edit this newly added row, jdev cannot find VO2.id-- then cannot calculated sum and cannot commit again?

              The key issue is when rows are newly added or deleted, the calculated sum cannot change accordingly.

              I donot know how to fix it and donot know if my thinking is right? Can Jan make further try on your example?
              or someone else can give any help?

              Thanks
              BAO

              Edited by: BAO.SZ on 2013-5-12 下午8:16
              • 4. Re: Why sum field in master VO didnot change when a new row add in detail VO?
                Jan Vervecken
                hi BAO.SZ
                BAO.SZ wrote:
                ... Can Jan make further try on your example? ...
                Currently not.
                Maybe someone can point DeDe Morton to this forum thread, so maybe she can give some suggestions.

                regards
                Jan
                • 5. Re: Why sum field in master VO didnot change when a new row add in detail VO?
                  Frank Nimphius-Oracle
                  Hi,

                  have you tried a PartialTrigger property reference between the total salary field and the table Id? Note that when you create a new row, the row is added (submitted) when you change the row currency and not when the autosubmit of the Salary field is called. Autosubmit follows a partial event root, which means that the autosubmit of the Salary field does not submit the new row (though it triggers the dependent total salary field in the departments, which however sums salary for the existing rows)

                  This actually worked for me using JDeveloper 11.1.1.7

                  Frank
                  • 6. Re: Why sum field in master VO didnot change when a new row add in detail VO?
                    BAO.SZ
                    Hi, Frank

                    After tried your guidance as (in jdev 11.2.3):
                    --set autosubmit property to true for VO2.amount.
                    --set PartialTrigger property of VO1.CalAmount to VO2.tableid.

                    but the results is strange:
                    sometime, it works;
                    sometime, it didnot work:
                    --when i add more than one rows, from the second on, the sum field didnot change;
                    --sum field didnot change when delete rows.
                    --popup an error msg:"Cannot find row in VO2 with keywords oracle.jbo.Key[null AAAFh7AAEAAACZaAAC ]"

                    Any ideas?
                    Thanks.
                    • 7. Re: Why sum field in master VO didnot change when a new row add in detail VO?
                      BAO.SZ
                      Hi, Jan,

                      For the issue of "sum field in master VO didnot change when a new row added in detail VO", now i have found some clues:

                      There is a primary key for (in my example) this VO, which will be populated with value from a sequence by a database trigger, but will not show on the page until commit the data.
                      So, when i press the button to create new row, the PK field is still blank, and cannot trigger the calculating sum process.(?)
                      After i use another way to create the PK (not by database trigger, but by a groovy expression, see: How to show the primary key created by sequence before commit? ),
                      now for every press of createwithparas button in detail table, the calculated sum field in master table will be changed.

                      But i'm not sure if it's the real cause of the issue, and if it works for your example (in your sample's demo video, i see you have enter the value for the emp-id column of the detail table, is that a PK column?)

                      Thanks.
                      BAO
                      • 8. Re: Why sum field in master VO didnot change when a new row add in detail VO?
                        BAO.SZ
                        The reason for "sum field didnot change when delete rows." is that:
                        The delete button should be in the list of the detailed adf table's PartialProperty.

                        Thanks.
                        • 9. Re: Why sum field in master VO didnot change when a new row add in detail VO?
                          Jan Vervecken
                          hi BAO
                          BAO.SZ wrote:
                          ... the PK field is still blank, and cannot trigger the calculating sum process.(?) ...
                          Trying to use Entity Object attribute type DBSequence I ran into some strange behaviour, see also JIRA issue ADFEMG-132 , "difference when configuring type DBSequence during wizard or afterwards",
                          at https://java.net/jira/browse/ADFEMG-132
                          ... (in your sample's demo video, i see you have enter the value for the emp-id column of the detail table, is that a PK column?) ...
                          You can check in the source code of the application I used, which I referred to before
                          at http://www.consideringred.com/files/oracle/2013/Thread2529569ImplementingTotalsApp-v0.01.zip

                          regards
                          Jan