2 Replies Latest reply: Dec 28, 2012 5:19 AM by Manish RSS

    problem to create multiple rows in adf table.

    Manish
      Hi All,

      i am using jdev version 11.1.1.5.0. i have facing very strange problem to create row on table.

      In my use case i have create row on table under loop statement. so no of rows created based on loop condition. each time on loop we supply diffrenet value for column like subpkgid,sno but row created with same value.

      code is following-
          public void createRowOptHdr()
          {     
                    boolean flag=false;
                  ViewObject reqhdrvo= getService().getView("StmReqhdrView1Iterator");
                 Row reqhdrrow= reqhdrvo.getCurrentRow();
                  
                  ViewObject pkglist= getService().getView("PkgListOptHdr1Iterator");          
                 
                 ViewObject tskcdvo= getService().getView("GetTskSubtskCd1Iterator");
                  System.out.println("Subtype===>"+reqhdrrow.getAttribute("Subtype"));           
                  tskcdvo.setNamedWhereClauseParam("stype",reqhdrrow.getAttribute("Subtype"));
                  Row tskrow=tskcdvo.first();
                  
                  int count =pkglist.getRowCount();
                  
                  ViewObject opthdr= getService().getView("StmOpthdrView2Iterator");
                             opthdr.executeQuery();
                  Row optrow=null;
                  Row pkgrow=null;
                  for(int i=1;i<=count;i++)
                  {
                      if(i==1)
                      {
                      pkgrow=pkglist.first();
                      }
                      else
                      {
                          pkgrow=pkglist.next();
                          }
                      if(pkgrow.getAttribute("Mark")!=null)
                      {                    
                   flag=(Boolean)pkgrow.getAttribute("Mark");
                      }
                      else
                      {
                          flag=false;
                          }
                      if(flag)
                      {
                       
                          optrow = opthdr.createRow();   
              optrow.setAttribute("Reqdt",reqhdrrow.getAttribute("Reqdt"));
              System.out.println("Pkg Id====>"+pkgrow.getAttribute("Id"));
              String id=(String)pkgrow.getAttribute("Id");
              System.out.println("id val==>"+id);
              optrow.setAttribute("Pkgid",reqhdrrow.getAttribute("V_Pkgid"));
              optrow.setAttribute("Subid",id);
              optrow.setAttribute("Sno",opthdr.getRowCount());
              optrow.setAttribute("ReqStatus","WAIT");
              optrow.setAttribute("LHier",reqhdrrow.getAttribute("LHier"));
              optrow.setAttribute("Subtype",reqhdrrow.getAttribute("Lanweb"));
              optrow.setAttribute("Divn",reqhdrrow.getAttribute("Divn"));
              optrow.setAttribute("Status","Y");
              optrow.setAttribute("TaskCd",tskrow.getAttribute("TaskCd"));
              optrow.setAttribute("SubtaskCd",tskrow.getAttribute("SubtaskCd"));
              opthdr.insertRow(optrow);
              try
              {
              optrow.validate();
              }
              catch(Exception e)
              {
                  System.out.println("Error to validate opt hdr row===>"+e);
                  }
            
              //opthdr.executeQuery();
                      }
                  }
      i have called this method on a button click so no of row selected on pkglist vo same no of row created. and these row are different pkgid but when i again select some row from pkglist and click on button thease row created with same sno ,subpkgid as first row.