11 Replies Latest reply: Dec 29, 2009 6:36 AM by 731982 RSS

    How to create multiple new rows in ADF Table?

    724776
      Hello,

      being new to ADF Faces/BC I managed to display data in an ADF Table and create new entries using the "CreateInsert" operation (one at a time).

      Now, the next task is to create multiple new rows at the same time, set some default values and display the new rows in the ADF table. Then the user will enter additional data and commit the new rows.

      Where do I step in? In the EntitiyImpl? Can this be handled declaratively or do I have to implement custom method(s) in the AM?

      Thanks
      Gerald
        • 1. Re: How to create multiple new rows in ADF Table?
          BranislavNemec
          Hi Gerald,

          you can do it programatically in managed bean. so insert commandButton on the page and set actionListener like:
                  <af:commandButton text="commandButton 1" id="cb1"
                                    actionListener="#{myBB.createMultiRows}"/>
          and code in managed bean can be like:
              public void createMultiRows(ActionEvent actionEvent) {
                  DCBindingContainer dc = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
                  DCIteratorBinding iter = dc.findIteratorBinding("DeptView1Iterator");
                  ViewObject vo = iter.getViewObject();
                  for (int i=1; i<=5; i++) {
                    Row newRow = vo.createRow();
                    newRow.setAttribute("Deptno", i);
                  }
                  ApplicationModule am = vo.getApplicationModule();
                  am.getTransaction().commit();
                  vo.executeQuery();
               }
          this method will add 5 new rows and set column DEPTNO. and also commits the transaction

          regards,

          Branislav
          • 2. Re: How to create multiple new rows in ADF Table?
            731982
            how can i accomplish the same in 10g..


            The following lines are showing an error:

            public void createMultiRows(ActionEvent actionEvent) {

            DCBindingContainer dc = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();+
            DCIteratorBinding iter = dc.findIteratorBinding("DeptView1Iterator");
            ViewObject vo = iter.getViewObject();
            for (int i=1; i<=5; i++) {
            Row newRow = vo.createRow();
            newRow.setAttribute("Deptno", i);*

            }
            ApplicationModule am = vo.getApplicationModule();
            am.getTransaction().commit();
            vo.executeQuery();
            }

            i think some library might be missing or some problem like that..

            I am using JDev 10.1.3.4

            thanks,
            Shri
            • 3. Re: How to create multiple new rows in ADF Table?
              Neeraj Sehgal
              Hi Shri,

              Try this for 10g.

              DCBindingContainer dc = (DCBindingContainer) FacesContext.getCurrentInstance().getApplication().createValueBinding("#{bindings}");

              Regards,
              Neeraj
              • 4. Re: How to create multiple new rows in ADF Table?
                731982
                Hi Neeraj,

                Thanks for the solution.

                Actually ;
                I am new to JDev

                I am working on ADFBC trying to insert values into database.

                I am able to insert values into database in built components from component pallette; like create, commit etc.



                If i want to hv a custom method , eg create/commit only certain attributes of the table eg (only empname, email id among other fields), how do i do it.
                (this is b'coz i have one form where emp id, name are same and i want to insert 5 different email ids. This should happen in a single submit)

                Basically i want to understand the flow i.e when i drag and drop things how it works. So that I can write custom methods and use them as ADF command buttons.

                Any help very much appreciated...

                Thanks in advance,
                Shri
                • 5. Re: How to create multiple new rows in ADF Table?
                  731982
                  Hi Neeraj,

                  Using the statement i'm still getting an error,

                  Error(93,39): cannot cast class javax.faces.el.ValueBinding to class oracle.adf.model.binding.DCBindingContainer


                  How can I cast it without any problem?

                  Thanks
                  Shri
                  • 6. Re: How to create multiple new rows in ADF Table?
                    John Stegeman
                    DCBindingContainer dc = (DCBindingContainer) FacesContext.getCurrentInstance().getApplication().createValueBinding("#{bindings}").getValue();
                    • 7. Re: How to create multiple new rows in ADF Table?
                      731982
                      Hi John,

                      I'm still getting the following error

                      Error(94,144): method getValue() not found in class javax.faces.el.ValueBinding



                      What should it be casted to?

                      The code in backing bean is like this..


                      package view.backing;



                      //import com.test.model.TestAppModuleImpl;
                      import javax.faces.component.html.HtmlForm;
                      import javax.faces.component.html.HtmlPanelGroup;
                      import javax.faces.context.FacesContext;
                      import javax.faces.event.ActionEvent;
                      //import javax.faces.event.FacesListener;
                      //import oracle.adf.model.BindingContext;
                      import oracle.adf.model.binding.DCBindingContainer;
                      import oracle.adf.model.binding.DCIteratorBinding;
                      import oracle.adf.view.faces.component.core.data.CoreColumn;
                      import oracle.adf.view.faces.component.core.data.CoreTable;
                      import oracle.adf.view.faces.component.core.input.CoreInputText;
                      import oracle.adf.view.faces.component.core.nav.CoreCommandButton;
                      import oracle.adf.view.faces.component.core.output.CoreMessages;
                      import oracle.adf.view.faces.component.html.HtmlBody;
                      import oracle.adf.view.faces.component.html.HtmlHead;
                      import oracle.adf.view.faces.component.html.HtmlHtml;
                      import oracle.jbo.ApplicationModule;
                      import oracle.jbo.Row;
                      import oracle.jbo.ViewObject;
                      //import oracle.jbo.server.ViewObjectImpl;
                      //import view.utils.EL;

                      public class MultipleInsert1 {


                      private HtmlHtml html1;
                      private HtmlHead head1;
                      private HtmlBody body1;
                      private CoreMessages messages1;
                      private HtmlForm form1;
                      private CoreTable table1;
                      private CoreColumn column1;
                      private CoreInputText inputText1;
                      private CoreColumn column2;
                      private CoreInputText inputText2;
                      private CoreCommandButton commandButton1;
                      private HtmlPanelGroup panelGroup1;
                      private CoreCommandButton commandButton2;

                      public void setHtml1(HtmlHtml html1) {
                      this.html1 = html1;
                      }

                      :
                      :
                      :
                      :
                      :


                      public void createMultiRows(ActionEvent actionEvent) {

                      DCBindingContainer dc = (DCBindingContainer) FacesContext.getCurrentInstance().getApplication().createValueBinding("#{bindings}").getValue();
                      DCIteratorBinding iter = dc.findIteratorBinding("TestView1Iterator");
                      ViewObject vo = iter.getViewObject();
                      for (int i=1; i<=5; i++) {
                      Row newRow = vo.createRow();
                      newRow.setAttribute("Id", i);
                      }
                      ApplicationModule am = vo.getApplicationModule();
                      am.getTransaction().commit();
                      vo.executeQuery();

                      }


                      /
                      :
                      :
                      :
                      :
                      :

                      }


                      Do I need to import something else?

                      Thanks,
                      Shri.
                      • 8. Re: How to create multiple new rows in ADF Table?
                        John Stegeman
                        sorry:
                        DCBindingContainer dc = (DCBindingContainer) FacesContext.getCurrentInstance().getApplication().createValueBinding("#{bindings}").getValue(FacesContext.getCurrentInstance());
                        • 9. Re: How to create multiple new rows in ADF Table?
                          731982
                          Thanks a lot John

                          I have another query

                          The above application is useful when we want to enter new values along with all the table entries getting displayed. What can I do If I dont want all the table values but just an 'AddEntries' page where I can only add new rows without having the entries in table getting displayed.

                          Also I want the Ids, say EmpIds to be same but different email Ids .

                          Say, 1 form has 5 rows

                          Each row has empId and eMail

                          EmpId is same for all 5 records but emailId is different.

                          Each row is a different record in Database.

                          Please help.

                          Thanks in advance,
                          Shri
                          • 10. Re: How to create multiple new rows in ADF Table?
                            John Stegeman
                            open a new thread for new questions
                            • 11. Re: How to create multiple new rows in ADF Table?
                              731982
                              Hi John,

                              Sorry for posting a different query on the same thread.

                              Please refer to the following link for the thread

                              Insert Multiple records in single form

                              Thanks,
                              Shri