2 Replies Latest reply: Jan 23, 2013 4:33 AM by 986337 RSS

    setAttribute issue in extended controller

    986337
      Dears,

      It is my first thread here, so thank you for your patients when I will do something wrong :)

      My case is like below:
      1. On one page I extenede controller to obtain value from VO and pass it via pageContext.putSessionValue...
      2. On second page I extended controller to read previously passed value via session and set this value to VO attribute using below code:

      public void processRequest(OAPageContext pageContext, OAWebBean webBean)
      {
      super.processRequest(pageContext, webBean);

      String PartyName = pageContext.getSessionValue("xxPartyName").toString();
      pageContext.writeDiagnostics(this, "xxHzPuiAddressCreateUpdateCO - session PartName: " + PartyName, 1);

      OAApplicationModule am1 = pageContext.getApplicationModule(webBean);
      OAApplicationModule am2 = (OAApplicationModule)am1.findApplicationModule("HzPuiAddressAM");
      OAViewObject empVo = (OAViewObject)am2.findViewObject("HzPuiLocationVO");

      pageContext.writeDiagnostics(this, "xxHzPuiAddressCreateUpdateCO - getValue: " + empVo.first().getAttribute("Address4"), 1); // return null
      pageContext.writeDiagnostics(this, "xxHzPuiAddressCreateUpdateCO - RowCount(): " + empVo.getRowCount(), 1); // return 1

      empVo.getCurrentRow().setAttribute("Address4",PartyName);

      pageContext.writeDiagnostics(this, "xxHzPuiAddressCreateUpdateCO - getValue po Set: " + empVo.getCurrentRow().getAttribute("Address4"), 1);

      pageContext.writeDiagnostics(this, "xxHzPuiAddressCreateUpdateCO - getValue po ExecuteQuery: " + empVo.getCurrentRow().getAttribute("Address4"), 1); // return desired value

      }

      The issue:
      When I go to the page where I set attribute to the value it is not visible immediately. Why? I have to refresh the page and then it is visible. The page contains root AM with one VO and then under this I have HzPuiAddressAM and HzPuiLocationVO.

      What is more the page is construct like below:
      1. User is inserting cliking to add new site - page "New site" is loaded
      2. Then user click "Add address" button on "New site" page - my extended controller is loaded and "Address4" attribute is null even that I set the value (in logs file I see that the value is set properly)
      3. After refreshing the page from browser "New site" is again loaded and after I click on "Add address" the value in "Address4" attribute is not null what is desirable result.

      Thanks for any help.

      Rgds,
      Marcin