Monday, 26 November 2012

Storing values from the page to a row in view object



                  This is one important step in OAF page development. Initializing the view object and storing values in to it from the page field. The steps are given below in the following code.

            OAViewObjectImpl var1 = (OAViewObjectImpl)am.findViewObject("XXVO");
                 if (!var1.isPreparedForExecution())
                 {
                    var1.executeQuery();
                 }   
                 var1.last();
                 var1.next();
                 OARow Row = (OARow)var1.createRow();
                 var1.insertRow(Row);
                 Row.setNewRowState(OARow.STATUS_INITIALIZED);

Dynamic View Object (Create View object in Controller)

           I had a requirement for getting the value from the table dynamically. That requirement was new to me. I searched in the web and found the solution, which is to create a view object dynamically. This will give you the needed data.



 String L3OnTheFlyVOQueryPFR = "select  past.USER_STATUS, "

                                                             +" FROM Per_all_assignments_f papf,"

                                                             +"PER_ASSIGNMENT_STATUS_TYPES past where ”

past.ASSIGNMENT_STATUS_TYPE_ID=papf.ASSIGNMENT_STATUS_TYPE_ID"

                                                             +" and ASSIGNMENT_ID='"+AssId+"'";



ViewObject OnTheFlyViewObjectPFR = am.findViewObject("FindPersonStaVO");

                       if(OnTheFlyViewObjectPFR == null)

                           OnTheFlyViewObjectPFR = am.createViewObjectFromQueryStmt("FindPersonStaVO ", OnTheFlyVOQueryPFR);

                          

                           OnTheFlyViewObjectPFR.executeQuery();

                           oracle.jbo.Row row = OnTheFlyViewObjectPFR.first();

                 

                  String UserStatus=null;

                 

                   if(row != null)

                   {

                      UserStatus=row.getAttribute(0).toString();

                   }

                   OnTheFlyViewObjectPFR.remove();