Friday 16 March 2012

Uploading File into server from local machine

Hi
Friends, I just inform to you that, the following article is published by mukul's, but even though i want to publish this article for my friends and dearest one's.

Through my OAF page i want to upload the file from local to server.

Step 1: Create the page with two items
               
           a. MessageFileUpload Bean
           b. Submit Button.
Step 2: Now write the below logic in the controller class

 public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);   
    if(pageContext.getParameter("Submit")!=null)
    {

             upLoadFile(pageContext,webBean);     
    }                     
  } 

 public void upLoadFile(OAPageContext pageContext,OAWebBean webBean)
  {
                    System.out.println("Action Performed");


                    String filePath = pageContext.getProfile("FILE_UPLOAD_PATH");

                    System.out.println("Default File Path---->"+filePath);

                    String fileUrl = null;

                    try

                    {

                      DataObject fileUploadData =  pageContext.getNamedDataObject("FileUploading"); //FileUploading is my MessageFileUpload Bean Id

                       if(fileUploadData!=null)
                      {


                        System.out.println("BeanId is also Not null");


                        String uFileName = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_NAME"); // include this line

                        String contentType = (String) fileUploadData.selectValue(null, "UPLOAD_FILE_MIME_TYPE"); // For Mime Type

                        System.out.println("User File Name---->"+uFileName);

                        FileOutputStream output = null;

                        InputStream input = null;

                        System.out.println("am In try block---->");

                        BlobDomain uploadedByteStream = (BlobDomain)fileUploadData.selectValue(null, uFileName); 
                        System.out.println("uploadedByteStream---->"+uploadedByteStream);
                       // File file = new File("/export_home_dev/user/oracle", uFileName); //once you deploy the page uncomment this line and give your server path according to your fish
                        File file = new File("D:\\santhosh", uFileName); // comment this line once you deploy the page into server
                        System.out.println("File output---->"+file);

                       // output = new FileOutputStream("D:\\Kumar"+uFileName);

                        output = new FileOutputStream(file); 

                        System.out.println("output----->"+output);

                        input = uploadedByteStream.getInputStream();

                        System.out.println("input---->"+input);
                        byte abyte0[] = new byte[0x19000];
                        int i;
 

                       while((i = input.read(abyte0)) > 0) 
                        output.write(abyte0, 0, i);

                       // output.write(uploadedByteStream.getBytes(0,(int)uploadedByteStream.getLength()));
                        output.close();
                        input.close();
                      //  fileUrl = (String)file;
                      }
                    }
                   catch(Exception ex)
                    {
                      throw new OAException(ex.getMessage(), OAException.ERROR);

                    }     
   
  }

Step 4: Now Run the page and see the output.

Step 5: Before going to see the output, i will show you, in my local mahcine i don't have file called
"BT_GEOCode_Order_To_Cash.xls" file
     

Step 6: Now Run the page and Browse the file
   
Step 7: Now check the Browsed file called  "BT_GEOCode_Order_To_Cash.xls" file in the local machine


Note: This application is working in local machine only , because i gave my local path for the saving purpose, so if you want to save the file from local to server, then you need to do the following things

a. First change the local path to server path
b. then deploy the page and related .class and .server files from local to server
c. now run the page in the application not in the local machine(jdeveloper).


       
            

Friday 9 March 2012

Implementing Auto Customizatin Criteria

                                      Implementing Auto Customizatin Criteria
Using Auto Customization Criteria, we are developing the following page.
Step 1: Create one work space
Step 2: Create a project
Step 3: Create business Component package in .server package.
Step 4: Create Application Module in .server Package
Step 5: Create a page in .webui package and set the mandatory properties.
             AM Definition
Cisco.oracle.apps.xxcfi.ap.holdtel.SummaryAM
Window Title
Auto Customization Criteria.
Title (Optional)
Implementing Auto Customization Criteria.

Step 6: Crete on View Object (VO) in .server package and shuffle to AM.
Step 7: Go to pageLayoutRegion and create a region called Query and set the below properties.
Construction Mode
Auto Customization Criteria
Include Views Panel
False
Include Advanced Panel
False

Step 8: Right Click on Query Region and create a region using wizard, in that select am and select the region style is table.
Step 9: Now again Right Click on QueryRN, select simpleSearchPanel, now automatically region2 (header Region) and region1 (MessageComponentLayout Region) created.
Step 10: now set the following properties to the region2
Id
SimpleSearchHeader
Text
Simple Search


