Forum Stats

  • 3,874,172 Users
  • 2,266,677 Discussions
  • 7,911,753 Comments

Discussions

How to update other rows if user create new row and commit.

User_CYBIF
User_CYBIF Member Posts: 5 Red Ribbon

I am new to ADF and completely clueless on this .

Use case - In a table there is a end_date column and when user create a new row then I want to end date all other rows which has end_date = null. Can we achieve this in doDML method of EOImpl. If yes, how?

Any help would be appreciated.

JDev Version 12.2.1.0.0

Tagged:

Answers

  • User_CYBIF
    User_CYBIF Member Posts: 5 Red Ribbon

    I got this.

    I get the vo instance in doDML method of the EOImpl using below.

      protected void doDML(int i, TransactionEvent transactionEvent) {

        // TODO Implement this method

        System.out.println("In doDML");

         

        if(i == DML_INSERT){

          System.out.println("In doDML -- DML_INSERT");

          ViewObjectImpl vo = (ViewObjectImpl)this.getDBTransaction().getRootApplicationModule().findViewObject("TableVO");

           

          if(vo != null){

            System.out.println("In doDML -- vo is not null");

            ViewCriteriaManager vcm = vo.getViewCriteriaManager();

            ViewCriteria vc = vcm.getViewCriteria("findByBrandName");

            VariableValueManager vm = vo.ensureVariableManager();

            vm.setVariableValue("b_brandName", this.getBrandName());

            RowIterator ri = vo.findByViewCriteria(vc, -1, ViewObject.QUERY_MODE_SCAN_DATABASE_TABLES);

            Row r = null;

            if(ri !=null){

              System.out.println("In doDML -- ri is not null");

              while(ri.hasNext()){

                r = ri.next();

                if(this.getBrandId() != r.getAttribute("BrandId")){

                  System.out.println("In doDML -- "+ r.getAttribute("BrandId"));

                  System.out.println("In doDML -- "+ r.getAttribute("BrandName"));

                  System.out.println("In doDML -- "+ r.getAttribute("StartDate"));

                  System.out.println("In doDML -- "+ r.getAttribute("EndDate"));

                  r.setAttribute("EndDate", this.getStartDate());

                }

              }

            }

            vo.executeQuery(); // this will refresh the vo and reflect the data on UI

          }

           

        }

         

        System.out.println("Out doDML");

        super.doDML(i, transactionEvent);

      }


    This may help other if they want to achieve the same.

  • dvohra21
    dvohra21 Member Posts: 14,691 Gold Crown

    Use partialTriggers to update related components.

    partialTriggersString[]Yesthe IDs of the components that should trigger a partial update. This component will listen on the trigger components. If one of the trigger components receives an event that will cause it to update in some way, this component will request to be updated too. Identifiers are relative to the source component (this component), and must account for NamingContainers. If your component is already inside of a naming container, you can use a single colon to start the search from the root of the page, or multiple colons to move up through the NamingContainers - "::" will pop out of the component's naming container (or itself if the component is a naming container) and begin the search from there, ":::" will pop out of two naming containers (including itself if the component is a naming container) and begin the search from there, etc.