Oracle applications - Surendranath Subramani: OAF
Showing posts with label OAF. Show all posts
Showing posts with label OAF. Show all posts

Wednesday, November 20, 2024

Monday, January 14, 2019

Dependent Value set in OAF



Date: 10-Jan-2019
JDev version: 10.13.3.0.3
Oracle EBS: 12.1.3

Objective:

In this article we are going to create 2 LOVs Supplier LOV and Supplier Site LOV and see how to setup Supplier Site dependent on Supplier (without using "Programmatic Query" option).

Note:

There are many article you will find on the internet but all the documents talks about using "Programmatic Query".

In this article we are going to see what problem we face when using "Programmatic Query" and how to avoid it.


Important:

Click below link to download the source code

Click to download file




Problem using "Programmatic Query":

After entering supplier name (1st LOV) and when you enter site name in the 2nd LOV and click LOV button, you would expect to see site LOV showing results filtered based on entered site name, but using "Programmatic Query" properly you will see the entire result showing all site for that supplier. So user need to click GO button again to apply the filter. 

Find below screen shows to know the problem which i am talking about.


In below example you can see Supplier is DELL MARKETING and Site is ATLANTA% but the lov shows all the site.




























This issue can be avoided by setting False to "Programmatic Query" propriety.

In this article we are going to see the complete demo.



1. Create VO:

1.1 Create supplier VO:

VO name
supplierVO
Query
select vendor_id, vendor_name from ap_suppliers




1.2 Create supplier Site VO:

VO name
supplierSiteLov
Query
select vendor_site_code, vendor_id from ap_supplier_sites_all






1.3 Define AM
create AM and shuttle both supplier and supplier site VO to AM





2. Create External LOV:

2.1 Supplier LOV Region

Name
supplierLovRN
Style
listOfValues
Available View Usages
supplierLov1
Region ID
supplierLov1
Region Style
Table
Selected view Attributes:
VendorId
VendorName
Go to VendorName (messageStyledText)
change
ID= VendorNameLov
Search Allowed = True
Go to VendorId (messageStyledText)
change
ID=VendorIdLov













2.2 Attach AM to the Lov Region



Region Style
listOfValues
Scope
Public
AM Definition
suren.oracle.apps.ak.Lov.server.lovAM



2.3 SupplierSite LOV Region

Name
supplierSiteLovRN
Style
listOfValues
Available View Usages
supplierSiteLov1
Region ID
supplierSiteLov1
Region Style
Table
Selected view Attributes:
VendorSiteCode
VendorId
Go to VendorSiteCode (messageStyledText)
change
ID= VendorSiteCodeLov
Search Allowed = True
Go to VendorId (messageStyledText)
change
ID=VendorIdLov









2.4 Attach AM to the Lov Region



Region Style
listOfValues
Scope
Public
AM Definition
suren.oracle.apps.ak.Lov.server.lovAM




3. Page Setup:

Setup new page.

Name
searchPG
Package
suren.oracle.apps.ak.lov.webui




Change region ID to searchLayout 

Setup controller and AM to the region

Controller
suren.oracle.apps.ak.Lov.webui.searchCO
AM Definition
suren.oracle.apps.ak.Lov.server.lovAM





3.1 Lookup Item (Supplier)


Region
messageComponentLayout
Define messageLovInput
Supplier
External LOV
/suren/oracle/apps/ak/Lov/webui/supplierLovRN



Define new FormValue


ID
supplieridFV
Item Style
formValue




Supplier Lov Mapping (1)

ID
vendorLovMap
Lov Region Item
VendorNameLov
Return Item
supplier
Criteria Item
supplier



Supplier Lov Mapping (2)


ID
parentVendorIdlovMap
Lov Region Item
VendorIdLov
Return Item
supplieridFV







3.2 Lookup Item (Supplier Site)

Define messageLovInput
supplierSite
External LOV
/suren/oracle/apps/ak/Lov/webui/supplierSiteLovRN



Supplier Site Lov Mapping (1)


ID
vendorSiteCodelovMap
Lov Region Item
VendorSiteCodeLov
Return Item
supplierSite
Criteria Item
supplierSite
Programmatic Query
False

Make sure to select "Programmatic Query".


Supplier Site Lov Mapping (2)


ID
childVendorIdlovMap
Lov Region Item
VendorIdLov
Criteria Item
supplieridFV




Final result:

Lets do the same search as we did in the beginning of the article. As you could see when i enter site ATLANTA% and click on LOV button the search window showed only ALTANA site.















Thanks for visiting my blog.



Sunday, June 3, 2018

Show OADialogPage with 1 button only

How to show OADialogPage page with only 1 button.?


By default OADialogPage will only 2 buttons. To make it only 1 button pass null at the end of dialogPage declaration.



1
2
        OADialogPage dialogPage = 
            new OADialogPage(OAException.WARNING, instrMesg, null, "", null);


Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
        OAException instrMesg =
            new OAException("ICX", "CVICX_FREIGHT_TAX_WARNING");

        OADialogPage dialogPage =
            new OADialogPage(OAException.WARNING, instrMesg, null, "", null);

        dialogPage.setOkButtonItemName("xxYes");
        dialogPage.setOkButtonToPost(true);
        dialogPage.setOkButtonLabel("Continue");
        dialogPage.setPostToCallingPage(true);


Thanks for visiting my blog!

Thursday, December 21, 2017

Embedded Files in pdf using pdf box library

Date: 21-Dec-2017

JDK used for this demo: 1.7.079


Purpose:


Today we are going to see how to embed files in pdf using library called PDF BOX

pdfbox 1.8.9 library used in this article


The download link for the library is given belowl


Let us take an example.

I picked 3 files as shown below.

TEST-document.docx
TEST-Image.JPG
TEST-PDF.pdf

I am going to create new file and embed all 3 files in it.



Below code does the magic

Execute below code using any editor, i have used eclipse.

Step: 1


  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.util.GregorianCalendar;
import java.util.HashMap;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentNameDictionary;
import org.apache.pdfbox.pdmodel.PDEmbeddedFilesNameTreeNode;
import org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification;
import org.apache.pdfbox.pdmodel.common.filespecification.PDEmbeddedFile;

public class pdfBox
{
  /**
   * Constructor.
   */
  public pdfBox()
  {
      super();
  }
  /**
   * create the second sample document from the PDF file format specification.
   *
   * @param file The file to write the PDF to.
   *
   * @throws IOException If there is an error writing the data.
   */

  public void doIt( String path, String fileName) throws IOException
  {
      // the document
      PDDocument doc = null;
      try
      {

          
       // get primary file name
          doc = PDDocument.load(new File(path+"TEST-PDF.pdf"));
          HashMap efMap = new HashMap();
          
    File file2 = new File(path);
  File[] listOfFiles = file2.listFiles();
  
  
  for (int i = 0; i < listOfFiles.length; i++) {
        if (listOfFiles[i].isFile()) {
          System.out.println("File " + listOfFiles[i].getName());
          
           //first create the file specification, which holds the embedded file
            PDComplexFileSpecification fs = new PDComplexFileSpecification();

                 File file1 = new File(path+listOfFiles[i].getName());
        FileInputStream fis = new FileInputStream(file1);
      
        fs.setFile( file1.getName() ); 
        
        
     byte fileContent[] = new byte[(int)file1.length()];
     fis.read(fileContent);
      fis.close();
     ByteArrayOutputStream bao = new ByteArrayOutputStream();
     bao.write(fileContent);
     
             byte[] data1 = bao.toByteArray();

             ByteArrayInputStream bin = new ByteArrayInputStream(data1);
             System.out.println(bin.available());

             System.out.println("Start custom - 2");

     
        
            PDEmbeddedFile ef = new PDEmbeddedFile(doc, bin );
            //now lets some of the optional parameters
//            ef.setSubtype( fileType );
            ef.setSize( data1.length );
            ef.setCreationDate( new GregorianCalendar() );
            ef.setModDate(new GregorianCalendar() );
            fs.setEmbeddedFile( ef );
            fs.setFileDescription("testing2");
            
            efMap.put("Attachments"+i, fs);
            
          
        } else if (listOfFiles[i].isDirectory()) {
          System.out.println("Directory " + listOfFiles[i].getName());
        }
      }              
          
          
  
          //embedded files are stored in a named tree
          PDEmbeddedFilesNameTreeNode efTree = new PDEmbeddedFilesNameTreeNode();
          efTree.setNames(efMap);

           
            // add the tree to the document catalog
          PDDocumentNameDictionary names = new PDDocumentNameDictionary( doc.getDocumentCatalog() );
          names.setEmbeddedFiles( efTree );
          doc.getDocumentCatalog().setNames( names );


          doc.save( path+fileName );
          doc.close();
         
      }
      
      catch (Exception  e){
   e.printStackTrace();
   System.out.println("Error");
   }
      
      finally
      {
          if( doc != null )
          {
              doc.close();
          }
      }


  }

  /**
       * This will create a hello world PDF document with an embedded file.
       * <br>
       * see usage() for commandline
       *
       * @param args Command line arguments.
       */
      public static void main(String[] args) throws IOException
      {
       pdfBox app = new pdfBox();
          
          if( args.length != 1 )
          {
//              app.usage();
 app.doIt( "c:\\temp\\article\\","Embedded-file.pdf" );
          }
          else
          {
              app.doIt( "c:\\temp\\article\\",args[0] );
          }
      }
  /**
   * This will print out a message telling how to use this example.
   */
//  private void usage()
//  {
//    System.out.println( ": " + this.getClass().getName() + " <output-file>" );
//      System.err.println( "usage: " + this.getClass().getName() + " <output-file>" );
//  }

}


If you have trouble in copying the code, i have given download link to download the code.

Step: 2

After you import the code, you will notice the error. This is because the library has not been imported. You are all set after library import.





Step: 3

After executing this is now the log looks like:

File TEST-document.docx
12394
Start custom - 2
File TEST-Image.JPG
12144
Start custom - 2
File TEST-PDF.pdf
1516
Start custom - 2




Step: 4

After i execute now i see new pdf file Embedded-file.pdf.



I have shared the download link below if you like to view how embedded-file.pdf file look like.


Step: 5

If i open the file i see other files are attached.






Use full links:

pdf box 1.8.9

https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox/1.8.9
or
https://drive.google.com/open?id=1xSpGSgyX850y381Lcdnpbe8-op0YqIzn

Commons Logging

http://www.java2s.com/Code/Jar/c/Downloadcommonslogging11forpdfboxjar.htm
or
https://drive.google.com/open?id=1tn8rv2C6_Tsrfo5OcAPCBW9w6PngQpJy


pdfBox.java 

https://drive.google.com/open?id=162au37eQiAELeT6XEyyLV_KqZKeYFXKE

Embedded-file.pdf

https://drive.google.com/open?id=1do0povZOKWxF8KAIih1WAIIk8vwf12wZ