Wednesday 28 March 2018

Assigning Values to the DFF attributes through SQL query in OAF Page through Controller Extension

Assigning Values to the DFF attributes through SQL query in OAF Page through Controller Extension

 
In this post , We will use SQL to fetch the data from some custom Table and then assign this fetched columns  in the DFF attributes. We will execute the SQL query based on the LOV selected value by the Business user in the OAF page. Here in this requirement , we will take help of Controller Extension to Capture the LOV selection event and then use the LOV selected value to fetch the sql query date and then assign this value to the DFF attributes for the OAF page. This is some thing we are giving solution out of the box from the standard application to capture the external information based on the Value selected by the user in  the LOV. We can then use this external information in the OAF pages through DFF fields.
 
Assigning Values to the DFF attributes through SQL query in OAF Page through Controller Extension
 

Assigning Values to the DFF attributes through SQL query in OAF Page through Controller Extension

 
Here below I am sharing you the Controller Extension for this above requirement.
 
There are the steps this Controller will do.
1.Capture the LOV selection event .
2.Then use the LOV selected value to fetch the sql query date.
3Then assign this value to the DFF attributes for the OAF page.
 
 
 
 public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    {
       super.processFormRequest(pageContext, webBean);
       
         OAApplicationModule am = pageContext.getApplicationModule(webBean);      
 
        String xxinvno=null;
        String Att1=null,Att2=null;
        String result ="";       
        if(pageContext.isLovEvent()) 
        { 
             String lovInputSourceId = pageContext.getLovInputSourceId(); 
             if("XXInvNo".equals(lovInputSourceId))
             { 
              
                  Hashtable lovValue = pageContext.getLovResultsFromSession(lovInputSourceId); 
                  if(lovValue !=null) 
                    { 
                      xxinvno =(String)lovResults.get("XXInvNo"); // "InvNo" is the Return Item specified in the lovMapping 
                          
                    }
                  if (xxinvno!=null) 
                  {
                      String sql = "select customer_name,phone_no from xx_third_pary_data where invocie_number= ="+ xxinvno;
                      try {
                          Connection conn = (Connection)am.getOADBTransaction().getJdbcConnection();
                          PreparedStatement sql1 = conn.prepareStatement(sql);
                          ResultSet rs = sql1.executeQuery();
                          while(rs.next())             
                            {
                             Attr1 = rs.getString(1).trim();
                             Attr2 = rs.getString(1).trim();                             
                             }
                            }
                        catch (Exception e)
                            {  e.printStackTrace();
                            }
                       OAViewObject viewobject1 = (OAViewObject)am.findViewObject("SuppliersHeaderVO");
                          if(viewobject1!=null)
                          {
                           pageContext.writeDiagnostics(this, "Successfully set the VO", 2);
                          }
                          OAMessageTextInputBean viotype = (OAMessageTextInputBean)webBean.findChildRecursive("Attribute1");
                           viotype.setValue(pageContext, Attr1);               
                          OAMessageTextInputBean Tktno = (OAMessageTextInputBean)webBean.findChildRecursive("Attribute2");
                           Tktno.setValue(pageContext, Attr2);     
                          }                   
                      }
              }         
          }


Assigning Values to the DFF attributes through SQL query in OAF Page through Controller Extension
 

Contact us for any Collaboration, Project Support & On Job Support Work

Name

Email *

Message *