This appendix covers the following topics:
Refer to Creating User Defined Dynamic Fields for information on creating user defined dynamic fields.
Users can reuse the same database connection (transaction) that is used to generate the proposal document. They can also create their own database connection, connecting to same database or different database. Please see the following sections for explanation of benefits/disadvantages of using each approach.
If you use the same transaction or database connection, you can get profile option values, user details, or other information, for the user who is generating the proposal. You can get the connection object by using the statement:
Connection con = oaDbTransaction.getJdbcConnection();
Note: There should not be any commits or rollbacks in the Java program, if you are reusing the connection.
You can create your own connection, but you cannot use data such as profile option values, or user details. You can create a connection to any database, provided you have access to that database from the middle tier when Oracle Proposals code is running.
If you have defined a View Object earlier and want to use it to get data from other tables, you need to create it on the transaction and perform the query. Refer to Sample Code Program for details.
If you use the View Object, the BC4J layer prepares the SQL statement. Also, the View Object meta data (SQL statement) is cached, for better performance during subsequent executions.
After you have written a program, compile the program to get the class file and copy the class file into a directory that is included in the classpath. You can also add a new directory to the classpath, but you will need to restart your apache middle tier(s). Create a dynamic field, choose the type as Java program and then associate the package.class.method with it. Refer to Creating User Defined Dynamic Fields for information on field creation.
When you register the Java program, Oracle Proposals will validate whether the Java class file is accessible to the middle tier and if the method contains Hashtable as an input parameter and returns a String. It is therefore important to follow the preceding steps before creating the dynamic field.
While generating the proposal version, Oracle Proposals calls the Java program to get the String value and replace the dynamic field with the returned value in the generated document. If there is an error while calling the program, Oracle Proposals replaces the dynamic field with blank space in the generated document.
This sample code program contains two methods.
Method getUserLanguageGreeting: prints greetings in the generated proposal depending on the users' language, which is the language the user logs in to the application. For this it gets the user language from the View Object UserLanguageVO (In /oracle/apps/prp/common/server directory).
Method getSystemTime: prints the current system time while generating the proposals document.
public class PRPJavaTokenExample
//Method to get the System Time.
public String getSystemTime(Hashtable hash)
return new Timestamp(new Date().getTime()).toString();
//Method to get the Greeting in User Language.
public String getUserLanguageGreeting(Hashtable hash)
String greeting = "Greetings!";
//Get the Proposal Id. Notice that the proposalId is casted to oracle.jbo.domain.Number
Number proposalId = (Number)hash.get("proposalId");
OAViewObject UserLanguageVO = null;
//get the OADBTransaction
OADBTransaction oaDbTransaction = (OADBTransaction)hash.get("oaDbTransaction");
// Connection con = oaDbTransaction.getJdbcConnection();
//You will need the connection, if you are using JDBC to construct and execute the sql statement.
// Check if the transaction exists
if (oaDbTransaction != null)
// Create the View Object UserLanguageVO and execute the Query.
//Get the first row. This sql only returns one row.
Row rowUserLanguageVO = UserLanguageVO.next();
//Get the language code value from the view object.
String languageCode = (String)rowUserLanguageVO.getAttribute("LanguageCode");
greeting = "Hello World!!";
else if (languageCode.equals("FR"))
greeting = "Bonjour Monde!";
else if (languageCode.equals("E"))
greeting = "Hola Mundo!";
else if (languageCode.equals("D"))
greeting = "Hallo Welt!";
greeting = "Hello!";
catch (Throwable ex)
return "<Unexpected Error! (Creating VO)>";
return "<Unexpected Error!>";