This discussion is archived
12 Replies Latest reply: Jul 18, 2013 2:30 PM by oraclepro73 RSS

VO refresh after commit not working

oraclepro73 Newbie
Currently Being Moderated

I have a complete Master-Detail functionality ( query, update and create ) implemented.

 

I have created 3 pages for this.

 

SearchPG

UpdatePG

and

CreatePG

 

In the SearchPG I can search for the Master rows and have an update link for every record.

When the user clicks on the link the UpdatePG opens with the Master and Detail VOs and they can edit and save both VOs.

 

On saving, I return to the SearchPG displaying a message.

 

I also have a Create button on the SearchPG to create new records.

On clicking, it opens the CreatePG with both the Master and Detail VOs and the user can create 1 Master and multiple Details records and save the data.

 

On saving, I return to the SearchPG displaying a message.

 

I have a very peculiar issue here.

 

The first time when I create the record and then return to the SearchPG if I try to update any existing records I get a blank page on the UpdatePG.

If I close the screen and reopen it works fine. The new data gets created. There is no problem if I use only Update functionality throughout one session.

 

This is an issue only when I create and then try to update any record.

 

After I create new records, the Search query works fine. It is only the Update not working immediately after create.

 

I use the same VOs. MasterVO and DetailVO for both same Create and Update fucntionality. I thought it might be a caching issue so

I tried to use immediately before the actual update in

 

     vo.reset();

     vo.clearcache();

 

But it is still not having any effect.

 