Step 11: Now select the region1 and set the below properties
Id
SimpleSearchMappings
Rows
2
Columns
1


Step 12: Now right click on message Component Layout Region (SimpleSearchMappings) and create two message text input beans and set the below properties to each
MessageTextInputBean1
Id
SearchSutdNo
Search Allowed
True
Data Type
Number
Maximum Length

CSS Class
OraFieldText
Prompt
Student No


MessageTextInputBean2
Id
SearchSutdName
Search Allowed
True
Data Type
Varchar2
Maximum Length
100
CSS Class
OraFieldText
Prompt
Student Name


Step 13: Now Right Click on query Components and create simple Search Mappings. Then automatically SimpleSearchMappings and QueryCriteriaMap1 created.
Step 14: Now select the QueryCriteriaMap1 and set the below properties.
Id
SearchStudNoMap
SearhItem
SearchSutdNo
ResultItem
Sno


Step 15: Now again right click on SimpleSearchMappings àNewàQueryCriteriaMap, and then set the below properties.
Id
SearchStudNameMap
SearhItem
SearchSutdName
ResultItem
Sname

Step 15: Now run the page and check the functionality. Give Student No as 41 and Click on Go button, now you will see the output.
Note: Page XML Structure
Note: If you want LOV for the Student Number and Student Name , change the item style and do the neccessary steps.
                                  

Tuesday 6 March 2012

Working With Key Flex Filed In OAF

                                                               Working With Key Flex Filed In OAF

Step 1: Create one Work Space and Project.
Step 2: Create one VO and AM under .server package.
Step 3: Query: SELECT CODE_COMBINATION_ID FROM GL_CODE_COMBINATIONS_KFV;
Step 4: Shuffle the VO to the AM.
Step 5: Create page and set the mandatory properties to the page Layout Region.
Step 6: Create one Stack Layout Region under the Page Layout Region.
Step 7: Create item of type Flex under the Stack Layout Region.
Step 8: Set the below proper ties to the flex Item

Item Id
KeyFlexItem
prompt
Accounting Key Flex Field
Application Short Name
SQLGL
Name
GL#
Type
Key
View Instance
codeCombinationsVO1


Step 9: Create one Controller Class and write the below code in the Process Request Method
    //get the Key flex Field Bean Id
    OAKeyFlexBean kffId = (OAKeyFlexBean)webBean.findIndexedChildRecursive("KeyFlexItem ");
    System.out.println("Key Flex Filed Bean Id is--->"+kffId);
     // set the code combination lov
    kffId.useCodeCombinationLOV(true);
     //set the structure code for the item key flex
    kffId.setStructureCode("Expert_AFF"); //Expert_AFF, ACCOUNTING_FLEXFIELD
    //kffId.setStructureCode("ARGENTINA_ACCOUNTING_FLEX");
     //Set the attribute name to the item
    kffId.setCCIDAttributeName("CodeCombinationId");
    //merging segments with key flex fields
   // CCIDlovEnabledKFF.mergeSegmentsWithParent(pageContext);
    //Execute the Query
    sampleAMImpl am = (sampleAMImpl)pageContext.getApplicationModule(webBean);
    KeyFlexFieldVOImpl vo = (KeyFlexFieldVOImpl)am.findViewObject("KeyFlexFieldVO1");
    if(!vo.isPreparedForExecution())
    {
      vo.executeQuery();
    }
Step 10: Now run the page see the output.

Step 11: Click on Search for segments.
Step 12: If you don’t  want to see the key flex field is merging one then change the code in the controller class as below.
kffId.useCodeCombinationLOV(false);


Step 13: Use the below Query to find the Structure Code
select  FIF.APPLICATION_ID  , 
        FIF.ID_FLEX_CODE    , 
         FIF.ID_FLEX_NAME    , 
         FIF.APPLICATION_TABLE_NAME , 
         FIF.DESCRIPTION     , 
         FIFS.ID_FLEX_NUM    , 
         FIFS.ID_FLEX_STRUCTURE_CODE  , 
         FIFSE.SEGMENT_NAME, 
         FIFSE.SEGMENT_NUM, 
         FIFSE.FLEX_VALUE_SET_ID 
 from    FND_ID_FLEXS FIF    , 
         FND_ID_FLEX_STRUCTURES FIFS , 
         FND_ID_FLEX_SEGMENTS FIFSE 
 where   FIF.APPLICATION_ID = FIFS.APPLICATION_ID 
 and     FIF.ID_FLEX_CODE   = FIFS.ID_FLEX_CODE 
 and     FIFSE.APPLICATION_ID = FIF.APPLICATION_ID 
 and     FIFSE.ID_FLEX_CODE = FIF.ID_FLEX_CODE 
 and     FIFSE.ID_FLEX_NUM = FIFS.ID_FLEX_NUM 
 and     FIF.ID_FLEX_CODE LIKE 'GL#'
 and     FIF.ID_FLEX_NAME LIKE 'Accounting Flexfield';

