Monday 16 January 2012

Idea how to create the VO and VL dynamically in oaf

How to create VO s and VLs dynamically in OAF

I have to create 2 VO objects dynamicaly and created 2 VL's dynamically .I have a static HGrid.and iam setting viewlinks dynamically.It is working for 1 level but not another leve..For Example.. Grid id displaying projects to Tasks but not tasks to subtasks.

here is my code

public void createViewLink(){
OADBTransaction dbTransaction=getOADBTransaction();
OAViewObject obj = (OAViewObject)this.findViewObject("TestProjects1VO1");
OAViewObject obj1 = (OAViewObject)this.findViewObject("TestTasks1VO1");

AttributeDef] prjLinkAttrs = new AttributeDef[ { obj.findAttributeDef("ProjectId") };
AttributeDef] taskLinkAttrs = new AttributeDef[ { obj1.findAttributeDef("ProjectId") };
ViewLink vl = createViewLinkBetweenViewObjects("TestPrjToTestTasksVL","TestPrjToTasksAcc",
obj,prjLinkAttrs,obj1,taskLinkAttrs,null);



//OAViewObject obj3 = (OAViewObject)this.findViewObject("TestTasks1VO1");
OAViewObject obj2 = (OAViewObject)this.findViewObject("TestRecTasks1VO1");


AttributeDef] taskAttrs = new AttributeDef[ { obj1.findAttributeDef("TaskId") };
AttributeDef] parentTaskAttrs = new AttributeDef[ { obj2.findAttributeDef("ParentTaskId") };



ViewLink vl1 = createViewLinkBetweenViewObjects("TaskToTestTasksVL","TaskToTasksAcc",
obj1,taskAttrs,obj2,parentTaskAttrs,null);
}

OAHGridBean hgrid=(OAHGridBean)webBean.findChildRecursive("HGridRN");
OAHGridHierarchyBean hgridHierarchy = (OAHGridHierarchyBean)hgrid.findChildRecursive("TreeRN");
OATreeLevelBean treeChild = (OATreeLevelBean)hgridHierarchy.findChildRecursive("TreeRN");


OAWebBean nodeDef1 = (OAWebBean)treeChild.findChildRecursive("nodeDef1");
nodeDef1.setViewUsageName("TestProjects1VO1");
nodeDef1.setViewAttributeName("ProjectName");



OATreeChildBean childNode1 = (OATreeChildBean)treeChild.findChildRecursive("childNode1");
childNode1.setAttributeValue(VIEW_LINK_NAME,"TestPrjToTestTasksVL");
childNode1.setAttributeValue(VL_ACCESSOR_NAME_ATTR,"TestPrjToTasksAcc");


OAWebBean nodeDef2 = (OAWebBean)childNode1.findIndexedChild(childNode1,"nodeDef2");
nodeDef2.setAttributeValue(VIEW_USAGE_NAME, "TestTasks1VO1");
nodeDef2.setAttributeValue(VIEW_ATTRIBUTE_NAME,"TaskName");

%%%%%%%%%%%%%%%Till Here grid is getting data%%%%%%%%%%%%

This node is not getting data............i.e sub tasks are not getting data


OATreeChildBean childNode2 = (OATreeChildBean)childNode1.findIndexedChildRecursive("childNode2");
childNode2.setAttributeValue(VIEW_LINK_NAME,"TaskToTestTasksVL1");
childNode2.setAttributeValue(VL_ACCESSOR_NAME_ATTR,"TaskToTasksAcc");
OAWebBean nodeDef3 = (OAWebBean)childNode2.findIndexedChild(childNode2,"nodeDef3");
nodeDef3.setAttributeValue(VIEW_USAGE_NAME, "TestRecTasks1VO1");
nodeDef3.setAttributeValue(VIEW_ATTRIBUTE_NAME,"TaskName");

Converting String Object to Date Object in OAF and also how to pass the date object to preparedStatement

/**** String to Sql Date Conversion and passing this sql date object to prepared Statement in oaf ****/
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

      OAMessageStyledTextBean lastUpdateDate = (OAMessageStyledTextBean)webBean.findIndexedChildRecursive("LastUpdate");
      java.util.Date utilDate = (Date)lastUpdateDate.getValue(pageContext);
      System.out.println("Last Update Date is..1--->"+utilDate);
      java.sql.Date sqlDate = null;
      try
      {
      DateFormat formatter ;
    
      formatter = new SimpleDateFormat("dd-MMM-yyyy");
      String formatDate = formatter.format(utilDate);
      System.out.println("formatDate--->"+formatDate);
      sqlDate = java.sql.Date.valueOf(new String(formatDate));
      System.out.println("sql Date---->"+sqlDate);
    
      }
      catch(Exception e)
      {
        System.out.println("Exception :"+e);
      }
      try
      {
      String Query = "UPDATE XXBT_AMS_TC_DETAILS SET REASON = ? , DATE_CREATED = ? WHERE TICKET_NUMBER = ? ";   
      PreparedStatement stmt = conn.prepareStatement(Query);
      stmt.setString(1,recentUpdate);
     // stmt.setDate(2,oadbtransactionimpl.getCurrentDBDate().dateValue());which takes the current db date
      stmt.setDate(2,sqlDate); // which takes the user input date
      System.out.println("Date Created---"+oadbtransactionimpl.getCurrentDBDate().dateValue());
      stmt.setString(3,incidentNumber2);
      stmt.executeUpdate();
      conn.commit();

Monday 9 January 2012

Creating Defalut List Bean Dynamically In oaf

Creating Defalut List Bean dynamically in oaf
    
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
    OADefaultListBean list =(OADefaultListBean)createWebBean(pageContext,OAWebBeanConstants.DEFAULT_LIST_BEAN,null, "positionsList");
    // Specify the view object that you will use to populate the list bean values.
    list.setListViewObjectDefinitionName("oracle.apps.fnd.framework.toolbox.poplist.server.PositionsVO");
    // Specify the display and internal value attributes in the associated viewobject.
    list.setListValueAttribute("LookupCode");
    list.setListDisplayAttribute("Meaning");
    // Configure the list box to allow selection of multiple values.
     list.setMultiple(true);
    // Even though you created the component with an ID, you must explicitly
    // make this call to setName().
    list.setName("posList");
    list.setText("List of values");
    // In this example, we're adding the list box to a messageComponentLayoutregion, so we
    // get the declaratively defined messageLayout region that will contain this
    // component. Note that we declaratively set a prompt for the list box on the
    // messageLayout region.
    OAMessageLayoutBean listBoxLayout =(OAMessageLayoutBean)webBean.findChildRecursive("ListBoxLayout");
    listBoxLayout.addIndexedChild(list);
  }


Output: