9 Replies Latest reply: Feb 6, 2013 11:34 PM by thishum RSS

    how to make createinsert when jsf page load

    thishum
      hi all,
      I am using oracle ADF jdeveloper 11g 2 release.

      my jsf page has a form. BUT in first time it loading with data.
      I made when page load (AfterPhase) this code,But it execute on in referesh the page.
      DCBindingContainer bindings =
      (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
      bindings.resetInputState();
      bindings.refreshControl();
      OperationBinding operationBinding =(OperationBinding) bindings.getOperationBinding("CreateInsert");
      Object result = operationBinding.execute();

      In AmImpl class add ;
      ViewObject viewmaster= this.findViewObject("Pcs_ReimbursementVO1");
      Row newRow = viewmaster.createRow();
      newRow.setNewRowState(Row.STATUS_INITIALIZED);
      viewmaster.insertRow(newRow);
      this is only also work when page after refresh.
      in table that will work.. In pagedef I bind createInsert as a action also.
      how to do it form??
      thanks.
        • 1. Re: how to make createinsert when jsf page load
          Koen Verhulst
          Hi thishum,

          you should try using the "invokeAction", available in the executables section of your pageDef.

          Regards,

          Koen Verhulst
          • 2. Re: how to make createinsert when jsf page load
            thishum
            hi Koen,
            no need write coding in backing bean or AmImpl? I now did it binding with createInsert. But no any chance..
            thanks..
            • 3. Re: how to make createinsert when jsf page load
              Frank Nimphius-Oracle
              Hi,

              lets clean up your code first
              DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
              
              // ... useless code ....
              //bindings.resetInputState();
              //bindings.refreshControl();
              
              OperationBinding operationBinding =(OperationBinding) bindings.getOperationBinding("CreateInsert");
              Object result = operationBinding.execute(); 
              Instead of using a phase listener that fires after RENDER_RESPONSE you should use one that fires before RENDER_RESPONSE. If the page is a JSF page (no page fragment) then you can use the f:view beforeMethod property. In the method you reference, check for the lifecycle phase. To avoid the new row to be created on subsequent requests or during partial submits and refreshes, you should set a flag into viewScope (which is active as long as the view is the same). Then in yur before RENDER_RESPONSE listener you check for this flag and if it doesn't exit, call the Operation Binding and create the flag. If the flag exist, don't create a new row

              Frank
              • 4. Re: how to make createinsert when jsf page load
                thishum
                hi franks,
                thanks ur corporation. these are the code that i add for avoid refresh.
                if (phaseEvent.getPhaseId() == PhaseId.RENDER_RESPONSE)
                {
                if (!AdfFacesContext.getCurrentInstance().isPostback())

                now refresh is hold. BUT I select LOV value into text field which is not selected. That is primary key on that VO. LOv is Input Text with List of values one.
                hoping opinion.
                thanks.
                • 5. Re: how to make createinsert when jsf page load
                  Timo Hahn
                  >
                  now refresh is hold. BUT I select LOV value into text field which is not selected. That is primary key on that VO. LOv is Input Text with List of values one.
                  >
                  I don't understand. Can you elaborate on what you are trying to do?


                  Timo
                  • 6. Re: how to make createinsert when jsf page load
                    thishum
                    hi Timo,
                    I am going to create data entering form. when first time load which has entered data. But it is ok according to frank's code. And also ,refresh the page avoid the new row to be created again and again.
                    But in form has LOV, which has newly entered data in some another form entered. so I need to select that one of the record in lov. That LOV indicate field is PK(primary key) on that view object.
                    when I select one record which is not appear.. I dont know what is the reason of it?? But in VO level I changed the assigning value(assigninig text field) another one name. so that value assign on that textfield.

                    many thanks ur corporation.
                    • 7. Re: how to make createinsert when jsf page load
                      Timo Hahn
                      Let me ask yo uanother question: Why don't you use a bounded task flow and put the call to the CreateInsert method before you navigate to the page?
                      This will create the new record only if you navigate to the page via the create insert, but not for the refresh of the page. This should solve the problem as far as I understand it.

                      Timo
                      • 8. Re: how to make createinsert when jsf page load
                        thishum
                        hi timo,
                        thanks ur help. BUT when I changed LOV selection filed(in earlier I said), it will assign that field. Lov selection fild name is jobno and assign field naame also jobno, BUT I newly change assign field name is sequence no . It will assign that value.
                        whatever I made taskflow and call to createinsert method via page. But it will not create new record. is there any changes need??
                        thanks..
                        • 9. Re: how to make createinsert when jsf page load
                          thishum
                          thanks frank,thanks Timo for ur excellent support.
                          I did it frank that u show the path, and also Timo assigning is ok , I make removing the value of Lov assign field value. #{bindings.PcrReimbNo.inputValue} this is in listOfValues value field ,i remove it then now assigning value can see.
                          many thanks both of u.