Monday 5 March 2012

Adding New Row to the Advanced Table in Programatical way

                               Adding New Row to the Advanced Table in Programatical way

Step 1: Create sample page

Step 2: Create one Advanced Table in that page

Step 3: Setup the required properties for the page

Step 4: Create on footer for the table, in that create one add table row button

Step 5:
Set the below properties to the Add Table Row button


                  Insert Rows Automatically : False

Step 6: Now in the process Request method add the below code
  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
    sampleAMImpl am = (sampleAMImpl)pageContext.getApplicationModule(webBean);
    am.invokeMethod("createInsert1");
    OAAdvancedTableBean tableBean = (OAAdvancedTableBean)webBean.findIndexedChildRecursive("AdvancedTableBean1");
    System.out.println("Advanced Table Bean id--->"+tableBean);
    OATableFooterBean footerBean = (OATableFooterBean)tableBean.getFooter();
    System.out.println("TableFooter bean-->"+footerBean);
    if(footerBean!=null)
    {
      OAAddTableRowBean addTableRowBean =  (OAAddTableRowBean)footerBean.findIndexedChild("addTableRow1");
      System.out.println("Add Table Row Bean id----->"+addTableRowBean);
      // Add 5 rows everytime add row button is clicked
      addTableRowBean.setText("Add 1 Rows");
      addTableRowBean.setRows(1);
      // Handle add row insertion yourself
      addTableRowBean.setAttributeValue(AUTO_INSERTION, Boolean.FALSE);
    }
  } 


Step 7:  In AMImpl Class write the below Code
     public void createInsert1()
  {
    OAViewObject vo =getInsertVO1();
    if (!vo.isPreparedForExecution())  
    {      
      vo.executeQuery();   
    }
   
  }


Step 8: Now in the process Form Request method add the below code
   public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);
     OAAdvancedTableBean tableBean = (OAAdvancedTableBean)webBean.findIndexedChildRecursive("AdvancedTableBean1");
     System.out.println("Advanced Table Bean id--->"+tableBean);
     OATableFooterBean footerBean = (OATableFooterBean)tableBean.getFooter();
     System.out.println("TableFooter bean-->"+footerBean);
     if(footerBean!=null)
     {
       OAAddTableRowBean addTableRowBean =  (OAAddTableRowBean)footerBean.findIndexedChild("addTableRow1");
       System.out.println("Add Table Row Bean id----->"+addTableRowBean);
       if ((tableBean.getName(pageContext).equals(pageContext.getParameter(SOURCE_PARAM))) && (ADD_ROWS_EVENT.equals(pageContext.getParameter(EVENT_PARAM))))
       {
       System.out.println("Add Another row is pressed");
       sampleAMImpl am = (sampleAMImpl)pageContext.getApplicationModule(webBean);
       am.invokeMethod("createAnotherRow1");
       System.out.println("Action over");
       }
     }


Step 9: In Am Impl Class write the below Code

   public void createAnotherRow1()
  {
    InsertVOImpl studVo = getInsertVO1();
    // StudentDetailsVOImpl studVo = getStudentVO1();
    System.out.println(" vo class statement");
    InsertVORowImpl studrow = (InsertVORowImpl)studVo.createRow();
    System.out.println(" vo row impl statement");
    studVo.last();
    System.out.println("vo.last method");
    studVo.next();
    System.out.println("vo.next method");
    studVo.insertRow(studrow); //'ABC' is HardCod value inserted based on the requirement in this example
    System.out.println("insert row method");
    studVo.setCurrentRow(studrow);
    System.out.println("current row method");
    studrow.setNewRowState(Row.STATUS_INITIALIZED);
    System.out.println("Initialized method");
  }


Step 10: Now Run the page and check the functionality of Add Another Row.