Any assistance is appreciated.

  • 1. Re: VO refresh after commit not working
    oraclepro73 Newbie
    Currently Being Moderated

    Here is the code I'm using


    UpdatePG CO code:

    ......

    .....

    Serializable[] params = { HeaderID };

    am.invokeMethod("initQuery", params);

     

     

        public void initQuery(String HeaderId) {

     

                     HeadersFullVOImpl vo = (HeadersFullVOImpl) getHeadersFullVO1();

     

     

            int j = 0;

            int z = 0;

           

            if (vo != null) {

              

                 if ((HeaderId != null) &&

                     (!("".equals(HeaderId.trim()))))

                 {

                   // Do the following conversion for type consistency.

                   Number HeaderIdNum = null;

               

                   try

                   {

                     HeaderIdNum = new Number(HeaderId);

                   }

                   catch(Exception e)

                   {

                     throw new OAException("AK", "FWK_TBX_INVALID_EMP_NUMBER");

                   }

                     vo.clearCache();

                     vo.reset();

                     vo.setWhereClauseParams(null);

                     vo.setWhereClause(" HEADER_ID = :1 ");                

                     vo.setWhereClauseParam(0,HeaderIdNum);

                     System.out.println(vo.getQuery());

                     vo.executeQuery();    

                     System.out.println("AFTER"); // for debug

                     System.out.println(vo.getQuery());

                    

                    

                     j = vo.getRowCount();

                     z = vo.getFetchedRowCount();

                    

                    

                 }

     

    I tried to debug and the values for j and z are setting to 1 when I using Update alone.

     

    For the sequence 1) Create 2) Update it is always 0.

  • 2. Re: VO refresh after commit not working
    oraclepro73 Newbie
    Currently Being Moderated

    Does anyone have any idea on this?

     

    I have tried all sorts of changes and debugging. Couldn't figure it out.

     

    Thanks

  • 3. Re: VO refresh after commit not working
    Sandeep Oracle Explorer
    Currently Being Moderated

    I believe when you are creating the row, its not actually getting saved . Hence when you are querying its showing the value as zero.  Could you please paste in your code here , so can pass our inputs .Please try to commit the trasaction

     

    public String commit() {

        try {

      XxEmployeeVOImpl employeeVO = getXxEmployeeVO1();

      XxEmployeeVORowImpl row = (XxEmployeeVORowImpl)employeeVO.first();

      String savedEmp = row.getEmpno().toString();

      getOADBTransaction().commit();

      return savedEmp;

      } catch (Exception e) {

       e.printStackTrace();

       }



  • 4. Re: VO refresh after commit not working
    oraclepro73 Newbie
    Currently Being Moderated

    I'm not sure how it would not save the data.

     

    As soon as I click on Create the CreatePG opens and when I click the Apply button on this page I do the usual call to am.invokeMethod("apply") and then commit over there.

     

    Once this is done I do a forward to the SearchPG.

     

    I can query the data which I just created. There is no issue with the data.

     

    It is just I cannot open any record in Update mode ( calling UpdatePG from the update link in the SearchPG )

     

    I think there is problem with the Master and Detail VO since I use same VOs for both Create and Update functionality.

     

    I will add the given code and check if the data is returned.

     

    Thanks

  • 5. Re: VO refresh after commit not working
    oraclepro73 Newbie
    Currently Being Moderated

    I tried adding your code to the commit part and I don;t see any issues there.

     

    I'm able to see the data when I encounter the line

         String savedEmp = row.getEmpno().toString();

     

    Also as soon as I do

        getOADBTransaction().commit();


    I can see the data in the table.


    I've already pasted the code for the Controller processRequest of UpdatePG and

    also the AM method initQuery

  • 6. Re: VO refresh after commit not working
    Jeet_A Journeyer
    Currently Being Moderated

    Hi,

     

    Can you write

     

    executeQuery();  inside afterCommit() method of VoImpl and see ? 

     

     

    Thanks,

    Jeet

  • 7. Re: VO refresh after commit not working
    oraclepro73 Newbie
    Currently Being Moderated

    I added the below code in the custome VOImpl but it is not executing.......    

     

    I set a debug point but it not stopping here.......

     

     

        public void afterCommit() {

       

            //Number rateHeaderIdNum = 1;

       

            setWhereClauseParams(null);

            setWhereClause(" HEADER_ID = 295363 ");                

     

            if ( isPreparedForExecution() ) {

                executeQuery();        

               

                int j = 0;

                int z = 0;

               

                j = getRowCount();

                z = getFetchedRowCount();

               

                Number k = null;

               

               

            }

        }

  • 8. Re: VO refresh after commit not working
    oraclepro73 Newbie
    Currently Being Moderated

    I also noticed that the below sequence works fine.

         Update record

         Create record

         Update record

     

     

    It is only the sequence 

          Create record

          Update record (opens a blank page..... executeQuery() does not work..... 

    does not work ... at all.

     

    I also tried to add  )

    setAssociationConsistent(true); // in the VOImpl create method

     

    but this did not change anything

  • 9. Re: VO refresh after commit not working
    Swati Explorer
    Currently Being Moderated

    Hi,

     

    have you used any session parameters while navigating between the pages?

    Please make sure on Search Page load Removing/Reseting the parameters as well as reseting whenever require.

     

    For your current issue can you please make following change in your page redirection:

    "retainAM to N" while page redirection from createPage and UpdatePage.

     

    Swati

  • 10. Re: VO refresh after commit not working
    oraclepro73 Newbie
    Currently Being Moderated

    I'm using pageContext.putTransactionValue and pageContext.getTransactionValue in the UpdatePG controller to get the passed field names from SearchPG and after update passing back to the Search PG to pop up a message.

     

    >>>>>>> Please make sure on Search Page load Removing/Reseting the parameters as well as reseting whenever require.

    Is this an option in the PG properties? Where do I change this?


    I'm using the same AM as RootAM for all 3 pages. Not sure why I need to change this.

    I will  try and see if that helps.

  • 11. Re: VO refresh after commit not working
    Swati Explorer
    Currently Being Moderated


    Hi,

     

    As per my understanding, If you are using TransactionValue then retainAM=N may lost your values on navigation.

    Suggestion: Instead of this you can pass hashmap parameter value with setForwardURL method(retainAM=N)

    using pageContext.putTransactionValue and pageContext.getTransactionValue

     

    Suggested you to reset the parameters as I have faced such issue in past with session parameters, they were holding the previous value so need to remove the created parameter.

    >>>>>>> Please make sure on Search Page load Removing/Reseting the parameters as well as reseting whenever require.

    Is this an option in the PG properties? Where do I change this?

     

    There is no property for your custom defined parameter values reset. you have to write code

    Ex: pageContext.putSessionValue("customparam","-1"); and pageContext.removeSessionValue("customparam") ;

     

    Hope this helps

    Swati

  • 12. Re: VO refresh after commit not working
    oraclepro73 Newbie
    Currently Being Moderated

    It is working fine now after changing the RetainAM to false in setForwardURL from CreatePG to SearchPG.

     

    I also changed it from UpdatePG to SearchPG. (Though this is not required)

     

    But I also had to add    vo.getRowCount()  after vo.executeQuery in UpdatePG Co.

     

    Thanks a lot for your assistance.

     

    I don't get why you need to put RetainAM to N as all the 3 pages are using same transaction. Also this was not working only for 1 sequence of steps.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points