4 Replies Latest reply on May 5, 2011 11:49 AM by 522560

    ADF: Passivation/activation of sorted transient view object fails.

      1. I have a transient view object that contains the following transient attribute and data types:

      Integer Id
      Number var2
      Number var3
      Number var4
      Number var5
      Number var6
      Date var7
      Number var8
      Number var9
      Boolean var10
      String var11
      String var12
      String var13
      Number var14
      Number var15
      Date var16
      Boolean var17

      Notes Regarding view object above:
      . The view object is not based on an entity object.
      . all attributes are transient.
      . all attributes are updateable.
      . The first attribute Id, is configured as a key and I ensure uniqueness, which avoids exceptions on passivation.
      . The view object contains no SQL statement.
      . Important values from the tuning panel
      . Retrive Rows from DB is configure to "No Rows (used for inserting new rows)"
      . Passivate State is enabled (checkmark)
      . Including Transient Attributes is enabled (checkmark)

      2. In a backing been I have code that inserts rows into the view object and then sorts the rows in memory.

      ViewObject CartView;
      Row CartRow;

      for (Key k: (Set<Key>)myTableKeySet) {

      // create new row.
      CartRow = CartView.createRow();

      // set values for all attributes in my Row, not all shown here
      CartRow.setAttribute("Id", myId);
      CartRow.setAttribute("var1", someValue); etc....

      // Insert the row.


      // once all rows have been inserted, sorty them in memory.
      adCartView.setSortBy("Name, Var1");

      3. When I have configured my application module to use an application module pools all the code above works fine.

      . View object contains correct data
      . Data has been sorted as I expect.
      . JSP page that uses view object looks great.

      The Problem:

      When I configure the application module to not use a pool (force passivation) my view object contains no rows after activation.

      . Select configuration on application module and make sure Enable Application Module Pooling is not checked.
      . Run the project and go to my JSP, data related to this view object is not shown on the page.
      . I debug and it looks like the view contains no rows.

      Key Points from Debugging:

      1. If I remove the following lines from the above code (sort view object) activation works fine and JSP has all data.

      adCartView.setSortBy("Name, Var1");

      2. I add the above sort code back in and try to figure out how they break passivation and activation.

      I overloaded all passivate and activate functions in my view object to get an idea if passivation and activation works.
      I overloaded all of them, including deprecated ones. The most important I think were passivateState() activateState()

      One thing that concerned me the most was in the passivateState() function I could see the viewObject contained
      the correct query mode, which is ViewObject.QUERY_MODE_SCAN_VIEW_ROWS. However, in the activateState() function
      I noticed that the query mode is the defaut again, which is ViewObject.QUERY_MODE_SCAN_DATABASE_TABLES.

      Excellent, I thought the query mode was the cause of my problem, so in the function activeState()
      I set the query mode in my view object to this.setQueryMode(ViewObject.QUERY_MODE_SCAN_VIEW_ROWS); and then
      I call super.activateState(), but still this did not work.

      I should mention that I did not passivate the queryMode in passivateState(), this also could have been an option
      and then grab that queryMode back from the passivated data and set it in the view object in activateState.
      I have had to do this type of thing (passivate/activate) with a view object's RowMatch criteria and that worked fine.
      I figured there is no need to passivate since I can code the setting to the correct query mode in activateState(),
      which seems correct to me.

      I have tried many different things to get this to work, I don't want to list all as I am getting long winded here.

      So my questions are:

      1. Is it possible to passivate and activate in memory sorted transient view object?

      2. If so, where I am going wrong?

      I have been debugging this problem for many days, so any help is greatly apprecitated.